@openzeppelin/upgrades-core 1.11.1 → 1.12.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/dist/deployment.d.ts +14 -3
- package/dist/deployment.d.ts.map +1 -1
- package/dist/deployment.js +20 -13
- package/dist/deployment.js.map +1 -1
- package/dist/deployment.test.js +23 -0
- package/dist/deployment.test.js.map +1 -1
- package/dist/impl-store.d.ts +3 -2
- package/dist/impl-store.d.ts.map +1 -1
- package/dist/impl-store.js +21 -10
- package/dist/impl-store.js.map +1 -1
- package/package.json +2 -2
- package/src/deployment.test.ts +25 -0
- package/src/deployment.ts +43 -13
- package/src/impl-store.ts +23 -7
package/dist/deployment.d.ts
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import { EthereumProvider } from './provider';
|
|
2
|
+
import { UpgradesError } from './error';
|
|
2
3
|
export interface Deployment {
|
|
3
4
|
address: string;
|
|
4
5
|
txHash?: string;
|
|
5
6
|
}
|
|
7
|
+
export interface DeployOpts {
|
|
8
|
+
/**
|
|
9
|
+
* Timeout in milliseconds to wait for the transaction confirmation when deploying an implementation contract or proxy admin contract. Use `0` to wait indefinitely.
|
|
10
|
+
*/
|
|
11
|
+
timeout?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Polling interval in milliseconds between checks for the transaction confirmation when deploying an implementation contract or proxy admin contract.
|
|
14
|
+
*/
|
|
15
|
+
pollingInterval?: number;
|
|
16
|
+
}
|
|
6
17
|
export declare function resumeOrDeploy<T extends Deployment>(provider: EthereumProvider, cached: T | undefined, deploy: () => Promise<T>): Promise<T>;
|
|
7
|
-
export declare function waitAndValidateDeployment(provider: EthereumProvider, deployment: Deployment): Promise<void>;
|
|
8
|
-
export declare class TransactionMinedTimeout extends
|
|
18
|
+
export declare function waitAndValidateDeployment(provider: EthereumProvider, deployment: Deployment, type?: string, opts?: DeployOpts): Promise<void>;
|
|
19
|
+
export declare class TransactionMinedTimeout extends UpgradesError {
|
|
9
20
|
readonly deployment: Deployment;
|
|
10
|
-
constructor(deployment: Deployment);
|
|
21
|
+
constructor(deployment: Deployment, type?: string, configurableTimeout?: boolean);
|
|
11
22
|
}
|
|
12
23
|
export declare class InvalidDeployment extends Error {
|
|
13
24
|
readonly deployment: Deployment;
|
package/dist/deployment.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deployment.d.ts","sourceRoot":"","sources":["../src/deployment.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,gBAAgB,EAMjB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"deployment.d.ts","sourceRoot":"","sources":["../src/deployment.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,gBAAgB,EAMjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxC,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAsB,cAAc,CAAC,CAAC,SAAS,UAAU,EACvD,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,CAAC,GAAG,SAAS,EACrB,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACvB,OAAO,CAAC,CAAC,CAAC,CA2BZ;AAED,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,UAAU,EACtB,IAAI,CAAC,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,UAAU,GAChB,OAAO,CAAC,IAAI,CAAC,CA8Cf;AAED,qBAAa,uBAAwB,SAAQ,aAAa;IAC5C,QAAQ,CAAC,UAAU,EAAE,UAAU;gBAAtB,UAAU,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,mBAAmB,CAAC,EAAE,OAAO;CAY1F;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAG9B,QAAQ,CAAC,UAAU,EAAE,UAAU;IAF3C,OAAO,UAAS;gBAEK,UAAU,EAAE,UAAU;IAO3C,IAAI,OAAO,IAAI,MAAM,CAMpB;CACF"}
|
package/dist/deployment.js
CHANGED
|
@@ -8,6 +8,7 @@ const util_1 = require("util");
|
|
|
8
8
|
const debug_1 = __importDefault(require("./utils/debug"));
|
|
9
9
|
const make_non_enumerable_1 = require("./utils/make-non-enumerable");
|
|
10
10
|
const provider_1 = require("./provider");
|
|
11
|
+
const error_1 = require("./error");
|
|
11
12
|
const sleep = (0, util_1.promisify)(setTimeout);
|
|
12
13
|
async function resumeOrDeploy(provider, cached, deploy) {
|
|
13
14
|
if (cached !== undefined) {
|
|
@@ -39,21 +40,17 @@ async function resumeOrDeploy(provider, cached, deploy) {
|
|
|
39
40
|
return deployment;
|
|
40
41
|
}
|
|
41
42
|
exports.resumeOrDeploy = resumeOrDeploy;
|
|
42
|
-
async function waitAndValidateDeployment(provider, deployment) {
|
|
43
|
+
async function waitAndValidateDeployment(provider, deployment, type, opts) {
|
|
44
|
+
var _a, _b;
|
|
43
45
|
const { txHash, address } = deployment;
|
|
44
|
-
// Poll for 60 seconds with a 5 second poll interval.
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
46
|
+
// Poll for 60 seconds with a 5 second poll interval by default.
|
|
47
|
+
const pollTimeout = (_a = opts === null || opts === void 0 ? void 0 : opts.timeout) !== null && _a !== void 0 ? _a : 60e3;
|
|
48
|
+
const pollInterval = (_b = opts === null || opts === void 0 ? void 0 : opts.pollingInterval) !== null && _b !== void 0 ? _b : 5e3;
|
|
49
|
+
(0, debug_1.default)('polling timeout', pollTimeout, 'polling interval', pollInterval);
|
|
48
50
|
if (txHash !== undefined) {
|
|
49
51
|
const startTime = Date.now();
|
|
50
52
|
// eslint-disable-next-line no-constant-condition
|
|
51
53
|
while (true) {
|
|
52
|
-
const elapsedTime = Date.now() - startTime;
|
|
53
|
-
if (elapsedTime >= pollTimeout) {
|
|
54
|
-
// A timeout is NOT an InvalidDeployment
|
|
55
|
-
throw new TransactionMinedTimeout(deployment);
|
|
56
|
-
}
|
|
57
54
|
(0, debug_1.default)('verifying deployment tx mined', txHash);
|
|
58
55
|
const receipt = await (0, provider_1.getTransactionReceipt)(provider, txHash);
|
|
59
56
|
if (receipt && (0, provider_1.isReceiptSuccessful)(receipt)) {
|
|
@@ -68,6 +65,13 @@ async function waitAndValidateDeployment(provider, deployment) {
|
|
|
68
65
|
(0, debug_1.default)('waiting for deployment tx mined', txHash);
|
|
69
66
|
await sleep(pollInterval);
|
|
70
67
|
}
|
|
68
|
+
if (pollTimeout != 0) {
|
|
69
|
+
const elapsedTime = Date.now() - startTime;
|
|
70
|
+
if (elapsedTime >= pollTimeout) {
|
|
71
|
+
// A timeout is NOT an InvalidDeployment
|
|
72
|
+
throw new TransactionMinedTimeout(deployment, type, !!opts);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
77
|
(0, debug_1.default)('verifying code in target address', address);
|
|
@@ -82,9 +86,12 @@ async function waitAndValidateDeployment(provider, deployment) {
|
|
|
82
86
|
(0, debug_1.default)('code in target address found', address);
|
|
83
87
|
}
|
|
84
88
|
exports.waitAndValidateDeployment = waitAndValidateDeployment;
|
|
85
|
-
class TransactionMinedTimeout extends
|
|
86
|
-
constructor(deployment) {
|
|
87
|
-
super(`Timed out waiting for transaction ${deployment.txHash}
|
|
89
|
+
class TransactionMinedTimeout extends error_1.UpgradesError {
|
|
90
|
+
constructor(deployment, type, configurableTimeout) {
|
|
91
|
+
super(`Timed out waiting for ${type ? type + ' ' : ''}contract deployment to address ${deployment.address} with transaction ${deployment.txHash}`, () => 'Run the function again to continue waiting for the transaction confirmation.' +
|
|
92
|
+
(configurableTimeout
|
|
93
|
+
? ' If the problem persists, adjust the polling parameters with the timeout and pollingInterval options.'
|
|
94
|
+
: ''));
|
|
88
95
|
this.deployment = deployment;
|
|
89
96
|
}
|
|
90
97
|
}
|
package/dist/deployment.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deployment.js","sourceRoot":"","sources":["../src/deployment.ts"],"names":[],"mappings":";;;;;;AAAA,+BAAiC;AAEjC,0DAAkC;AAClC,qEAAgE;AAChE,yCAOoB;
|
|
1
|
+
{"version":3,"file":"deployment.js","sourceRoot":"","sources":["../src/deployment.ts"],"names":[],"mappings":";;;;;;AAAA,+BAAiC;AAEjC,0DAAkC;AAClC,qEAAgE;AAChE,yCAOoB;AACpB,mCAAwC;AAExC,MAAM,KAAK,GAAG,IAAA,gBAAS,EAAC,UAAU,CAAC,CAAC;AAmB7B,KAAK,UAAU,cAAc,CAClC,QAA0B,EAC1B,MAAqB,EACrB,MAAwB;IAExB,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;QAC1B,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,uCAAuC;YACvC,mEAAmE;YACnE,OAAO,MAAM,CAAC;SACf;QACD,kFAAkF;QAClF,kDAAkD;QAClD,IAAA,eAAK,EAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC;QAC3C,MAAM,EAAE,GAAG,MAAM,IAAA,+BAAoB,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACxD,IAAI,EAAE,KAAK,IAAI,EAAE;YACf,IAAA,eAAK,EAAC,8BAA8B,EAAE,MAAM,CAAC,CAAC;YAC9C,OAAO,MAAM,CAAC;SACf;aAAM,IAAI,CAAC,CAAC,MAAM,IAAA,+BAAoB,EAAC,QAAQ,CAAC,CAAC,EAAE;YAClD,wEAAwE;YACxE,0DAA0D;YAC1D,MAAM,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;SACrC;aAAM;YACL,IAAA,eAAK,EAAC,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,CAAY;IAW3C,CAAC;CACF;AAbD,0DAaC;AAED,MAAa,iBAAkB,SAAQ,KAAK;IAG1C,YAAqB,UAAsB;QACzC,KAAK,EAAE,CAAC;QADW,eAAU,GAAV,UAAU,CAAY;QAF3C,YAAO,GAAG,KAAK,CAAC;QAId,8DAA8D;QAC9D,IAAA,uCAAiB,EAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACnC,IAAA,uCAAiB,EAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,OAAO;QACT,IAAI,GAAG,GAAG,0BAA0B,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC9D,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,GAAG,IAAI,0BAA0B,CAAC;SACnC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAjBD,8CAiBC"}
|
package/dist/deployment.test.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const ava_1 = __importDefault(require("ava"));
|
|
7
7
|
const util_1 = require("util");
|
|
8
|
+
const _1 = require(".");
|
|
8
9
|
const deployment_1 = require("./deployment");
|
|
9
10
|
const stub_provider_1 = require("./stub-provider");
|
|
10
11
|
const sleep = (0, util_1.promisify)(setTimeout);
|
|
@@ -89,4 +90,26 @@ const sleep = (0, util_1.promisify)(setTimeout);
|
|
|
89
90
|
provider.addContract(deployment.address);
|
|
90
91
|
await (0, deployment_1.waitAndValidateDeployment)(provider, deployment);
|
|
91
92
|
});
|
|
93
|
+
(0, ava_1.default)('tx mined timeout - no params', async (t) => {
|
|
94
|
+
const provider = (0, stub_provider_1.stubProvider)();
|
|
95
|
+
const deployment = await (0, deployment_1.resumeOrDeploy)(provider, undefined, provider.deploy);
|
|
96
|
+
try {
|
|
97
|
+
throw new _1.TransactionMinedTimeout(deployment);
|
|
98
|
+
}
|
|
99
|
+
catch (e) {
|
|
100
|
+
const EXPECTED = /Timed out waiting for contract deployment to address \S+ with transaction \S+\n\nRun the function again to continue waiting for the transaction confirmation./;
|
|
101
|
+
t.true(EXPECTED.test(e.message), e.message);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
(0, ava_1.default)('tx mined timeout - params', async (t) => {
|
|
105
|
+
const provider = (0, stub_provider_1.stubProvider)();
|
|
106
|
+
const deployment = await (0, deployment_1.resumeOrDeploy)(provider, undefined, provider.deploy);
|
|
107
|
+
try {
|
|
108
|
+
throw new _1.TransactionMinedTimeout(deployment, 'implementation', true);
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
const EXPECTED = /Timed out waiting for implementation contract deployment to address \S+ with transaction \S+\n\nRun the function again to continue waiting for the transaction confirmation. If the problem persists, adjust the polling parameters with the timeout and pollingInterval options./;
|
|
112
|
+
t.true(EXPECTED.test(e.message), e.message);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
92
115
|
//# sourceMappingURL=deployment.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deployment.test.js","sourceRoot":"","sources":["../src/deployment.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAuB;AACvB,+BAAiC;
|
|
1
|
+
{"version":3,"file":"deployment.test.js","sourceRoot":"","sources":["../src/deployment.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAuB;AACvB,+BAAiC;AACjC,wBAA4C;AAE5C,6CAAqF;AACrF,mDAA+C;AAE/C,MAAM,KAAK,GAAG,IAAA,gBAAS,EAAC,UAAU,CAAC,CAAC;AAEpC,IAAA,aAAI,EAAC,sBAAsB,EAAE,KAAK,EAAC,CAAC,EAAC,EAAE;IACrC,MAAM,QAAQ,GAAG,IAAA,4BAAY,GAAE,CAAC;IAChC,MAAM,UAAU,GAAG,MAAM,IAAA,2BAAc,EAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9E,CAAC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AAEH,IAAA,aAAI,EAAC,8BAA8B,EAAE,KAAK,EAAC,CAAC,EAAC,EAAE;IAC7C,MAAM,QAAQ,GAAG,IAAA,4BAAY,GAAE,CAAC;IAChC,MAAM,UAAU,GAAG,MAAM,IAAA,2BAAc,EAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9E,IAAI;QACF,MAAM,IAAI,0BAAuB,CAAC,UAAU,CAAC,CAAC;KAC/C;IAAC,OAAO,CAAM,EAAE;QACf,MAAM,QAAQ,GACZ,+JAA+J,CAAC;QAClK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;KAC7C;AACH,CAAC,CAAC,CAAC;AAEH,IAAA,aAAI,EAAC,2BAA2B,EAAE,KAAK,EAAC,CAAC,EAAC,EAAE;IAC1C,MAAM,QAAQ,GAAG,IAAA,4BAAY,GAAE,CAAC;IAChC,MAAM,UAAU,GAAG,MAAM,IAAA,2BAAc,EAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9E,IAAI;QACF,MAAM,IAAI,0BAAuB,CAAC,UAAU,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC;KACvE;IAAC,OAAO,CAAM,EAAE;QACf,MAAM,QAAQ,GACZ,mRAAmR,CAAC;QACtR,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;KAC7C;AACH,CAAC,CAAC,CAAC"}
|
package/dist/impl-store.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ImplDeployment } from './manifest';
|
|
|
2
2
|
import { EthereumProvider } from './provider';
|
|
3
3
|
import { Deployment } from './deployment';
|
|
4
4
|
import type { Version } from './version';
|
|
5
|
-
|
|
6
|
-
export declare function
|
|
5
|
+
import { DeployOpts } from '.';
|
|
6
|
+
export declare function fetchOrDeploy(version: Version, provider: EthereumProvider, deploy: () => Promise<ImplDeployment>, opts?: DeployOpts): Promise<string>;
|
|
7
|
+
export declare function fetchOrDeployAdmin(provider: EthereumProvider, deploy: () => Promise<Deployment>, opts?: DeployOpts): Promise<string>;
|
|
7
8
|
//# sourceMappingURL=impl-store.d.ts.map
|
package/dist/impl-store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"impl-store.d.ts","sourceRoot":"","sources":["../src/impl-store.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,cAAc,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAwB,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,UAAU,EAAgE,MAAM,cAAc,CAAC;AACxG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"impl-store.d.ts","sourceRoot":"","sources":["../src/impl-store.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,cAAc,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAwB,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,UAAU,EAAgE,MAAM,cAAc,CAAC;AACxG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC;AAyE/B,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,EACrC,IAAI,CAAC,EAAE,UAAU,GAChB,OAAO,CAAC,MAAM,CAAC,CAEjB;AAQD,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,EACjC,IAAI,CAAC,EAAE,UAAU,GAChB,OAAO,CAAC,MAAM,CAAC,CAEjB"}
|
package/dist/impl-store.js
CHANGED
|
@@ -9,7 +9,18 @@ const manifest_1 = require("./manifest");
|
|
|
9
9
|
const provider_1 = require("./provider");
|
|
10
10
|
const deployment_1 = require("./deployment");
|
|
11
11
|
const assert_1 = __importDefault(require("assert"));
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Fetches the deployment from the manifest, or deploys it if not found.
|
|
14
|
+
*
|
|
15
|
+
* @param lens the manifest lens
|
|
16
|
+
* @param provider the Ethereum provider
|
|
17
|
+
* @param deploy the deploy function
|
|
18
|
+
* @param opts options containing the timeout and pollingInterval parameters. If undefined, assumes the timeout is not configurable and will not mention those parameters in the error message for TransactionMinedTimeout.
|
|
19
|
+
* @returns the deployment address
|
|
20
|
+
* @throws {InvalidDeployment} if the deployment is invalid
|
|
21
|
+
* @throws {TransactionMinedTimeout} if the transaction was not confirmed within the timeout period
|
|
22
|
+
*/
|
|
23
|
+
async function fetchOrDeployGeneric(lens, provider, deploy, opts) {
|
|
13
24
|
const manifest = await manifest_1.Manifest.forNetwork(provider);
|
|
14
25
|
try {
|
|
15
26
|
const deployment = await manifest.lockedRun(async () => {
|
|
@@ -28,7 +39,7 @@ async function fetchOrDeployGeneric(lens, provider, deploy) {
|
|
|
28
39
|
}
|
|
29
40
|
return updated;
|
|
30
41
|
});
|
|
31
|
-
await (0, deployment_1.waitAndValidateDeployment)(provider, deployment);
|
|
42
|
+
await (0, deployment_1.waitAndValidateDeployment)(provider, deployment, lens.type, opts);
|
|
32
43
|
return deployment.address;
|
|
33
44
|
}
|
|
34
45
|
catch (e) {
|
|
@@ -49,24 +60,24 @@ async function fetchOrDeployGeneric(lens, provider, deploy) {
|
|
|
49
60
|
throw e;
|
|
50
61
|
}
|
|
51
62
|
}
|
|
52
|
-
async function fetchOrDeploy(version, provider, deploy) {
|
|
53
|
-
return fetchOrDeployGeneric(implLens(version.linkedWithoutMetadata), provider, deploy);
|
|
63
|
+
async function fetchOrDeploy(version, provider, deploy, opts) {
|
|
64
|
+
return fetchOrDeployGeneric(implLens(version.linkedWithoutMetadata), provider, deploy, opts);
|
|
54
65
|
}
|
|
55
66
|
exports.fetchOrDeploy = fetchOrDeploy;
|
|
56
|
-
const implLens = (versionWithoutMetadata) => lens(`implementation ${versionWithoutMetadata}`, data => ({
|
|
67
|
+
const implLens = (versionWithoutMetadata) => lens(`implementation ${versionWithoutMetadata}`, 'implementation', data => ({
|
|
57
68
|
get: () => data.impls[versionWithoutMetadata],
|
|
58
69
|
set: (value) => (data.impls[versionWithoutMetadata] = value),
|
|
59
70
|
}));
|
|
60
|
-
async function fetchOrDeployAdmin(provider, deploy) {
|
|
61
|
-
return fetchOrDeployGeneric(adminLens, provider, deploy);
|
|
71
|
+
async function fetchOrDeployAdmin(provider, deploy, opts) {
|
|
72
|
+
return fetchOrDeployGeneric(adminLens, provider, deploy, opts);
|
|
62
73
|
}
|
|
63
74
|
exports.fetchOrDeployAdmin = fetchOrDeployAdmin;
|
|
64
|
-
const adminLens = lens('proxy admin', data => ({
|
|
75
|
+
const adminLens = lens('proxy admin', 'proxy admin', data => ({
|
|
65
76
|
get: () => data.admin,
|
|
66
77
|
set: (value) => (data.admin = value),
|
|
67
78
|
}));
|
|
68
|
-
function lens(description, fn) {
|
|
69
|
-
return Object.assign(fn, { description });
|
|
79
|
+
function lens(description, type, fn) {
|
|
80
|
+
return Object.assign(fn, { description, type });
|
|
70
81
|
}
|
|
71
82
|
async function checkForAddressClash(provider, data, updated) {
|
|
72
83
|
const clash = lookupDeployment(data, updated.address);
|
package/dist/impl-store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"impl-store.js","sourceRoot":"","sources":["../src/impl-store.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAkC;AAClC,yCAAoE;AACpE,yCAAoE;AACpE,6CAAwG;AAExG,oDAA4B;
|
|
1
|
+
{"version":3,"file":"impl-store.js","sourceRoot":"","sources":["../src/impl-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Ae;;IAC3D,IAAI,CAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,OAAO,MAAK,OAAO,EAAE;QACnC,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;KACxB;IAED,KAAK,MAAM,sBAAsB,IAAI,IAAI,CAAC,KAAK,EAAE;QAC/C,IAAI,CAAA,MAAA,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,0CAAE,OAAO,MAAK,OAAO,EAAE;YAC3D,OAAO,QAAQ,CAAC,sBAAsB,CAAC,CAAC,IAAI,CAAC,CAAC;SAC/C;KACF;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openzeppelin/upgrades-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": "https://github.com/OpenZeppelin/openzeppelin-upgrades/tree/master/packages/core",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"proper-lockfile": "^4.1.1",
|
|
60
60
|
"solidity-ast": "^0.4.15"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "aff3cdacedb7265f5b54cdb8408e9517bb009e7f"
|
|
63
63
|
}
|
package/src/deployment.test.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import { promisify } from 'util';
|
|
3
|
+
import { TransactionMinedTimeout } from '.';
|
|
3
4
|
|
|
4
5
|
import { Deployment, resumeOrDeploy, waitAndValidateDeployment } from './deployment';
|
|
5
6
|
import { stubProvider } from './stub-provider';
|
|
@@ -96,3 +97,27 @@ test('waits for a deployment to return contract code', async t => {
|
|
|
96
97
|
provider.addContract(deployment.address);
|
|
97
98
|
await waitAndValidateDeployment(provider, deployment);
|
|
98
99
|
});
|
|
100
|
+
|
|
101
|
+
test('tx mined timeout - no params', async t => {
|
|
102
|
+
const provider = stubProvider();
|
|
103
|
+
const deployment = await resumeOrDeploy(provider, undefined, provider.deploy);
|
|
104
|
+
try {
|
|
105
|
+
throw new TransactionMinedTimeout(deployment);
|
|
106
|
+
} catch (e: any) {
|
|
107
|
+
const EXPECTED =
|
|
108
|
+
/Timed out waiting for contract deployment to address \S+ with transaction \S+\n\nRun the function again to continue waiting for the transaction confirmation./;
|
|
109
|
+
t.true(EXPECTED.test(e.message), e.message);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('tx mined timeout - params', async t => {
|
|
114
|
+
const provider = stubProvider();
|
|
115
|
+
const deployment = await resumeOrDeploy(provider, undefined, provider.deploy);
|
|
116
|
+
try {
|
|
117
|
+
throw new TransactionMinedTimeout(deployment, 'implementation', true);
|
|
118
|
+
} catch (e: any) {
|
|
119
|
+
const EXPECTED =
|
|
120
|
+
/Timed out waiting for implementation contract deployment to address \S+ with transaction \S+\n\nRun the function again to continue waiting for the transaction confirmation. If the problem persists, adjust the polling parameters with the timeout and pollingInterval options./;
|
|
121
|
+
t.true(EXPECTED.test(e.message), e.message);
|
|
122
|
+
}
|
|
123
|
+
});
|
package/src/deployment.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
isDevelopmentNetwork,
|
|
11
11
|
isReceiptSuccessful,
|
|
12
12
|
} from './provider';
|
|
13
|
+
import { UpgradesError } from './error';
|
|
13
14
|
|
|
14
15
|
const sleep = promisify(setTimeout);
|
|
15
16
|
|
|
@@ -18,6 +19,18 @@ export interface Deployment {
|
|
|
18
19
|
txHash?: string;
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
export interface DeployOpts {
|
|
23
|
+
/**
|
|
24
|
+
* Timeout in milliseconds to wait for the transaction confirmation when deploying an implementation contract or proxy admin contract. Use `0` to wait indefinitely.
|
|
25
|
+
*/
|
|
26
|
+
timeout?: number;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Polling interval in milliseconds between checks for the transaction confirmation when deploying an implementation contract or proxy admin contract.
|
|
30
|
+
*/
|
|
31
|
+
pollingInterval?: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
21
34
|
export async function resumeOrDeploy<T extends Deployment>(
|
|
22
35
|
provider: EthereumProvider,
|
|
23
36
|
cached: T | undefined,
|
|
@@ -51,24 +64,25 @@ export async function resumeOrDeploy<T extends Deployment>(
|
|
|
51
64
|
return deployment;
|
|
52
65
|
}
|
|
53
66
|
|
|
54
|
-
export async function waitAndValidateDeployment(
|
|
67
|
+
export async function waitAndValidateDeployment(
|
|
68
|
+
provider: EthereumProvider,
|
|
69
|
+
deployment: Deployment,
|
|
70
|
+
type?: string,
|
|
71
|
+
opts?: DeployOpts,
|
|
72
|
+
): Promise<void> {
|
|
55
73
|
const { txHash, address } = deployment;
|
|
56
74
|
|
|
57
|
-
// Poll for 60 seconds with a 5 second poll interval.
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
75
|
+
// Poll for 60 seconds with a 5 second poll interval by default.
|
|
76
|
+
const pollTimeout = opts?.timeout ?? 60e3;
|
|
77
|
+
const pollInterval = opts?.pollingInterval ?? 5e3;
|
|
78
|
+
|
|
79
|
+
debug('polling timeout', pollTimeout, 'polling interval', pollInterval);
|
|
61
80
|
|
|
62
81
|
if (txHash !== undefined) {
|
|
63
82
|
const startTime = Date.now();
|
|
64
83
|
|
|
65
84
|
// eslint-disable-next-line no-constant-condition
|
|
66
85
|
while (true) {
|
|
67
|
-
const elapsedTime = Date.now() - startTime;
|
|
68
|
-
if (elapsedTime >= pollTimeout) {
|
|
69
|
-
// A timeout is NOT an InvalidDeployment
|
|
70
|
-
throw new TransactionMinedTimeout(deployment);
|
|
71
|
-
}
|
|
72
86
|
debug('verifying deployment tx mined', txHash);
|
|
73
87
|
const receipt = await getTransactionReceipt(provider, txHash);
|
|
74
88
|
if (receipt && isReceiptSuccessful(receipt)) {
|
|
@@ -81,6 +95,13 @@ export async function waitAndValidateDeployment(provider: EthereumProvider, depl
|
|
|
81
95
|
debug('waiting for deployment tx mined', txHash);
|
|
82
96
|
await sleep(pollInterval);
|
|
83
97
|
}
|
|
98
|
+
if (pollTimeout != 0) {
|
|
99
|
+
const elapsedTime = Date.now() - startTime;
|
|
100
|
+
if (elapsedTime >= pollTimeout) {
|
|
101
|
+
// A timeout is NOT an InvalidDeployment
|
|
102
|
+
throw new TransactionMinedTimeout(deployment, type, !!opts);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
84
105
|
}
|
|
85
106
|
}
|
|
86
107
|
|
|
@@ -96,9 +117,18 @@ export async function waitAndValidateDeployment(provider: EthereumProvider, depl
|
|
|
96
117
|
debug('code in target address found', address);
|
|
97
118
|
}
|
|
98
119
|
|
|
99
|
-
export class TransactionMinedTimeout extends
|
|
100
|
-
constructor(readonly deployment: Deployment) {
|
|
101
|
-
super(
|
|
120
|
+
export class TransactionMinedTimeout extends UpgradesError {
|
|
121
|
+
constructor(readonly deployment: Deployment, type?: string, configurableTimeout?: boolean) {
|
|
122
|
+
super(
|
|
123
|
+
`Timed out waiting for ${type ? type + ' ' : ''}contract deployment to address ${
|
|
124
|
+
deployment.address
|
|
125
|
+
} with transaction ${deployment.txHash}`,
|
|
126
|
+
() =>
|
|
127
|
+
'Run the function again to continue waiting for the transaction confirmation.' +
|
|
128
|
+
(configurableTimeout
|
|
129
|
+
? ' If the problem persists, adjust the polling parameters with the timeout and pollingInterval options.'
|
|
130
|
+
: ''),
|
|
131
|
+
);
|
|
102
132
|
}
|
|
103
133
|
}
|
|
104
134
|
|
package/src/impl-store.ts
CHANGED
|
@@ -4,9 +4,11 @@ import { EthereumProvider, isDevelopmentNetwork } from './provider';
|
|
|
4
4
|
import { Deployment, InvalidDeployment, resumeOrDeploy, waitAndValidateDeployment } from './deployment';
|
|
5
5
|
import type { Version } from './version';
|
|
6
6
|
import assert from 'assert';
|
|
7
|
+
import { DeployOpts } from '.';
|
|
7
8
|
|
|
8
9
|
interface ManifestLens<T> {
|
|
9
10
|
description: string;
|
|
11
|
+
type: string;
|
|
10
12
|
(data: ManifestData): ManifestField<T>;
|
|
11
13
|
}
|
|
12
14
|
|
|
@@ -15,10 +17,22 @@ interface ManifestField<T> {
|
|
|
15
17
|
set(value: T | undefined): void;
|
|
16
18
|
}
|
|
17
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Fetches the deployment from the manifest, or deploys it if not found.
|
|
22
|
+
*
|
|
23
|
+
* @param lens the manifest lens
|
|
24
|
+
* @param provider the Ethereum provider
|
|
25
|
+
* @param deploy the deploy function
|
|
26
|
+
* @param opts options containing the timeout and pollingInterval parameters. If undefined, assumes the timeout is not configurable and will not mention those parameters in the error message for TransactionMinedTimeout.
|
|
27
|
+
* @returns the deployment address
|
|
28
|
+
* @throws {InvalidDeployment} if the deployment is invalid
|
|
29
|
+
* @throws {TransactionMinedTimeout} if the transaction was not confirmed within the timeout period
|
|
30
|
+
*/
|
|
18
31
|
async function fetchOrDeployGeneric<T extends Deployment>(
|
|
19
32
|
lens: ManifestLens<T>,
|
|
20
33
|
provider: EthereumProvider,
|
|
21
34
|
deploy: () => Promise<T>,
|
|
35
|
+
opts?: DeployOpts,
|
|
22
36
|
): Promise<string> {
|
|
23
37
|
const manifest = await Manifest.forNetwork(provider);
|
|
24
38
|
|
|
@@ -40,7 +54,7 @@ async function fetchOrDeployGeneric<T extends Deployment>(
|
|
|
40
54
|
return updated;
|
|
41
55
|
});
|
|
42
56
|
|
|
43
|
-
await waitAndValidateDeployment(provider, deployment);
|
|
57
|
+
await waitAndValidateDeployment(provider, deployment, lens.type, opts);
|
|
44
58
|
|
|
45
59
|
return deployment.address;
|
|
46
60
|
} catch (e) {
|
|
@@ -67,12 +81,13 @@ export async function fetchOrDeploy(
|
|
|
67
81
|
version: Version,
|
|
68
82
|
provider: EthereumProvider,
|
|
69
83
|
deploy: () => Promise<ImplDeployment>,
|
|
84
|
+
opts?: DeployOpts,
|
|
70
85
|
): Promise<string> {
|
|
71
|
-
return fetchOrDeployGeneric(implLens(version.linkedWithoutMetadata), provider, deploy);
|
|
86
|
+
return fetchOrDeployGeneric(implLens(version.linkedWithoutMetadata), provider, deploy, opts);
|
|
72
87
|
}
|
|
73
88
|
|
|
74
89
|
const implLens = (versionWithoutMetadata: string) =>
|
|
75
|
-
lens(`implementation ${versionWithoutMetadata}`, data => ({
|
|
90
|
+
lens(`implementation ${versionWithoutMetadata}`, 'implementation', data => ({
|
|
76
91
|
get: () => data.impls[versionWithoutMetadata],
|
|
77
92
|
set: (value?: ImplDeployment) => (data.impls[versionWithoutMetadata] = value),
|
|
78
93
|
}));
|
|
@@ -80,17 +95,18 @@ const implLens = (versionWithoutMetadata: string) =>
|
|
|
80
95
|
export async function fetchOrDeployAdmin(
|
|
81
96
|
provider: EthereumProvider,
|
|
82
97
|
deploy: () => Promise<Deployment>,
|
|
98
|
+
opts?: DeployOpts,
|
|
83
99
|
): Promise<string> {
|
|
84
|
-
return fetchOrDeployGeneric(adminLens, provider, deploy);
|
|
100
|
+
return fetchOrDeployGeneric(adminLens, provider, deploy, opts);
|
|
85
101
|
}
|
|
86
102
|
|
|
87
|
-
const adminLens = lens('proxy admin', data => ({
|
|
103
|
+
const adminLens = lens('proxy admin', 'proxy admin', data => ({
|
|
88
104
|
get: () => data.admin,
|
|
89
105
|
set: (value?: Deployment) => (data.admin = value),
|
|
90
106
|
}));
|
|
91
107
|
|
|
92
|
-
function lens<T>(description: string, fn: (data: ManifestData) => ManifestField<T>): ManifestLens<T> {
|
|
93
|
-
return Object.assign(fn, { description });
|
|
108
|
+
function lens<T>(description: string, type: string, fn: (data: ManifestData) => ManifestField<T>): ManifestLens<T> {
|
|
109
|
+
return Object.assign(fn, { description, type });
|
|
94
110
|
}
|
|
95
111
|
|
|
96
112
|
async function checkForAddressClash(
|