Skip to content

Commit

Permalink
support addLockManager in unlock admin script
Browse files Browse the repository at this point in the history
  • Loading branch information
canercidam committed Aug 7, 2023
1 parent d11843f commit 273c1da
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions scripts/unlock-admin/call.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ function withdraw(tokenAddress, recipient, amount) {
};
}

function addLockManager(address) {
return {
func: simplify(contracts.publicLock.getFunction('addLockManager')),
inputs: [address],
};
}

function simplify(func) {
return {
name: func.name,
Expand All @@ -46,5 +53,6 @@ module.exports = {
createUpgradeableLockAtVersion,
updateKeyPricing,
withdraw,
addLockManager,
ABI,
};
7 changes: 7 additions & 0 deletions scripts/unlock-admin/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,10 @@ proposals:
tokenAddress: '0x9ff62d1FC52A907B6DCbA8077c2DDCA6E6a9d3e1' # FORT token on Polygon
recipient: '0x874B5d427b2d27F6Ea0ed3BCE4De454824AEC9cC'
amount: '10000000000000000000' # enter in wei: example is 10 wei

- title: Add lock manager
description: Adds a new address as an Unlock lock manager
contract: publicLock
type: addLockManager
args:
address: '0x874B5d427b2d27F6Ea0ed3BCE4De454824AEC9cC'
6 changes: 5 additions & 1 deletion scripts/unlock-admin/propose.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function batchPropose(config, proposals) {
};
}
// create batch proposal
await defenderAdmin.createProposal({
const result = await defenderAdmin.createProposal({
contract: Object.keys(contracts).map((key) => contracts[key]),
title: config.title,
description: config.description,
Expand All @@ -57,6 +57,7 @@ async function batchPropose(config, proposals) {
metadata: {}, // required field but empty
steps,
});
console.log(result.url);
}

async function propose(config, proposal) {
Expand Down Expand Up @@ -93,6 +94,9 @@ function getCall(proposal) {
case 'withdraw':
return call.withdraw(args.tokenAddress, args.recipient, args.amount);

case 'addLockManager':
return call.addLockManager(args.address);

default:
throw `unknown proposal type ${proposal.type}`;
}
Expand Down

0 comments on commit 273c1da

Please sign in to comment.