Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@openzeppelin/hardhat-upgrades

Package Overview
Dependencies
Maintainers
2
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openzeppelin/hardhat-upgrades - npm Package Compare versions

Comparing version 1.11.0 to 1.12.0

4

CHANGELOG.md
# Changelog
## 1.12.0 (2021-10-28)
- Add support for `upgradeToAndCall` to batch a function call into the upgrade transaction. ([#443](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/443))
## 1.11.0 (2021-10-22)

@@ -4,0 +8,0 @@

4

dist/upgrade-proxy.d.ts
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import type { ContractFactory, Contract } from 'ethers';
import { Options, ContractAddressOrInstance } from './utils';
export declare type UpgradeFunction = (proxy: ContractAddressOrInstance, ImplFactory: ContractFactory, opts?: Options) => Promise<Contract>;
import { UpgradeOptions, ContractAddressOrInstance } from './utils';
export declare type UpgradeFunction = (proxy: ContractAddressOrInstance, ImplFactory: ContractFactory, opts?: UpgradeOptions) => Promise<Contract>;
export declare function makeUpgradeProxy(hre: HardhatRuntimeEnvironment): UpgradeFunction;
//# sourceMappingURL=upgrade-proxy.d.ts.map

@@ -11,3 +11,4 @@ "use strict";

const { impl: nextImpl } = await (0, utils_1.deployImpl)(hre, ImplFactory, opts, proxyAddress);
const upgradeTx = await upgradeTo(nextImpl);
const call = encodeCall(ImplFactory, opts.call);
const upgradeTx = await upgradeTo(nextImpl, call);
const inst = ImplFactory.attach(proxyAddress);

@@ -26,3 +27,3 @@ // @ts-ignore Won't be readonly because inst was created through attach.

const proxy = TransparentUpgradeableProxyFactory.attach(proxyAddress);
return nextImpl => proxy.upgradeTo(nextImpl);
return (nextImpl, call) => (call ? proxy.upgradeToAndCall(nextImpl, call) : proxy.upgradeTo(nextImpl));
}

@@ -38,3 +39,3 @@ else {

}
return nextImpl => admin.upgrade(proxyAddress, nextImpl);
return (nextImpl, call) => call ? admin.upgradeAndCall(proxyAddress, nextImpl, call) : admin.upgrade(proxyAddress, nextImpl);
}

@@ -44,2 +45,12 @@ }

exports.makeUpgradeProxy = makeUpgradeProxy;
function encodeCall(factory, call) {
var _a;
if (!call) {
return undefined;
}
if (typeof call === 'string') {
call = { fn: call };
}
return factory.interface.encodeFunctionData(call.fn, (_a = call.args) !== null && _a !== void 0 ? _a : []);
}
//# sourceMappingURL=upgrade-proxy.js.map

@@ -9,2 +9,8 @@ import { ValidationOptions } from '@openzeppelin/upgrades-core';

}
export interface UpgradeOptions extends Options {
call?: {
fn: string;
args?: unknown[];
} | string;
}
//# sourceMappingURL=options.d.ts.map
{
"name": "@openzeppelin/hardhat-upgrades",
"version": "1.11.0",
"version": "1.12.0",
"description": "",

@@ -5,0 +5,0 @@ "repository": "https://github.com/OpenZeppelin/openzeppelin-upgrades/tree/master/packages/plugin-hardhat",

@@ -7,3 +7,3 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types';

import {
Options,
UpgradeOptions,
deployImpl,

@@ -19,7 +19,7 @@ getTransparentUpgradeableProxyFactory,

ImplFactory: ContractFactory,
opts?: Options,
opts?: UpgradeOptions,
) => Promise<Contract>;
export function makeUpgradeProxy(hre: HardhatRuntimeEnvironment): UpgradeFunction {
return async function upgradeProxy(proxy, ImplFactory, opts: Options = {}) {
return async function upgradeProxy(proxy, ImplFactory, opts: UpgradeOptions = {}) {
const proxyAddress = getContractAddress(proxy);

@@ -29,3 +29,4 @@

const { impl: nextImpl } = await deployImpl(hre, ImplFactory, opts, proxyAddress);
const upgradeTx = await upgradeTo(nextImpl);
const call = encodeCall(ImplFactory, opts.call);
const upgradeTx = await upgradeTo(nextImpl, call);

@@ -38,3 +39,3 @@ const inst = ImplFactory.attach(proxyAddress);

type Upgrader = (nextImpl: string) => Promise<ethers.providers.TransactionResponse>;
type Upgrader = (nextImpl: string, call?: string) => Promise<ethers.providers.TransactionResponse>;

@@ -52,3 +53,3 @@ async function getUpgrader(proxyAddress: string, signer: Signer): Promise<Upgrader> {

return nextImpl => proxy.upgradeTo(nextImpl);
return (nextImpl, call) => (call ? proxy.upgradeToAndCall(nextImpl, call) : proxy.upgradeTo(nextImpl));
} else {

@@ -65,5 +66,18 @@ // Admin contract: redirect upgrade call through it

return nextImpl => admin.upgrade(proxyAddress, nextImpl);
return (nextImpl, call) =>
call ? admin.upgradeAndCall(proxyAddress, nextImpl, call) : admin.upgrade(proxyAddress, nextImpl);
}
}
}
function encodeCall(factory: ContractFactory, call: UpgradeOptions['call']): string | undefined {
if (!call) {
return undefined;
}
if (typeof call === 'string') {
call = { fn: call };
}
return factory.interface.encodeFunctionData(call.fn, call.args ?? []);
}

@@ -17,1 +17,5 @@ import { ValidationOptions, withValidationDefaults } from '@openzeppelin/upgrades-core';

}
export interface UpgradeOptions extends Options {
call?: { fn: string; args?: unknown[] } | string;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc