|
|
|
@ -1,6 +1,6 @@ |
|
|
|
|
import { Plugin } from '@remixproject/engine' |
|
|
|
|
import { ContractAST, ContractSources, DeployOptions } from '../types/contract' |
|
|
|
|
import { UUPS, UUPSABI, UUPSBytecode, UUPSfunAbi, UUPSupgradeAbi } from './constants/uups' |
|
|
|
|
import { EnableProxyURLParam, UUPS, UUPSABI, UUPSBytecode, UUPSfunAbi, UUPSupgradeAbi } from './constants/uups' |
|
|
|
|
|
|
|
|
|
const proxyProfile = { |
|
|
|
|
name: 'openzeppelin-proxy', |
|
|
|
@ -33,31 +33,39 @@ export class OpenZeppelinProxy extends Plugin { |
|
|
|
|
async getProxyOptions (data: ContractSources, file: string): Promise<{ [name: string]: DeployOptions }> { |
|
|
|
|
const contracts = data.contracts[file] |
|
|
|
|
const ast = data.sources[file].ast |
|
|
|
|
const inputs = {} |
|
|
|
|
|
|
|
|
|
if (this.kind === 'UUPS') { |
|
|
|
|
Object.keys(contracts).map(name => { |
|
|
|
|
if (ast) { |
|
|
|
|
const UUPSSymbol = ast.exportedSymbols[UUPS] ? ast.exportedSymbols[UUPS][0] : null |
|
|
|
|
|
|
|
|
|
ast.absolutePath === file && ast.nodes.map((node) => { |
|
|
|
|
if (node.name === name && node.linearizedBaseContracts.includes(UUPSSymbol)) { |
|
|
|
|
const abi = contracts[name].abi |
|
|
|
|
const initializeInput = abi.find(node => node.name === 'initialize') |
|
|
|
|
|
|
|
|
|
inputs[name] = { |
|
|
|
|
options: [{ title: 'Deploy with Proxy', active: false }, { title: 'Upgrade with Proxy', active: false }], |
|
|
|
|
initializeOptions: { |
|
|
|
|
inputs: initializeInput, |
|
|
|
|
initializeInputs: initializeInput ? this.blockchain.getInputs(initializeInput) : null |
|
|
|
|
} |
|
|
|
|
const options = await (this.getUUPSContractOptions(contracts, ast, file)) |
|
|
|
|
|
|
|
|
|
return options |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async getUUPSContractOptions (contracts, ast, file) { |
|
|
|
|
const options = {} |
|
|
|
|
|
|
|
|
|
await Promise.all(Object.keys(contracts).map(async (name) => { |
|
|
|
|
if (ast) { |
|
|
|
|
const UUPSSymbol = ast.exportedSymbols[UUPS] ? ast.exportedSymbols[UUPS][0] : null |
|
|
|
|
|
|
|
|
|
await Promise.all(ast.absolutePath === file && ast.nodes.map(async (node) => { |
|
|
|
|
if (node.name === name && node.linearizedBaseContracts.includes(UUPSSymbol)) { |
|
|
|
|
const abi = contracts[name].abi |
|
|
|
|
const initializeInput = abi.find(node => node.name === 'initialize') |
|
|
|
|
const isDeployWithProxyEnabled: boolean = await this.call('config', 'getAppParameter', EnableProxyURLParam) || false |
|
|
|
|
|
|
|
|
|
options[name] = { |
|
|
|
|
options: [{ title: 'Deploy with Proxy', active: isDeployWithProxyEnabled }, { title: 'Upgrade with Proxy', active: false }], |
|
|
|
|
initializeOptions: { |
|
|
|
|
inputs: initializeInput, |
|
|
|
|
initializeInputs: initializeInput ? this.blockchain.getInputs(initializeInput) : null |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
return inputs |
|
|
|
|
} |
|
|
|
|
})) |
|
|
|
|
} |
|
|
|
|
})) |
|
|
|
|
return options |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async executeUUPSProxy(implAddress: string, args: string | string [] = '', initializeABI, implementationContractObject): Promise<void> { |
|
|
|
|