Created
May 9, 2023 21:20
-
-
Save blurpesec/99e68854510f858b35330009b825f533 to your computer and use it in GitHub Desktop.
Delegation - EOA -> EOA
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
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