ParaProxy EIP-2535 Operations

ParaProxy EIP-2535 Operations

The main way to interact with the ParaProxy is by using the function updateImplementation

which has the following signature

function updateImplementation(
        ProxyImplementation[] calldata _implementationParams,
        address _init,
        bytes calldata _calldata
    ) external

ProxyImplementation is 

struct ProxyImplementation {
        address implAddress;
        ProxyImplementationAction action;
        bytes4[] functionSelectors;
    }

ProxyImplementationAction is

enum ProxyImplementationAction {
        Add,
        Replace,
        Remove
    }

Only PoolAddressProvider can interact with the ParaProxy updateImplemnentation

Adding New Selectors

to add new selectors, we have to call updatePoolImpl in PoolAddressProvider

await addressesProvider.updatePoolImpl(
      [
        {
          implAddress: newPool.address,
          action: 0,
          functionSelectors: poolSelectors,
        },
      ],
      poolAddress,
      newPool.interface.encodeFunctionData("initialize", [
        addressesProvider.address,
      ])
    )

implAddress: is the implementation address

action: is action enum which can be Add (0), Replace (1), Remove (2)

functionSelectors: is an array of the 4byte keccak256 of the function selectors

poolAddress: is the address of the contract to call after the addition of the selectors. this can be an initialize function like what we provided in the following line:

newPool.interface.encodeFunctionData("initialize", [ addressesProvider.address, ])

Updating Existing Selectors

to update selectors, we have to call updatePoolImpl in PoolAddressProvider

await addressesProvider.updatePoolImpl(
      [
        {
          implAddress: newPool.address,
          action: 1,
          functionSelectors: poolSelectors,
        },
      ],
      poolAddress,
      newPool.interface.encodeFunctionData("initialize", [
        addressesProvider.address,
      ])
    )

implAddress: is the implementation address

action: is action enum which can be Add (0), Replace (1), Remove (2)

functionSelectors: is an array of the 4byte keccak256 of the function selectors

poolAddress: is the address of the contract to call after the addition of the selectors. this can be an initialize function like what we provided in the following line:

newPool.interface.encodeFunctionData("initialize", [ addressesProvider.address, ])

Deleting Selectors

to delete selectors, we have to call updatePoolImpl in PoolAddressProvider

await addressesProvider.updatePoolImpl(
      [
        {
          implAddress: ZERO_ADDRESS,
          action: 2,
          functionSelectors: oldPoolSelectors,
        },
      ],
      ZERO_ADDRESS,
      "0x"
    )

implAddress: this should be zero address

action: is action enum which can be Add (0), Replace (1), Remove (2)

functionSelectors: is an array of the 4byte keccak256 of the function selectors to delete

next argument is ZERO_ADDRESS or we can specify an implementation to call if we want then specify the exact encoded function to call.

Last updated