Finally get signature verification to match
This commit is contained in:
parent
7fcc4e99ec
commit
f2d957affc
|
@ -15,21 +15,17 @@ const ChequeType = [
|
|||
{ name: 'cumulativePayout', type: 'uint256' }
|
||||
]
|
||||
|
||||
// XXX Hardcoded from recent deploy to Hardhat dev chain
|
||||
var erc20address = "0x5FbDB2315678afecb367f032d93F642f64180aa3";
|
||||
// Seems to persist, first two default accounts
|
||||
var aliceAddress = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266";
|
||||
var aliceSwapAddress = "0xCafac3dD18aC6c6e92c921884f9E4176737C052c";
|
||||
var bobAddress = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8";
|
||||
|
||||
// XXX These change
|
||||
var erc20address = "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853";
|
||||
var aliceSwapAddress = "0x94099942864EA81cCF197E9D71ac53310b1468D8";
|
||||
|
||||
|
||||
// XXX Hardcoded return from sign-cheque script of cheque from Alice to Bob:
|
||||
// Cheque {
|
||||
// chequebook: '0xCafac3dD18aC6c6e92c921884f9E4176737C052c',
|
||||
// beneficiary: '0x70997970C51812dc3A010C7d01b50e0d17dc79C8',
|
||||
// cumulativePayout: 500
|
||||
//}
|
||||
var issuerSig = "0xa00dfb22e246211c39e594c35eb3321a8aa99c83cb94ea8dcb311a381181c04637676e95e1f51901a6c1f3423852a2431baed00b0cffca5719698055283069dc1c";
|
||||
|
||||
var issuerSig = "0x67c0c9ec1e72e90ebf0155b10953ec81b1ff5bca6283e51bee9bb55ec2fa14876278e88e8f0a34570bed0f9bed4cec9c576dc0ac34512adddbfd157b5be5df091c";
|
||||
// TODO This should be parameterized with arguments, so probably as a task or standalone script?
|
||||
async function main() {
|
||||
var recipient = bobAddress;
|
||||
|
|
|
@ -15,12 +15,14 @@ const ChequeType = [
|
|||
{ name: 'cumulativePayout', type: 'uint256' }
|
||||
]
|
||||
|
||||
// XXX Hardcoded from recent deploy to Hardhat dev chain
|
||||
var erc20address = "0x5FbDB2315678afecb367f032d93F642f64180aa3";
|
||||
// Seems to persist, first two default accounts
|
||||
var aliceAddress = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266";
|
||||
var aliceSwapAddress = "0xCafac3dD18aC6c6e92c921884f9E4176737C052c";
|
||||
var bobAddress = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8";
|
||||
|
||||
// XXX These change
|
||||
var erc20address = "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853";
|
||||
var aliceSwapAddress = "0x94099942864EA81cCF197E9D71ac53310b1468D8";
|
||||
|
||||
// TODO This should be parameterized with arguments, so probably as a task or standalone script?
|
||||
async function main() {
|
||||
var swapAddress = aliceSwapAddress;
|
||||
|
@ -39,25 +41,26 @@ async function main() {
|
|||
|
||||
console.log("Cheque", cheque);
|
||||
|
||||
const typedData = {
|
||||
types: {
|
||||
EIP712Domain,
|
||||
Cheque: ChequeType
|
||||
},
|
||||
domain: {
|
||||
name: "Chequebook",
|
||||
version: "1.0",
|
||||
chainId
|
||||
},
|
||||
primaryType: 'Cheque',
|
||||
message: cheque
|
||||
}
|
||||
const types = {
|
||||
Cheque: ChequeType
|
||||
};
|
||||
|
||||
const digest = eip712.TypedDataUtils.encodeDigest(typedData)
|
||||
const digestHex = ethers.utils.hexlify(digest)
|
||||
const domain = {
|
||||
name: "Chequebook",
|
||||
version: "1.0",
|
||||
chainId
|
||||
};
|
||||
|
||||
// NOTE this may be different from eth_signTypedData_v3, etc
|
||||
const signature = await aliceSigner.signMessage(digest)
|
||||
const value = cheque;
|
||||
|
||||
// XXX Workaround to get to private signTypedData interface
|
||||
var mnemonic = "test test test test test test test test test test test junk";
|
||||
var path0 = "m/44'/60'/0'/0/0";
|
||||
var recoveredWallet = ethers.Wallet.fromMnemonic(mnemonic, path0);
|
||||
var aliceSignerWallet = recoveredWallet.connect(ethers.provider);
|
||||
|
||||
var signature = await aliceSignerWallet._signTypedData(domain, types, value);
|
||||
console.log("Signer:", aliceSigner.address);
|
||||
console.log("Signature:", signature);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue