This repository has been archived by the owner on Dec 13, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace ethers usage to always import from module (#364)
* Replace all ethers utils with module imports * Fixed a few places I missed the first time * Update rollup for cf.js to include ethers.constants
- Loading branch information
Showing
22 changed files
with
104 additions
and
121 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 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
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import { ethers } from "ethers"; | ||
import { Arrayish, defaultAbiCoder, solidityPack } from "ethers/utils"; | ||
|
||
export function encode(types: string[], values: any[]) { | ||
return ethers.utils.defaultAbiCoder.encode(types, values); | ||
return defaultAbiCoder.encode(types, values); | ||
} | ||
|
||
export function decode(types: string[], data: ethers.utils.Arrayish) { | ||
return ethers.utils.defaultAbiCoder.decode(types, data); | ||
export function decode(types: string[], data: Arrayish) { | ||
return defaultAbiCoder.decode(types, data); | ||
} | ||
|
||
export function encodePacked(types: string[], values: any[]) { | ||
return ethers.utils.solidityPack(types, values); | ||
return solidityPack(types, values); | ||
} |
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 |
---|---|---|
@@ -1,26 +1,28 @@ | ||
import { ethers } from "ethers"; | ||
|
||
import { Bytes32 } from "@counterfactual/common-types"; | ||
import { | ||
BigNumber, | ||
joinSignature, | ||
recoverAddress, | ||
Signature | ||
} from "ethers/utils"; | ||
|
||
export function signaturesToBytes( | ||
...signatures: ethers.utils.Signature[] | ||
): string { | ||
export function signaturesToBytes(...signatures: Signature[]): string { | ||
const signaturesHexString = signatures | ||
.map(ethers.utils.joinSignature) | ||
.map(joinSignature) | ||
.map(s => s.substr(2)) | ||
.join(""); | ||
return `0x${signaturesHexString}`; | ||
} | ||
|
||
export function signaturesToSortedBytes( | ||
digest: Bytes32, | ||
...signatures: ethers.utils.Signature[] | ||
...signatures: Signature[] | ||
): string { | ||
const sigs = signatures.slice(); | ||
sigs.sort((sigA, sigB) => { | ||
const addrA = ethers.utils.recoverAddress(digest, signaturesToBytes(sigA)); | ||
const addrB = ethers.utils.recoverAddress(digest, signaturesToBytes(sigB)); | ||
return new ethers.utils.BigNumber(addrA).lt(addrB) ? -1 : 1; | ||
const addrA = recoverAddress(digest, signaturesToBytes(sigA)); | ||
const addrB = recoverAddress(digest, signaturesToBytes(sigB)); | ||
return new BigNumber(addrA).lt(addrB) ? -1 : 1; | ||
}); | ||
return signaturesToBytes(...sigs); | ||
} |
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
Oops, something went wrong.