@openzeppelin/upgrades-core 1.10.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/artifacts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol/ERC1967Proxy.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol/BeaconProxy.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol/BeaconProxy.json +80 -0
- package/artifacts/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol/UpgradeableBeacon.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol/UpgradeableBeacon.json +113 -0
- package/artifacts/AdminUpgradeabilityProxy.json +2 -2
- package/artifacts/contracts/proxy/AdminUpgradeabilityProxy.sol/AdminUpgradeabilityProxy.json +2 -2
- package/dist/beacon.d.ts +8 -0
- package/dist/beacon.d.ts.map +1 -0
- package/dist/beacon.js +25 -0
- package/dist/beacon.js.map +1 -0
- package/dist/eip-1967-type.d.ts +4 -0
- package/dist/eip-1967-type.d.ts.map +1 -0
- package/dist/eip-1967-type.js +37 -0
- package/dist/eip-1967-type.js.map +1 -0
- package/dist/eip-1967.d.ts +5 -0
- package/dist/eip-1967.d.ts.map +1 -1
- package/dist/eip-1967.js +19 -12
- package/dist/eip-1967.js.map +1 -1
- package/dist/impl-address.d.ts +19 -0
- package/dist/impl-address.d.ts.map +1 -0
- package/dist/impl-address.js +67 -0
- package/dist/impl-address.js.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -3
- package/dist/index.js.map +1 -1
- package/dist/manifest.d.ts +1 -1
- package/dist/manifest.d.ts.map +1 -1
- package/dist/provider.d.ts +2 -0
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +11 -1
- package/dist/provider.js.map +1 -1
- package/dist/proxy-kind.d.ts +12 -0
- package/dist/proxy-kind.d.ts.map +1 -0
- package/dist/proxy-kind.js +50 -0
- package/dist/proxy-kind.js.map +1 -0
- package/dist/usage-error.d.ts +21 -0
- package/dist/usage-error.d.ts.map +1 -0
- package/dist/usage-error.js +51 -0
- package/dist/usage-error.js.map +1 -0
- package/dist/utils/address.d.ts +8 -0
- package/dist/utils/address.d.ts.map +1 -0
- package/dist/utils/address.js +20 -0
- package/dist/utils/address.js.map +1 -0
- package/dist/validate/overrides.js +1 -1
- package/dist/validate/overrides.js.map +1 -1
- package/package.json +6 -3
- package/src/beacon.ts +20 -0
- package/src/eip-1967-type.ts +35 -0
- package/src/eip-1967.ts +16 -12
- package/src/impl-address.ts +76 -0
- package/src/index.ts +16 -1
- package/src/manifest.ts +1 -1
- package/src/provider.ts +16 -0
- package/src/proxy-kind.ts +59 -0
- package/src/usage-error.ts +68 -0
- package/src/utils/address.ts +16 -0
- package/src/validate/overrides.ts +1 -1
- package/CHANGELOG.md +0 -120
- package/dist/set-proxy-kind.d.ts +0 -5
- package/dist/set-proxy-kind.d.ts.map +0 -1
- package/dist/set-proxy-kind.js +0 -25
- package/dist/set-proxy-kind.js.map +0 -1
- package/src/set-proxy-kind.ts +0 -27
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getImplementationAddressFromProxy = exports.getImplementationAddressFromBeacon = exports.InvalidBeacon = void 0;
|
|
4
|
+
const ethereumjs_util_1 = require("ethereumjs-util");
|
|
5
|
+
const _1 = require(".");
|
|
6
|
+
const address_1 = require("./utils/address");
|
|
7
|
+
class InvalidBeacon extends _1.UpgradesError {
|
|
8
|
+
}
|
|
9
|
+
exports.InvalidBeacon = InvalidBeacon;
|
|
10
|
+
/**
|
|
11
|
+
* Gets the implementation address from the beacon using its implementation() function.
|
|
12
|
+
* @param provider
|
|
13
|
+
* @param beaconAddress
|
|
14
|
+
* @returns The implementation address.
|
|
15
|
+
* @throws {InvalidBeacon} If the implementation() function could not be called or does not return an address.
|
|
16
|
+
*/
|
|
17
|
+
async function getImplementationAddressFromBeacon(provider, beaconAddress) {
|
|
18
|
+
const implementationFunction = '0x' + (0, ethereumjs_util_1.keccak256)(Buffer.from('implementation()')).toString('hex').slice(0, 8);
|
|
19
|
+
let result;
|
|
20
|
+
try {
|
|
21
|
+
const implAddress = await (0, _1.call)(provider, beaconAddress, implementationFunction);
|
|
22
|
+
result = (0, address_1.parseAddress)(implAddress);
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
if (!(e.message.includes('function selector was not recognized') ||
|
|
26
|
+
e.message.includes('invalid opcode') ||
|
|
27
|
+
e.message.includes('Transaction reverted'))) {
|
|
28
|
+
throw e;
|
|
29
|
+
} // otherwise fall through with no result
|
|
30
|
+
}
|
|
31
|
+
if (result === undefined) {
|
|
32
|
+
throw new InvalidBeacon(`Contract at ${beaconAddress} doesn't look like a beacon`);
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
exports.getImplementationAddressFromBeacon = getImplementationAddressFromBeacon;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the implementation address from a UUPS/Transparent/Beacon proxy.
|
|
39
|
+
*
|
|
40
|
+
* @returns a Promise with the implementation address, or undefined if a UUPS/Transparent/Beacon proxy is not located at the address.
|
|
41
|
+
*/
|
|
42
|
+
async function getImplementationAddressFromProxy(provider, proxyAddress) {
|
|
43
|
+
try {
|
|
44
|
+
return await (0, _1.getImplementationAddress)(provider, proxyAddress);
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
if (e instanceof _1.EIP1967ImplementationNotFound) {
|
|
48
|
+
try {
|
|
49
|
+
const beaconAddress = await (0, _1.getBeaconAddress)(provider, proxyAddress);
|
|
50
|
+
return await getImplementationAddressFromBeacon(provider, beaconAddress);
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
if (e instanceof _1.EIP1967BeaconNotFound) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
throw e;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
throw e;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.getImplementationAddressFromProxy = getImplementationAddressFromProxy;
|
|
67
|
+
//# sourceMappingURL=impl-address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"impl-address.js","sourceRoot":"","sources":["../src/impl-address.ts"],"names":[],"mappings":";;;AAAA,qDAA4C;AAC5C,wBAOW;AAGX,6CAA+C;AAE/C,MAAa,aAAc,SAAQ,gBAAa;CAAG;AAAnD,sCAAmD;AAEnD;;;;;;GAMG;AACI,KAAK,UAAU,kCAAkC,CACtD,QAA0B,EAC1B,aAAqB;IAErB,MAAM,sBAAsB,GAAG,IAAI,GAAG,IAAA,2BAAS,EAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7G,IAAI,MAA0B,CAAC;IAC/B,IAAI;QACF,MAAM,WAAW,GAAG,MAAM,IAAA,OAAI,EAAC,QAAQ,EAAE,aAAa,EAAE,sBAAsB,CAAC,CAAC;QAChF,MAAM,GAAG,IAAA,sBAAY,EAAC,WAAW,CAAC,CAAC;KACpC;IAAC,OAAO,CAAM,EAAE;QACf,IACE,CAAC,CACC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,sCAAsC,CAAC;YAC1D,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC;YACpC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAC3C,EACD;YACA,MAAM,CAAC,CAAC;SACT,CAAC,wCAAwC;KAC3C;IACD,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,MAAM,IAAI,aAAa,CAAC,eAAe,aAAa,6BAA6B,CAAC,CAAC;KACpF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAxBD,gFAwBC;AAED;;;;GAIG;AACI,KAAK,UAAU,iCAAiC,CACrD,QAA0B,EAC1B,YAAoB;IAEpB,IAAI;QACF,OAAO,MAAM,IAAA,2BAAwB,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;KAC/D;IAAC,OAAO,CAAM,EAAE;QACf,IAAI,CAAC,YAAY,gCAA6B,EAAE;YAC9C,IAAI;gBACF,MAAM,aAAa,GAAG,MAAM,IAAA,mBAAgB,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;gBACrE,OAAO,MAAM,kCAAkC,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;aAC1E;YAAC,OAAO,CAAM,EAAE;gBACf,IAAI,CAAC,YAAY,wBAAqB,EAAE;oBACtC,OAAO,SAAS,CAAC;iBAClB;qBAAM;oBACL,MAAM,CAAC,CAAC;iBACT;aACF;SACF;aAAM;YACL,MAAM,CAAC,CAAC;SACT;KACF;AACH,CAAC;AAtBD,8EAsBC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,9 +9,14 @@ export * from './src-decoder';
|
|
|
9
9
|
export * from './solc-api';
|
|
10
10
|
export * from './deployment';
|
|
11
11
|
export * from './link-refs';
|
|
12
|
+
export * from './error';
|
|
12
13
|
export { getStorageLayoutForAddress } from './manifest-storage-layout';
|
|
13
14
|
export * from './scripts/migrate-oz-cli-project';
|
|
14
15
|
export { logWarning } from './utils/log';
|
|
15
|
-
export { setProxyKind } from './
|
|
16
|
+
export { setProxyKind, processProxyKind } from './proxy-kind';
|
|
16
17
|
export { UpgradeableContract } from './standalone';
|
|
18
|
+
export { isTransparentOrUUPSProxy, isBeaconProxy } from './eip-1967-type';
|
|
19
|
+
export { getImplementationAddressFromBeacon, getImplementationAddressFromProxy } from './impl-address';
|
|
20
|
+
export { isBeacon } from './beacon';
|
|
21
|
+
export { BeaconProxyUnsupportedError, LoadProxyUnsupportedError, PrepareUpgradeUnsupportedError, DeployBeaconProxyUnsupportedError, DeployBeaconProxyImplUnknownError, DeployBeaconProxyKindError, assertNotProxy, } from './usage-error';
|
|
17
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAEvE,cAAc,kCAAkC,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,kCAAkC,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AACvG,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,8BAA8B,EAC9B,iCAAiC,EACjC,iCAAiC,EACjC,0BAA0B,EAC1B,cAAc,GACf,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.UpgradeableContract = exports.setProxyKind = exports.logWarning = exports.getStorageLayoutForAddress = void 0;
|
|
13
|
+
exports.assertNotProxy = exports.DeployBeaconProxyKindError = exports.DeployBeaconProxyImplUnknownError = exports.DeployBeaconProxyUnsupportedError = exports.PrepareUpgradeUnsupportedError = exports.LoadProxyUnsupportedError = exports.BeaconProxyUnsupportedError = exports.isBeacon = exports.getImplementationAddressFromProxy = exports.getImplementationAddressFromBeacon = exports.isBeaconProxy = exports.isTransparentOrUUPSProxy = exports.UpgradeableContract = exports.processProxyKind = exports.setProxyKind = exports.logWarning = exports.getStorageLayoutForAddress = void 0;
|
|
14
14
|
__exportStar(require("./validate"), exports);
|
|
15
15
|
__exportStar(require("./impl-store"), exports);
|
|
16
16
|
__exportStar(require("./version"), exports);
|
|
@@ -22,13 +22,31 @@ __exportStar(require("./src-decoder"), exports);
|
|
|
22
22
|
__exportStar(require("./solc-api"), exports);
|
|
23
23
|
__exportStar(require("./deployment"), exports);
|
|
24
24
|
__exportStar(require("./link-refs"), exports);
|
|
25
|
+
__exportStar(require("./error"), exports);
|
|
25
26
|
var manifest_storage_layout_1 = require("./manifest-storage-layout");
|
|
26
27
|
Object.defineProperty(exports, "getStorageLayoutForAddress", { enumerable: true, get: function () { return manifest_storage_layout_1.getStorageLayoutForAddress; } });
|
|
27
28
|
__exportStar(require("./scripts/migrate-oz-cli-project"), exports);
|
|
28
29
|
var log_1 = require("./utils/log");
|
|
29
30
|
Object.defineProperty(exports, "logWarning", { enumerable: true, get: function () { return log_1.logWarning; } });
|
|
30
|
-
var
|
|
31
|
-
Object.defineProperty(exports, "setProxyKind", { enumerable: true, get: function () { return
|
|
31
|
+
var proxy_kind_1 = require("./proxy-kind");
|
|
32
|
+
Object.defineProperty(exports, "setProxyKind", { enumerable: true, get: function () { return proxy_kind_1.setProxyKind; } });
|
|
33
|
+
Object.defineProperty(exports, "processProxyKind", { enumerable: true, get: function () { return proxy_kind_1.processProxyKind; } });
|
|
32
34
|
var standalone_1 = require("./standalone");
|
|
33
35
|
Object.defineProperty(exports, "UpgradeableContract", { enumerable: true, get: function () { return standalone_1.UpgradeableContract; } });
|
|
36
|
+
var eip_1967_type_1 = require("./eip-1967-type");
|
|
37
|
+
Object.defineProperty(exports, "isTransparentOrUUPSProxy", { enumerable: true, get: function () { return eip_1967_type_1.isTransparentOrUUPSProxy; } });
|
|
38
|
+
Object.defineProperty(exports, "isBeaconProxy", { enumerable: true, get: function () { return eip_1967_type_1.isBeaconProxy; } });
|
|
39
|
+
var impl_address_1 = require("./impl-address");
|
|
40
|
+
Object.defineProperty(exports, "getImplementationAddressFromBeacon", { enumerable: true, get: function () { return impl_address_1.getImplementationAddressFromBeacon; } });
|
|
41
|
+
Object.defineProperty(exports, "getImplementationAddressFromProxy", { enumerable: true, get: function () { return impl_address_1.getImplementationAddressFromProxy; } });
|
|
42
|
+
var beacon_1 = require("./beacon");
|
|
43
|
+
Object.defineProperty(exports, "isBeacon", { enumerable: true, get: function () { return beacon_1.isBeacon; } });
|
|
44
|
+
var usage_error_1 = require("./usage-error");
|
|
45
|
+
Object.defineProperty(exports, "BeaconProxyUnsupportedError", { enumerable: true, get: function () { return usage_error_1.BeaconProxyUnsupportedError; } });
|
|
46
|
+
Object.defineProperty(exports, "LoadProxyUnsupportedError", { enumerable: true, get: function () { return usage_error_1.LoadProxyUnsupportedError; } });
|
|
47
|
+
Object.defineProperty(exports, "PrepareUpgradeUnsupportedError", { enumerable: true, get: function () { return usage_error_1.PrepareUpgradeUnsupportedError; } });
|
|
48
|
+
Object.defineProperty(exports, "DeployBeaconProxyUnsupportedError", { enumerable: true, get: function () { return usage_error_1.DeployBeaconProxyUnsupportedError; } });
|
|
49
|
+
Object.defineProperty(exports, "DeployBeaconProxyImplUnknownError", { enumerable: true, get: function () { return usage_error_1.DeployBeaconProxyImplUnknownError; } });
|
|
50
|
+
Object.defineProperty(exports, "DeployBeaconProxyKindError", { enumerable: true, get: function () { return usage_error_1.DeployBeaconProxyKindError; } });
|
|
51
|
+
Object.defineProperty(exports, "assertNotProxy", { enumerable: true, get: function () { return usage_error_1.assertNotProxy; } });
|
|
34
52
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,+CAA6B;AAC7B,4CAA0B;AAC1B,6CAA2B;AAC3B,4CAA0B;AAC1B,6CAA2B;AAC3B,6CAA2B;AAC3B,gDAA8B;AAC9B,6CAA2B;AAC3B,+CAA6B;AAC7B,8CAA4B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,+CAA6B;AAC7B,4CAA0B;AAC1B,6CAA2B;AAC3B,4CAA0B;AAC1B,6CAA2B;AAC3B,6CAA2B;AAC3B,gDAA8B;AAC9B,6CAA2B;AAC3B,+CAA6B;AAC7B,8CAA4B;AAC5B,0CAAwB;AAExB,qEAAuE;AAA9D,qIAAA,0BAA0B,OAAA;AAEnC,mEAAiD;AAEjD,mCAAyC;AAAhC,iGAAA,UAAU,OAAA;AACnB,2CAA8D;AAArD,0GAAA,YAAY,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AAEvC,2CAAmD;AAA1C,iHAAA,mBAAmB,OAAA;AAE5B,iDAA0E;AAAjE,yHAAA,wBAAwB,OAAA;AAAE,8GAAA,aAAa,OAAA;AAChD,+CAAuG;AAA9F,kIAAA,kCAAkC,OAAA;AAAE,iIAAA,iCAAiC,OAAA;AAC9E,mCAAoC;AAA3B,kGAAA,QAAQ,OAAA;AAEjB,6CAQuB;AAPrB,0HAAA,2BAA2B,OAAA;AAC3B,wHAAA,yBAAyB,OAAA;AACzB,6HAAA,8BAA8B,OAAA;AAC9B,gIAAA,iCAAiC,OAAA;AACjC,gIAAA,iCAAiC,OAAA;AACjC,yHAAA,0BAA0B,OAAA;AAC1B,6GAAA,cAAc,OAAA"}
|
package/dist/manifest.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface ImplDeployment extends Deployment {
|
|
|
13
13
|
layout: StorageLayout;
|
|
14
14
|
}
|
|
15
15
|
export interface ProxyDeployment extends Deployment {
|
|
16
|
-
kind: 'uups' | 'transparent';
|
|
16
|
+
kind: 'uups' | 'transparent' | 'beacon';
|
|
17
17
|
}
|
|
18
18
|
export declare class Manifest {
|
|
19
19
|
readonly chainId: number;
|
package/dist/manifest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAA4B,MAAM,YAAY,CAAC;AAIxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAM/C,MAAM,WAAW,YAAY;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK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AO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IASlE,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAS9D,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAY/C,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC;IAgB7B,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAQxC,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;YAYtC,IAAI;CASnB;AAgBD,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY,CAUhE;AAED,qBAAa,kBAAmB,SAAQ,KAAK;CAAG"}
|
package/dist/provider.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export interface EthereumProvider {
|
|
|
3
3
|
send(method: 'net_version', params: []): Promise<string>;
|
|
4
4
|
send(method: 'eth_chainId', params: []): Promise<string>;
|
|
5
5
|
send(method: 'eth_getCode', params: [string, string]): Promise<string>;
|
|
6
|
+
send(method: 'eth_call', params: unknown[]): Promise<string>;
|
|
6
7
|
send(method: 'eth_getStorageAt', params: [string, string, string]): Promise<string>;
|
|
7
8
|
send(method: 'eth_getTransactionByHash', params: [string]): Promise<null | EthereumTransaction>;
|
|
8
9
|
send(method: 'eth_getTransactionReceipt', params: [string]): Promise<null | EthereumTransactionReceipt>;
|
|
@@ -25,6 +26,7 @@ export declare function getChainId(provider: EthereumProvider): Promise<number>;
|
|
|
25
26
|
export declare function getClientVersion(provider: EthereumProvider): Promise<string>;
|
|
26
27
|
export declare function getStorageAt(provider: EthereumProvider, address: string, position: string, block?: string): Promise<string>;
|
|
27
28
|
export declare function getCode(provider: EthereumProvider, address: string, block?: string): Promise<string>;
|
|
29
|
+
export declare function call(provider: EthereumProvider, address: string, data: string, block?: string): Promise<string>;
|
|
28
30
|
export declare function hasCode(provider: EthereumProvider, address: string, block?: string): Promise<boolean>;
|
|
29
31
|
export declare function getTransactionByHash(provider: EthereumProvider, txHash: string): Promise<EthereumTransaction | null>;
|
|
30
32
|
export declare function getTransactionReceipt(provider: EthereumProvider, txHash: string): Promise<EthereumTransactionReceipt | null>;
|
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAChE,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACvE,IAAI,CAAC,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpF,IAAI,CAAC,MAAM,EAAE,0BAA0B,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,mBAAmB,CAAC,CAAC;IAChG,IAAI,CAAC,MAAM,EAAE,2BAA2B,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,0BAA0B,CAAC,CAAC;IACxG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO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AE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAG3G;AAED,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAErC;AAED,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAAC,CAM5C;AAED,eAAO,MAAM,YAAY,EAAE;KAAG,OAAO,IAAI,MAAM,CAAC,CAAC,EAAE,MAAM;CAOvD,CAAC;AAEH,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CAWvF;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,0BAA0B,EAAE,QAAQ,CAAC,GAAG,OAAO,CAEhG"}
|
package/dist/provider.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isReceiptSuccessful = exports.isDevelopmentNetwork = exports.networkNames = exports.getTransactionReceipt = exports.getTransactionByHash = exports.hasCode = exports.getCode = exports.getStorageAt = exports.getClientVersion = exports.getChainId = exports.getNetworkId = void 0;
|
|
6
|
+
exports.isReceiptSuccessful = exports.isDevelopmentNetwork = exports.networkNames = exports.getTransactionReceipt = exports.getTransactionByHash = exports.hasCode = exports.call = exports.getCode = exports.getStorageAt = exports.getClientVersion = exports.getChainId = exports.getNetworkId = void 0;
|
|
7
7
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
8
8
|
async function getNetworkId(provider) {
|
|
9
9
|
return provider.send('net_version', []);
|
|
@@ -28,6 +28,16 @@ async function getCode(provider, address, block = 'latest') {
|
|
|
28
28
|
return provider.send('eth_getCode', [address, block]);
|
|
29
29
|
}
|
|
30
30
|
exports.getCode = getCode;
|
|
31
|
+
async function call(provider, address, data, block = 'latest') {
|
|
32
|
+
return provider.send('eth_call', [
|
|
33
|
+
{
|
|
34
|
+
to: address,
|
|
35
|
+
data: data,
|
|
36
|
+
},
|
|
37
|
+
block,
|
|
38
|
+
]);
|
|
39
|
+
}
|
|
40
|
+
exports.call = call;
|
|
31
41
|
async function hasCode(provider, address, block) {
|
|
32
42
|
const code = await getCode(provider, address, block);
|
|
33
43
|
return code !== '0x';
|
package/dist/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAuB;
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAuB;AA4BhB,KAAK,UAAU,YAAY,CAAC,QAA0B;IAC3D,OAAO,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AAC1C,CAAC;AAFD,oCAEC;AAEM,KAAK,UAAU,UAAU,CAAC,QAA0B;IACzD,MAAM,EAAE,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;IAClD,OAAO,IAAI,eAAE,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC;AACzD,CAAC;AAHD,gCAGC;AAEM,KAAK,UAAU,gBAAgB,CAAC,QAA0B;IAC/D,OAAO,QAAQ,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;AACjD,CAAC;AAFD,4CAEC;AAEM,KAAK,UAAU,YAAY,CAChC,QAA0B,EAC1B,OAAe,EACf,QAAgB,EAChB,KAAK,GAA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ions } from './validate';
|
|
3
|
+
import { ProxyDeployment } from './manifest';
|
|
4
|
+
import { Version } from './version';
|
|
5
|
+
export declare function setProxyKind(provider: EthereumProvider, proxyAddress: string, opts: ValidationOptions): Promise<ProxyDeployment['kind']>;
|
|
6
|
+
/**
|
|
7
|
+
* Processes opts.kind when deploying the implementation for a UUPS or Transparent proxy.
|
|
8
|
+
*
|
|
9
|
+
* @throws {BeaconProxyUnsupportedError} If this function is called for a Beacon proxy.
|
|
10
|
+
*/
|
|
11
|
+
export declare function processProxyKind(provider: EthereumProvider, proxyAddress: string | undefined, opts: ValidationOptions, data: ValidationData, version: Version): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=proxy-kind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy-kind.d.ts","sourceRoot":"","sources":["../src/proxy-kind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAkB,cAAc,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EAAgC,eAAe,EAAE,MAAM,YAAY,CAAC;AAE3E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,wBAAsB,YAAY,CAChC,QAAQ,EAAE,gBAAgB,EAC1B,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAkBlC;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,gBAAgB,EAC1B,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,IAAI,EAAE,iBAAiB,EACvB,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,OAAO,iBAiBjB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processProxyKind = exports.setProxyKind = void 0;
|
|
4
|
+
const validate_1 = require("./validate");
|
|
5
|
+
const manifest_1 = require("./manifest");
|
|
6
|
+
const eip_1967_type_1 = require("./eip-1967-type");
|
|
7
|
+
const usage_error_1 = require("./usage-error");
|
|
8
|
+
async function setProxyKind(provider, proxyAddress, opts) {
|
|
9
|
+
var _a;
|
|
10
|
+
const manifest = await manifest_1.Manifest.forNetwork(provider);
|
|
11
|
+
const manifestDeployment = await manifest.getProxyFromAddress(proxyAddress).catch(e => {
|
|
12
|
+
if (e instanceof manifest_1.DeploymentNotFound) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
throw e;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
if (opts.kind === undefined) {
|
|
20
|
+
opts.kind = (_a = manifestDeployment === null || manifestDeployment === void 0 ? void 0 : manifestDeployment.kind) !== null && _a !== void 0 ? _a : 'transparent';
|
|
21
|
+
}
|
|
22
|
+
else if (manifestDeployment && opts.kind !== manifestDeployment.kind) {
|
|
23
|
+
throw new Error(`Requested an upgrade of kind ${opts.kind} but proxy is ${manifestDeployment.kind}`);
|
|
24
|
+
}
|
|
25
|
+
return opts.kind;
|
|
26
|
+
}
|
|
27
|
+
exports.setProxyKind = setProxyKind;
|
|
28
|
+
/**
|
|
29
|
+
* Processes opts.kind when deploying the implementation for a UUPS or Transparent proxy.
|
|
30
|
+
*
|
|
31
|
+
* @throws {BeaconProxyUnsupportedError} If this function is called for a Beacon proxy.
|
|
32
|
+
*/
|
|
33
|
+
async function processProxyKind(provider, proxyAddress, opts, data, version) {
|
|
34
|
+
if (opts.kind === undefined) {
|
|
35
|
+
if (proxyAddress !== undefined && (await (0, eip_1967_type_1.isBeaconProxy)(provider, proxyAddress))) {
|
|
36
|
+
opts.kind = 'beacon';
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
opts.kind = (0, validate_1.inferProxyKind)(data, version);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (proxyAddress !== undefined) {
|
|
43
|
+
await setProxyKind(provider, proxyAddress, opts);
|
|
44
|
+
}
|
|
45
|
+
if (opts.kind === 'beacon') {
|
|
46
|
+
throw new usage_error_1.BeaconProxyUnsupportedError();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.processProxyKind = processProxyKind;
|
|
50
|
+
//# sourceMappingURL=proxy-kind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy-kind.js","sourceRoot":"","sources":["../src/proxy-kind.ts"],"names":[],"mappings":";;;AACA,yCAA+E;AAC/E,yCAA2E;AAC3E,mDAAgD;AAEhD,+CAA4D;AAErD,KAAK,UAAU,YAAY,CAChC,QAA0B,EAC1B,YAAoB,EACpB,IAAuB;;IAEvB,MAAM,QAAQ,GAAG,MAAM,mBAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAErD,MAAM,kBAAkB,GAAG,MAAM,QAAQ,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;QACpF,IAAI,CAAC,YAAY,6BAAkB,EAAE;YACnC,OAAO,SAAS,CAAC;SAClB;aAAM;YACL,MAAM,CAAC,CAAC;SACT;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;QAC3B,IAAI,CAAC,IAAI,GAAG,MAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,IAAI,mCAAI,aAAa,CAAC;KACvD;SAAM,IAAI,kBAAkB,IAAI,IAAI,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,EAAE;QACtE,MAAM,IAAI,KAAK,CAAC,gCAAgC,IAAI,CAAC,IAAI,iBAAiB,kBAAkB,CAAC,IAAI,EAAE,CAAC,CAAC;KACtG;IAED,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC;AAtBD,oCAsBC;AAED;;;;GAIG;AACI,KAAK,UAAU,gBAAgB,CACpC,QAA0B,EAC1B,YAAgC,EAChC,IAAuB,EACvB,IAAoB,EACpB,OAAgB;IAEhB,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;QAC3B,IAAI,YAAY,KAAK,SAAS,IAAI,CAAC,MAAM,IAAA,6BAAa,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,EAAE;YAC/E,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;SACtB;aAAM;YACL,IAAI,CAAC,IAAI,GAAG,IAAA,yBAAc,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;SAC3C;KACF;IAED,IAAI,YAAY,KAAK,SAAS,EAAE;QAC9B,MAAM,YAAY,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;KAClD;IAED,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE;QAC1B,MAAM,IAAI,yCAA2B,EAAE,CAAC;KACzC;AACH,CAAC;AAtBD,4CAsBC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { EthereumProvider, UpgradesError } from '.';
|
|
2
|
+
export declare class BeaconProxyUnsupportedError extends UpgradesError {
|
|
3
|
+
constructor();
|
|
4
|
+
}
|
|
5
|
+
export declare class DeployBeaconProxyKindError extends UpgradesError {
|
|
6
|
+
constructor(kind: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class DeployBeaconProxyUnsupportedError extends UpgradesError {
|
|
9
|
+
constructor(beaconAddress: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class DeployBeaconProxyImplUnknownError extends UpgradesError {
|
|
12
|
+
constructor(implAddress: string);
|
|
13
|
+
}
|
|
14
|
+
export declare class LoadProxyUnsupportedError extends UpgradesError {
|
|
15
|
+
constructor(proxyAddress: string);
|
|
16
|
+
}
|
|
17
|
+
export declare class PrepareUpgradeUnsupportedError extends UpgradesError {
|
|
18
|
+
constructor(proxyOrBeaconAddress: string);
|
|
19
|
+
}
|
|
20
|
+
export declare function assertNotProxy(provider: EthereumProvider, address: string): Promise<void>;
|
|
21
|
+
//# sourceMappingURL=usage-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage-error.d.ts","sourceRoot":"","sources":["../src/usage-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA6D,aAAa,EAAE,MAAM,GAAG,CAAC;AAE/G,qBAAa,2BAA4B,SAAQ,aAAa;;CAO7D;AAED,qBAAa,0BAA2B,SAAQ,aAAa;gBAC/C,IAAI,EAAE,MAAM;CAMzB;AAED,qBAAa,iCAAkC,SAAQ,aAAa;gBACtD,aAAa,EAAE,MAAM;CAGlC;AAED,qBAAa,iCAAkC,SAAQ,aAAa;gBACtD,WAAW,EAAE,MAAM;CAMhC;AAED,qBAAa,yBAA0B,SAAQ,aAAa;gBAC9C,YAAY,EAAE,MAAM;CAMjC;AAED,qBAAa,8BAA+B,SAAQ,aAAa;gBACnD,oBAAoB,EAAE,MAAM;CAMzC;AAED,wBAAsB,cAAc,CAAC,QAAQ,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,iBAc/E"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertNotProxy = exports.PrepareUpgradeUnsupportedError = exports.LoadProxyUnsupportedError = exports.DeployBeaconProxyImplUnknownError = exports.DeployBeaconProxyUnsupportedError = exports.DeployBeaconProxyKindError = exports.BeaconProxyUnsupportedError = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
class BeaconProxyUnsupportedError extends _1.UpgradesError {
|
|
6
|
+
constructor() {
|
|
7
|
+
super('Beacon proxies are not supported with the current function.', () => 'Use deployBeacon(), deployBeaconProxy(), or upgradeBeacon() instead.');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.BeaconProxyUnsupportedError = BeaconProxyUnsupportedError;
|
|
11
|
+
class DeployBeaconProxyKindError extends _1.UpgradesError {
|
|
12
|
+
constructor(kind) {
|
|
13
|
+
super(`Unsupported proxy kind '${kind}'`, () => `deployBeaconProxy() is only supported with proxy kind undefined or 'beacon'`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.DeployBeaconProxyKindError = DeployBeaconProxyKindError;
|
|
17
|
+
class DeployBeaconProxyUnsupportedError extends _1.UpgradesError {
|
|
18
|
+
constructor(beaconAddress) {
|
|
19
|
+
super(`Contract at ${beaconAddress} doesn't look like a beacon`, () => 'Deploy a beacon using deployBeacon().');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.DeployBeaconProxyUnsupportedError = DeployBeaconProxyUnsupportedError;
|
|
23
|
+
class DeployBeaconProxyImplUnknownError extends _1.UpgradesError {
|
|
24
|
+
constructor(implAddress) {
|
|
25
|
+
super(`Beacon's current implementation at ${implAddress} is unknown`, () => `Call deployBeaconProxy() with the implementation option providing the beacon's current implementation.`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.DeployBeaconProxyImplUnknownError = DeployBeaconProxyImplUnknownError;
|
|
29
|
+
class LoadProxyUnsupportedError extends _1.UpgradesError {
|
|
30
|
+
constructor(proxyAddress) {
|
|
31
|
+
super(`Contract at ${proxyAddress} doesn't look like a supported proxy`, () => 'Only transparent, UUPS, or beacon proxies can be loaded with the loadProxy() function.');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.LoadProxyUnsupportedError = LoadProxyUnsupportedError;
|
|
35
|
+
class PrepareUpgradeUnsupportedError extends _1.UpgradesError {
|
|
36
|
+
constructor(proxyOrBeaconAddress) {
|
|
37
|
+
super(`Contract at address ${proxyOrBeaconAddress} doesn't look like a supported proxy or beacon`, () => `Only transparent, UUPS, or beacon proxies or beacons can be used with the prepareUpgrade() function.`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.PrepareUpgradeUnsupportedError = PrepareUpgradeUnsupportedError;
|
|
41
|
+
async function assertNotProxy(provider, address) {
|
|
42
|
+
if (await (0, _1.isTransparentOrUUPSProxy)(provider, address)) {
|
|
43
|
+
throw new _1.UpgradesError('Address is a transparent or UUPS proxy which cannot be upgraded using upgradeBeacon().', () => 'Use upgradeProxy() instead.');
|
|
44
|
+
}
|
|
45
|
+
else if (await (0, _1.isBeaconProxy)(provider, address)) {
|
|
46
|
+
const beaconAddress = await (0, _1.getBeaconAddress)(provider, address);
|
|
47
|
+
throw new _1.UpgradesError('Address is a beacon proxy which cannot be upgraded directly.', () => `upgradeBeacon() must be called with a beacon address, not a beacon proxy address. Call upgradeBeacon() on the beacon address ${beaconAddress} instead.`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.assertNotProxy = assertNotProxy;
|
|
51
|
+
//# sourceMappingURL=usage-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage-error.js","sourceRoot":"","sources":["../src/usage-error.ts"],"names":[],"mappings":";;;AAAA,wBAA+G;AAE/G,MAAa,2BAA4B,SAAQ,gBAAa;IAC5D;QACE,KAAK,CACH,6DAA6D,EAC7D,GAAG,EAAE,CAAC,sEAAsE,CAC7E,CAAC;IACJ,CAAC;CACF;AAPD,kEAOC;AAED,MAAa,0BAA2B,SAAQ,gBAAa;IAC3D,YAAY,IAAY;QACtB,KAAK,CACH,2BAA2B,IAAI,GAAG,EAClC,GAAG,EAAE,CAAC,6EAA6E,CACpF,CAAC;IACJ,CAAC;CACF;AAPD,gEAOC;AAED,MAAa,iCAAkC,SAAQ,gBAAa;IAClE,YAAY,aAAqB;QAC/B,KAAK,CAAC,eAAe,aAAa,6BAA6B,EAAE,GAAG,EAAE,CAAC,uCAAuC,CAAC,CAAC;IAClH,CAAC;CACF;AAJD,8EAIC;AAED,MAAa,iCAAkC,SAAQ,gBAAa;IAClE,YAAY,WAAmB;QAC7B,KAAK,CACH,sCAAsC,WAAW,aAAa,EAC9D,GAAG,EAAE,CAAC,wGAAwG,CAC/G,CAAC;IACJ,CAAC;CACF;AAPD,8EAOC;AAED,MAAa,yBAA0B,SAAQ,gBAAa;IAC1D,YAAY,YAAoB;QAC9B,KAAK,CACH,eAAe,YAAY,sCAAsC,EACjE,GAAG,EAAE,CAAC,wFAAwF,CAC/F,CAAC;IACJ,CAAC;CACF;AAPD,8DAOC;AAED,MAAa,8BAA+B,SAAQ,gBAAa;IAC/D,YAAY,oBAA4B;QACtC,KAAK,CACH,uBAAuB,oBAAoB,gDAAgD,EAC3F,GAAG,EAAE,CAAC,sGAAsG,CAC7G,CAAC;IACJ,CAAC;CACF;AAPD,wEAOC;AAEM,KAAK,UAAU,cAAc,CAAC,QAA0B,EAAE,OAAe;IAC9E,IAAI,MAAM,IAAA,2BAAwB,EAAC,QAAQ,EAAE,OAAO,CAAC,EAAE;QACrD,MAAM,IAAI,gBAAa,CACrB,wFAAwF,EACxF,GAAG,EAAE,CAAC,6BAA6B,CACpC,CAAC;KACH;SAAM,IAAI,MAAM,IAAA,gBAAa,EAAC,QAAQ,EAAE,OAAO,CAAC,EAAE;QACjD,MAAM,aAAa,GAAG,MAAM,IAAA,mBAAgB,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAChE,MAAM,IAAI,gBAAa,CACrB,8DAA8D,EAC9D,GAAG,EAAE,CACH,gIAAgI,aAAa,WAAW,CAC3J,CAAC;KACH;AACH,CAAC;AAdD,wCAcC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses an address from a hex string which may come from storage or a returned address via eth_call.
|
|
3
|
+
*
|
|
4
|
+
* @param addressString The address hex string.
|
|
5
|
+
* @returns The parsed checksum address, or undefined if the input string is not an address.
|
|
6
|
+
*/
|
|
7
|
+
export declare function parseAddress(addressString: string): string | undefined;
|
|
8
|
+
//# sourceMappingURL=address.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/utils/address.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOtE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseAddress = void 0;
|
|
4
|
+
const ethereumjs_util_1 = require("ethereumjs-util");
|
|
5
|
+
/**
|
|
6
|
+
* Parses an address from a hex string which may come from storage or a returned address via eth_call.
|
|
7
|
+
*
|
|
8
|
+
* @param addressString The address hex string.
|
|
9
|
+
* @returns The parsed checksum address, or undefined if the input string is not an address.
|
|
10
|
+
*/
|
|
11
|
+
function parseAddress(addressString) {
|
|
12
|
+
const buf = Buffer.from(addressString.replace(/^0x/, ''), 'hex');
|
|
13
|
+
if (!buf.slice(0, 12).equals(Buffer.alloc(12, 0))) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
const address = '0x' + buf.toString('hex', 12, 32); // grab the last 20 bytes
|
|
17
|
+
return (0, ethereumjs_util_1.toChecksumAddress)(address);
|
|
18
|
+
}
|
|
19
|
+
exports.parseAddress = parseAddress;
|
|
20
|
+
//# sourceMappingURL=address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../src/utils/address.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AAEpD;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,aAAqB;IAChD,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IACjE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE;QACjD,OAAO,SAAS,CAAC;KAClB;IACD,MAAM,OAAO,GAAG,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,yBAAyB;IAC7E,OAAO,IAAA,mCAAiB,EAAC,OAAO,CAAC,CAAC;AACpC,CAAC;AAPD,oCAOC"}
|
|
@@ -50,7 +50,7 @@ function withValidationDefaults(opts) {
|
|
|
50
50
|
exports.withValidationDefaults = withValidationDefaults;
|
|
51
51
|
function processExceptions(contractName, errors, opts) {
|
|
52
52
|
const { unsafeAllow } = withValidationDefaults(opts);
|
|
53
|
-
if (opts.kind === 'transparent') {
|
|
53
|
+
if (opts.kind === 'transparent' || opts.kind === 'beacon') {
|
|
54
54
|
errors = errors.filter(error => error.kind !== 'missing-public-upgradeto');
|
|
55
55
|
}
|
|
56
56
|
for (const [errorType, errorDescription] of Object.entries(exports.ValidationErrorUnsafeMessages)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overrides.js","sourceRoot":"","sources":["../../src/validate/overrides.ts"],"names":[],"mappings":";;;AAEA,sCAA0C;AAE1C,0BAA0B;AAC1B,oCAA+C;AAAtC,sGAAA,eAAe,OAAA;AAUX,QAAA,6BAA6B,GAA8C;IACtF,2BAA2B,EAAE;QAC3B,mEAAmE;QACnE,mEAAmE;KACpE;IACD,0BAA0B,EAAE,CAAC,kEAAkE,CAAC;IAChG,0BAA0B,EAAE;QAC1B,gGAAgG;QAChG,iFAAiF;KAClF;IACD,mBAAmB,EAAE;QACnB,8FAA8F;QAC9F,+EAA+E;KAChF;IACD,iBAAiB,EAAE;QACjB,0FAA0F;QAC1F,+EAA+E;KAChF;IACD,WAAW,EAAE,CAAC,qDAAqD,CAAC;IACpE,YAAY,EAAE,CAAC,sDAAsD,CAAC;IACtE,YAAY,EAAE,CAAC,sDAAsD,CAAC;IACtE,0BAA0B,EAAE;QAC1B,kFAAkF;QAClF,yFAAyF;QACzF,gFAAgF;KACjF;CACF,CAAC;AAEF,SAAgB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B,iBAAiB,CAC/B,YAAoB,EACpB,MAAyB,EACzB,IAAuB;IAEvB,MAAM,EAAE,WAAW,EAAE,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAErD,IAAI,IAAI,CAAC,IAAI,KAAK,aAAa,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE;QACzD,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,0BAA0B,CAAC,CAAC;KAC5E;IAED,KAAK,MAAM,CAAC,SAAS,EAAE,gBAAgB,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,qCAA6B,CAAC,EAAE;QACzF,IAAI,WAAW,CAAC,QAAQ,CAAC,SAAoC,CAAC,EAAE;YAC9D,IAAI,eAAe,GAAG,KAAK,CAAC;YAE5B,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;gBAC7B,MAAM,WAAW,GAAG,SAAS,KAAK,KAAK,CAAC,IAAI,CAAC;gBAC7C,eAAe,GAAG,eAAe,IAAI,WAAW,CAAC;gBACjD,OAAO,CAAC,WAAW,CAAC;YACtB,CAAC,CAAC,CAAC;YAEH,IAAI,eAAe,IAAI,gBAAgB,EAAE;gBACvC,IAAA,gBAAU,EAAC,oCAAoC,YAAY,EAAE,EAAE,gBAAgB,CAAC,CAAC;aAClF;SACF;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AA5BD,8CA4BC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openzeppelin/upgrades-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": "https://github.com/OpenZeppelin/openzeppelin-upgrades/tree/master/packages/core",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
"/artifacts/contracts/proxy/AdminUpgradeabilityProxy.sol/AdminUpgradeabilityProxy.json",
|
|
14
14
|
"/artifacts/contracts/proxy/ProxyAdmin.sol/ProxyAdmin.json",
|
|
15
15
|
"/contracts/Initializable.sol",
|
|
16
|
+
"/artifacts/@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol",
|
|
17
|
+
"/artifacts/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol",
|
|
16
18
|
"/artifacts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol",
|
|
17
19
|
"/artifacts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json ",
|
|
18
20
|
"/artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json"
|
|
@@ -51,10 +53,11 @@
|
|
|
51
53
|
"bn.js": "^5.1.2",
|
|
52
54
|
"cbor": "^8.0.0",
|
|
53
55
|
"chalk": "^4.1.0",
|
|
54
|
-
"compare-versions": "^
|
|
56
|
+
"compare-versions": "^4.0.0",
|
|
55
57
|
"debug": "^4.1.1",
|
|
56
58
|
"ethereumjs-util": "^7.0.3",
|
|
57
59
|
"proper-lockfile": "^4.1.1",
|
|
58
60
|
"solidity-ast": "^0.4.15"
|
|
59
|
-
}
|
|
61
|
+
},
|
|
62
|
+
"gitHead": "a32bd11a82ede9136d18de4cf0a1d18f44127103"
|
|
60
63
|
}
|
package/src/beacon.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { InvalidBeacon, getImplementationAddressFromBeacon } from './impl-address';
|
|
2
|
+
import { EthereumProvider } from './provider';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Checks if the address looks like a beacon.
|
|
6
|
+
*
|
|
7
|
+
* @returns true if the address has an implementation() function that returns an address, false otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export async function isBeacon(provider: EthereumProvider, beaconAddress: string): Promise<boolean> {
|
|
10
|
+
try {
|
|
11
|
+
await getImplementationAddressFromBeacon(provider, beaconAddress);
|
|
12
|
+
return true;
|
|
13
|
+
} catch (e: any) {
|
|
14
|
+
if (e instanceof InvalidBeacon) {
|
|
15
|
+
return false;
|
|
16
|
+
} else {
|
|
17
|
+
throw e;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EIP1967BeaconNotFound,
|
|
3
|
+
EIP1967ImplementationNotFound,
|
|
4
|
+
getBeaconAddress,
|
|
5
|
+
getImplementationAddress,
|
|
6
|
+
} from './eip-1967';
|
|
7
|
+
import { EthereumProvider } from './provider';
|
|
8
|
+
|
|
9
|
+
export async function isTransparentOrUUPSProxy(provider: EthereumProvider, address: string): Promise<boolean> {
|
|
10
|
+
try {
|
|
11
|
+
await getImplementationAddress(provider, address);
|
|
12
|
+
// if an exception was not encountered above, then this address is a transparent/uups proxy
|
|
13
|
+
return true;
|
|
14
|
+
} catch (e: any) {
|
|
15
|
+
if (e instanceof EIP1967ImplementationNotFound) {
|
|
16
|
+
return false;
|
|
17
|
+
} else {
|
|
18
|
+
throw e;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function isBeaconProxy(provider: EthereumProvider, address: string): Promise<boolean> {
|
|
24
|
+
try {
|
|
25
|
+
await getBeaconAddress(provider, address);
|
|
26
|
+
// if an exception was not encountered above, then this address is a beacon proxy
|
|
27
|
+
return true;
|
|
28
|
+
} catch (e: any) {
|
|
29
|
+
if (e instanceof EIP1967BeaconNotFound) {
|
|
30
|
+
return false;
|
|
31
|
+
} else {
|
|
32
|
+
throw e;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/eip-1967.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { toChecksumAddress, keccak256 } from 'ethereumjs-util';
|
|
2
1
|
import BN from 'bn.js';
|
|
3
|
-
|
|
2
|
+
import { keccak256 } from 'ethereumjs-util';
|
|
3
|
+
import { UpgradesError } from './error';
|
|
4
4
|
import { EthereumProvider, getStorageAt } from './provider';
|
|
5
|
+
import { parseAddress } from './utils/address';
|
|
6
|
+
|
|
7
|
+
export class EIP1967ImplementationNotFound extends UpgradesError {}
|
|
8
|
+
|
|
9
|
+
export class EIP1967BeaconNotFound extends UpgradesError {}
|
|
5
10
|
|
|
6
11
|
export async function getAdminAddress(provider: EthereumProvider, address: string): Promise<string> {
|
|
7
12
|
const storage = await getStorageFallback(
|
|
@@ -11,7 +16,7 @@ export async function getAdminAddress(provider: EthereumProvider, address: strin
|
|
|
11
16
|
toFallbackEip1967Hash('org.zeppelinos.proxy.admin'),
|
|
12
17
|
);
|
|
13
18
|
|
|
14
|
-
return
|
|
19
|
+
return parseAddressFromStorage(storage);
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
export async function getImplementationAddress(provider: EthereumProvider, address: string): Promise<string> {
|
|
@@ -23,20 +28,20 @@ export async function getImplementationAddress(provider: EthereumProvider, addre
|
|
|
23
28
|
);
|
|
24
29
|
|
|
25
30
|
if (isEmptySlot(storage)) {
|
|
26
|
-
throw new
|
|
31
|
+
throw new EIP1967ImplementationNotFound(`Contract at ${address} doesn't look like an administered ERC 1967 proxy`);
|
|
27
32
|
}
|
|
28
33
|
|
|
29
|
-
return
|
|
34
|
+
return parseAddressFromStorage(storage);
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
export async function getBeaconAddress(provider: EthereumProvider, address: string): Promise<string> {
|
|
33
38
|
const storage = await getStorageFallback(provider, address, toEip1967Hash('eip1967.proxy.beacon'));
|
|
34
39
|
|
|
35
40
|
if (isEmptySlot(storage)) {
|
|
36
|
-
throw new
|
|
41
|
+
throw new EIP1967BeaconNotFound(`Contract at ${address} doesn't look like an ERC 1967 beacon proxy`);
|
|
37
42
|
}
|
|
38
43
|
|
|
39
|
-
return
|
|
44
|
+
return parseAddressFromStorage(storage);
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
async function getStorageFallback(provider: EthereumProvider, address: string, ...slots: string[]): Promise<string> {
|
|
@@ -67,11 +72,10 @@ function isEmptySlot(storage: string): boolean {
|
|
|
67
72
|
return new BN(storage, 'hex').isZero();
|
|
68
73
|
}
|
|
69
74
|
|
|
70
|
-
function
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
75
|
+
function parseAddressFromStorage(storage: string): string {
|
|
76
|
+
const address = parseAddress(storage);
|
|
77
|
+
if (address === undefined) {
|
|
73
78
|
throw new Error(`Value in storage is not an address (${storage})`);
|
|
74
79
|
}
|
|
75
|
-
|
|
76
|
-
return toChecksumAddress(address);
|
|
80
|
+
return address;
|
|
77
81
|
}
|