diff --git a/scripts/orium-marketplace-royalties/11-propose-transfer-ownership.ts b/scripts/orium-marketplace-royalties/11-propose-transfer-ownership.ts new file mode 100644 index 0000000..a69512d --- /dev/null +++ b/scripts/orium-marketplace-royalties/11-propose-transfer-ownership.ts @@ -0,0 +1,21 @@ +import config from '../../addresses' +import { createDefenderProposal } from '../../utils/defender-proposal' +import { print, colors } from '../../utils/misc' + +const CONTRACT_NAME = 'OriumMarketplaceRoyalties' +const FUNCTION_NAME = 'transferOwnership' +const FUNCTION_INPUTS_TYPE = [{ type: 'address', name: '_newOwner' }] +const FUNCTION_INPUTS = [config.polygon.KMSDeployer.address] + +async function main() { + await createDefenderProposal(CONTRACT_NAME, FUNCTION_NAME, FUNCTION_INPUTS_TYPE, FUNCTION_INPUTS) +} + +main() + .then(() => { + print(colors.bigSuccess, 'All done!') + }) + .catch(error => { + console.error(error) + process.exitCode = 1 + }) diff --git a/utils/defender-proposal.ts b/utils/defender-proposal.ts new file mode 100644 index 0000000..03fdaf6 --- /dev/null +++ b/utils/defender-proposal.ts @@ -0,0 +1,54 @@ +import { network as hardhatNetwork } from 'hardhat' +import config, { Network } from '../addresses' +import { print, colors, confirmOrDie } from '../utils/misc' +import { AdminClient } from 'defender-admin-client' + +const NETWORK: Network = hardhatNetwork.name as Network +const DEFENDER_API_KEY = process.env.DEFENDER_TEAM_API_KEY +const DEFENDER_API_SECRET = process.env.DEFENDER_TEAM_API_SECRET_KEY + +/** + * @notice Create Defender Proposal + * @dev This function creates a Defender Proposal + * @param CONTRACT_NAME The contract name from the config file + * @param FUNCTION_NAME The function name to be called + * @param FUNCTION_INPUTS_TYPE The function inputs type + * @param FUNCTION_INPUTS The function inputs + */ +export async function createDefenderProposal( + CONTRACT_NAME: keyof (typeof config)[Network], + FUNCTION_NAME: string, + FUNCTION_INPUTS_TYPE: { type: string; name: string }[], + FUNCTION_INPUTS: any[], +) { + console.log(FUNCTION_INPUTS_TYPE) + console.log(FUNCTION_INPUTS) + await confirmOrDie(`Are you sure you want to create Defender Proposal to ${FUNCTION_NAME} on ${NETWORK} network?`) + + print(colors.highlight, `Create Defender Upgrade Proposal...`) + if (!DEFENDER_API_KEY || !DEFENDER_API_SECRET) return print(colors.error, 'Missing Defender API Key or Secret') + const adminClient = new AdminClient({ + apiKey: DEFENDER_API_KEY, + apiSecret: DEFENDER_API_SECRET, + }) + + const customNetwork = NETWORK === 'polygon' ? 'matic' : NETWORK + if (customNetwork === 'cronosTestnet' || customNetwork === 'cronos') + return print(colors.error, 'Cronos not supported') + + const proposal = await adminClient.createProposal({ + contract: { address: config[NETWORK][CONTRACT_NAME].address, network: customNetwork }, + title: `Proposal to ${FUNCTION_NAME} on ${CONTRACT_NAME}`, + description: '', + type: 'custom', + functionInterface: { + name: FUNCTION_NAME, + inputs: FUNCTION_INPUTS_TYPE, + }, + functionInputs: FUNCTION_INPUTS, + via: config[NETWORK].Multisig.address, + viaType: 'Gnosis Safe', + }) + + print(colors.bigSuccess, `Upgrade proposal created at: ${proposal.url}`) +}