Skip to content

Instantly share code, notes, and snippets.

@blurpesec
Created May 9, 2023 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blurpesec/99e68854510f858b35330009b825f533 to your computer and use it in GitHub Desktop.
Save blurpesec/99e68854510f858b35330009b825f533 to your computer and use it in GitHub Desktop.
Delegation - EOA -> EOA
expect(await Delegatable.purpose()).to.eq("What is my purpose?");
const delegation = {
delegate: wallet1.address,
authority:
"0x0000000000000000000000000000000000000000000000000000000000000000",
caveats: [],
salt: 0,
};
const delegationSignature = signingUtil.signTypedDataLocal(
pk0,
"Delegation",
delegation
);
const signedDelegation = {
signature: delegationSignature,
signer: ethers.constants.AddressZero,
message: delegation,
};
const batch = {
replayProtection: {
nonce: "0x01",
queue: "0x00",
},
invocations: [
{
authority: [signedDelegation],
transaction: {
to: Delegatable.address,
gasLimit: "21000000000000",
value: 0,
data: (
await Delegatable.populateTransaction.setPurpose("To delegate!")
).data,
},
},
],
};
const signature = signingUtil.signTypedDataLocal(pk0, "Batch", batch);
await Delegatable.invoke({
signature,
message: batch,
signer: ethers.constants.AddressZero,
});
expect(await Delegatable.purpose()).to.eq("To delegate!");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment