Last active
August 18, 2021 21:36
-
-
Save ajb413/3219115f1d74f35430a1cd85bc13fc2e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
sign.onclick = async () => { | |
const _delegatee = delegateTo.value; | |
const _nonce = await comp.methods.nonces(myAccount).call(); | |
const _expiry = 10e9; // expiration of signature, in seconds since unix epoch | |
const _chainId = window.ethereum.chainId.toString(); | |
const msgParams = createDelegateBySigMessage(compAddress, _delegatee, _expiry, _chainId, _nonce); | |
window.ethereum.sendAsync({ | |
method: 'eth_signTypedData_v4', | |
params: [ myAccount, msgParams ], | |
from: myAccount | |
}, async (err, result) => { | |
if (err) { | |
console.error('ERROR', err); | |
alert(err); | |
return; | |
} else if (result.error) { | |
console.error('ERROR', result.error.message); | |
alert(result.error.message); | |
return; | |
} | |
const sig = result.result; | |
delegatee.value = _delegatee; | |
nonce.value = _nonce; | |
expiry.value = _expiry; | |
signature.value = sig; | |
console.log('signature', sig); | |
console.log('msgParams', JSON.parse(msgParams)); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment