-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
- Loading branch information
Showing
13 changed files
with
1,242 additions
and
235 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
* xref:index.adoc[Overview] | ||
* xref:truffle-upgrades.adoc[Using with Truffle] | ||
* xref:buidler-upgrades.adoc[Using with Buidler] | ||
* xref:writing-upgradeable.adoc[Writing Upgradeable Contracts] | ||
* xref:proxies.adoc[Proxies] | ||
* xref:network-files.adoc[Network Files] | ||
* xref:faq.adoc[Frequently Asked Questions] | ||
.API Reference | ||
* xref:api-truffle-upgrades.adoc[Truffle Upgrades] | ||
* xref:api-buidler-upgrades.adoc[Buidler Upgrades] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
= OpenZeppelin Buidler Upgrades API | ||
|
||
Both `deployProxy` and `upgradeProxy` functions will return instances of https://docs.ethers.io/v5/api/contract/contract[ethers.js contracts], and require https://docs.ethers.io/v5/api/contract/contract-factory[ethers.js contract factories] as arguments. All functions validate that the implementation contract is upgrade-safe, and will fail otherwise. | ||
|
||
[[deploy-proxy]] | ||
== deployProxy | ||
|
||
Creates a proxy given an ethers contract factory to use as implementation, and returns a contract instance with the proxy address and the implementation interface. If `args` is set, will call an initializer function `initialize` with the supplied args during proxy deployment. | ||
|
||
Options are: | ||
|
||
* `initializer`: sets a different initializer function to call | ||
* `unsafeAllowCustomTypes`: allows a deployment where structs or enums are used in the implementation contract (required since xref:faq.adoc#what-does-it-mean-for-an-implementation-to-be-compatible[storage compatibility validations] do not handle custom types, so make sure the change you are introducing is safe) | ||
|
||
[source,ts] | ||
---- | ||
async function deployProxy( | ||
Contract: ethers.ContractFactory, | ||
args: unknown[] = [], | ||
opts: { initializer: string, unsafeAllowCustomTypes: boolean } = {}, | ||
): Promise<ethers.Contract> | ||
---- | ||
|
||
[[upgrade-proxy]] | ||
== upgradeProxy | ||
|
||
Upgrades a proxy at a specified address to a new implementation contract, and returns a contract instance with the proxy address and the new implementation interface. | ||
|
||
Options are: | ||
|
||
* `unsafeAllowCustomTypes`: allows an upgrade where structs or enums are used in the implementation contract (required since xref:faq.adoc#what-does-it-mean-for-an-implementation-to-be-compatible[storage compatibility validations] do not handle custom types, so make sure the change you are introducing is safe) | ||
|
||
[source,ts] | ||
---- | ||
async function upgradeProxy( | ||
proxyAddress: string, | ||
Contract: ethers.ContractFactory, | ||
opts: { unsafeAllowCustomTypes: boolean } = {}, | ||
): Promise<ethers.Contract> | ||
---- | ||
|
||
[[prepare-upgrade]] | ||
== prepareUpgrade | ||
|
||
Validates and deploys a new implementation contract, and returns its address. Use this method to prepare an upgrade to be run from an admin address you do not control directly or cannot use from Buidler. | ||
|
||
Options are: | ||
|
||
* `unsafeAllowCustomTypes`: allows an upgrade where structs or enums are used in the implementation contract (required since xref:faq.adoc#what-does-it-mean-for-an-implementation-to-be-compatible[storage compatibility validations] do not handle custom types, so make sure the change you are introducing is safe) | ||
|
||
[source,ts] | ||
---- | ||
async function prepareUpgrade( | ||
proxyAddress: string, | ||
Contract: ethers.ContractFactory, | ||
opts: { unsafeAllowCustomTypes: boolean } = {}, | ||
): Promise<string> | ||
---- | ||
|
||
[[admin-change-admin-for-proxy]] | ||
== admin.changeAdminForProxy | ||
|
||
Changes the admin for a specific proxy. Receives the address of the proxy to change, and the new admin address. | ||
|
||
[source,ts] | ||
---- | ||
async function changeAdminForProxy( | ||
proxyAddress: string, | ||
newAdmin: string, | ||
): Promise<void> | ||
---- | ||
|
||
[[admin-transfer-proxy-admin-ownership]] | ||
== admin.transferProxyAdminOwnership | ||
|
||
Changes the owner of the proxy admin contract, which is the default admin for upgrade rights over all proxies. Receives the new admin address. | ||
|
||
[source,ts] | ||
---- | ||
async function transferProxyAdminOwnership( | ||
newAdmin: string, | ||
): Promise<void> | ||
---- |
Oops, something went wrong.