-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* upgrade jest, ts-jest to latest * support ethers@6 * loosen peerDependencies on siwe * set up ethers5 and ethers6 devDependencies to enable testing with both versions * allow test runner to select ethers 5 or 6 * create a compatibility layer that exports the right functions based on whether we are using ethers v5 or v6
- Loading branch information
Showing
13 changed files
with
2,166 additions
and
1,947 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
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
jest.mock('ethers', () => { | ||
const packages = { | ||
5: 'ethers5', | ||
6: 'ethers6', | ||
}; | ||
const version = process.env.ETHERSJS_VERSION || '6'; | ||
console.log('Testing with ethers version', version); | ||
|
||
// Require the original module. | ||
const originalModule = jest.requireActual(packages[version]); | ||
|
||
return { | ||
__esModule: true, | ||
...originalModule, | ||
}; | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { | ||
utils, | ||
// @ts-expect-error -- ethers v6 compatibility hack | ||
verifyMessage as ethersVerifyMessage, | ||
// @ts-expect-error -- ethers v6 compatibility hack | ||
hashMessage as ethersHashMessage, | ||
// @ts-expect-error -- ethers v6 compatibility hack | ||
getAddress as ethersGetAddress, | ||
} from 'ethers'; | ||
|
||
type Ethers6BigNumberish = string | number | bigint; | ||
|
||
// NB: This compatibility type omits the `Signature` class defined in ethers v6; | ||
// however, a `Signature` instance is compatible with the object type defined. | ||
type Ethers6SignatureLike = | ||
| string | ||
| { | ||
r: string; | ||
s: string; | ||
v: Ethers6BigNumberish; | ||
yParity?: 0 | 1; | ||
yParityAndS?: string; | ||
} | ||
| { | ||
r: string; | ||
yParityAndS: string; | ||
yParity?: 0 | 1; | ||
s?: string; | ||
v?: number; | ||
} | ||
| { | ||
r: string; | ||
s: string; | ||
yParity: 0 | 1; | ||
v?: Ethers6BigNumberish; | ||
yParityAndS?: string; | ||
}; | ||
|
||
export const verifyMessage = | ||
utils?.verifyMessage ?? | ||
(ethersVerifyMessage as ( | ||
message: Uint8Array | string, | ||
sig: Ethers6SignatureLike | ||
) => string); | ||
|
||
export const hashMessage = | ||
utils?.hashMessage ?? | ||
(ethersHashMessage as (message: Uint8Array | string) => string); | ||
|
||
export const getAddress = | ||
utils?.getAddress ?? (ethersGetAddress as (address: string) => string); |
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