-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: added dma-library wrapper for signing and ChargeFee
- Loading branch information
Showing
3 changed files
with
75 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
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,18 @@ | ||
import type { Signer } from 'ethers' | ||
import { ethers } from 'ethers' | ||
|
||
/** | ||
* | ||
* @param signer Wallet with signing capabilities, i.e: with a private key | ||
* @param calldataTypes Types of the calldata to be signed in solidity format | ||
* @param calldataValues Values of the calldata to be signed | ||
* @returns Signature of the calldata | ||
*/ | ||
export async function signSolidityCalldata( | ||
signer: Signer, | ||
calldataTypes: string[], | ||
calldataValues: any[], | ||
): Promise<string> { | ||
const msgHash = ethers.utils.solidityKeccak256(calldataTypes, calldataValues) | ||
return await signer.signMessage(ethers.utils.arrayify(msgHash)) | ||
} |