@openzeppelin/upgrades-core 1.9.1
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/CHANGELOG.md +110 -0
- package/artifacts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol/ERC1967Proxy.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol/ERC1967Proxy.json +80 -0
- package/artifacts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json +160 -0
- package/artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json +155 -0
- package/artifacts/AdminUpgradeabilityProxy.json +155 -0
- package/artifacts/ProxyAdmin.json +160 -0
- package/artifacts/contracts/proxy/AdminUpgradeabilityProxy.sol/AdminUpgradeabilityProxy.json +155 -0
- package/artifacts/contracts/proxy/ProxyAdmin.sol/ProxyAdmin.json +160 -0
- package/contracts/Initializable.sol +64 -0
- package/dist/ast-dereferencer.d.ts +8 -0
- package/dist/ast-dereferencer.d.ts.map +1 -0
- package/dist/ast-dereferencer.js +29 -0
- package/dist/ast-dereferencer.js.map +1 -0
- package/dist/deployment.d.ts +18 -0
- package/dist/deployment.d.ts.map +1 -0
- package/dist/deployment.js +110 -0
- package/dist/deployment.js.map +1 -0
- package/dist/deployment.test.d.ts +2 -0
- package/dist/deployment.test.d.ts.map +1 -0
- package/dist/deployment.test.js +92 -0
- package/dist/deployment.test.js.map +1 -0
- package/dist/eip-1967.d.ts +7 -0
- package/dist/eip-1967.d.ts.map +1 -0
- package/dist/eip-1967.js +63 -0
- package/dist/eip-1967.js.map +1 -0
- package/dist/error.d.ts +21 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +21 -0
- package/dist/error.js.map +1 -0
- package/dist/impl-store.d.ts +7 -0
- package/dist/impl-store.d.ts.map +1 -0
- package/dist/impl-store.js +94 -0
- package/dist/impl-store.js.map +1 -0
- package/dist/impl-store.test.d.ts +2 -0
- package/dist/impl-store.test.d.ts.map +1 -0
- package/dist/impl-store.test.js +55 -0
- package/dist/impl-store.test.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/levenshtein.d.ts +12 -0
- package/dist/levenshtein.d.ts.map +1 -0
- package/dist/levenshtein.js +89 -0
- package/dist/levenshtein.js.map +1 -0
- package/dist/levenshtein.test.d.ts +2 -0
- package/dist/levenshtein.test.d.ts.map +1 -0
- package/dist/levenshtein.test.js +88 -0
- package/dist/levenshtein.test.js.map +1 -0
- package/dist/link-refs.d.ts +11 -0
- package/dist/link-refs.d.ts.map +1 -0
- package/dist/link-refs.js +36 -0
- package/dist/link-refs.js.map +1 -0
- package/dist/link-refs.test.d.ts +2 -0
- package/dist/link-refs.test.d.ts.map +1 -0
- package/dist/link-refs.test.js +76 -0
- package/dist/link-refs.test.js.map +1 -0
- package/dist/manifest-storage-layout.d.ts +6 -0
- package/dist/manifest-storage-layout.d.ts.map +1 -0
- package/dist/manifest-storage-layout.js +95 -0
- package/dist/manifest-storage-layout.js.map +1 -0
- package/dist/manifest-storage-layout.test.d.ts +2 -0
- package/dist/manifest-storage-layout.test.d.ts.map +1 -0
- package/dist/manifest-storage-layout.test.js +105 -0
- package/dist/manifest-storage-layout.test.js.map +1 -0
- package/dist/manifest.d.ts +36 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +154 -0
- package/dist/manifest.js.map +1 -0
- package/dist/manifest.test.d.ts +2 -0
- package/dist/manifest.test.d.ts.map +1 -0
- package/dist/manifest.test.js +17 -0
- package/dist/manifest.test.js.map +1 -0
- package/dist/provider.d.ts +37 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +74 -0
- package/dist/provider.js.map +1 -0
- package/dist/provider.test.d.ts +2 -0
- package/dist/provider.test.d.ts.map +1 -0
- package/dist/provider.test.js +41 -0
- package/dist/provider.test.js.map +1 -0
- package/dist/scripts/migrate-oz-cli-project.d.ts +108 -0
- package/dist/scripts/migrate-oz-cli-project.d.ts.map +1 -0
- package/dist/scripts/migrate-oz-cli-project.js +321 -0
- package/dist/scripts/migrate-oz-cli-project.js.map +1 -0
- package/dist/scripts/migrate-oz-cli-project.test.d.ts +2 -0
- package/dist/scripts/migrate-oz-cli-project.test.d.ts.map +1 -0
- package/dist/scripts/migrate-oz-cli-project.test.js +60 -0
- package/dist/scripts/migrate-oz-cli-project.test.js.map +1 -0
- package/dist/set-proxy-kind.d.ts +5 -0
- package/dist/set-proxy-kind.d.ts.map +1 -0
- package/dist/set-proxy-kind.js +25 -0
- package/dist/set-proxy-kind.js.map +1 -0
- package/dist/solc-api.d.ts +39 -0
- package/dist/solc-api.d.ts.map +1 -0
- package/dist/solc-api.js +3 -0
- package/dist/solc-api.js.map +1 -0
- package/dist/src-decoder.d.ts +6 -0
- package/dist/src-decoder.d.ts.map +1 -0
- package/dist/src-decoder.js +36 -0
- package/dist/src-decoder.js.map +1 -0
- package/dist/src-decoder.test.d.ts +2 -0
- package/dist/src-decoder.test.d.ts.map +1 -0
- package/dist/src-decoder.test.js +29 -0
- package/dist/src-decoder.test.js.map +1 -0
- package/dist/storage/compare.d.ts +55 -0
- package/dist/storage/compare.d.ts.map +1 -0
- package/dist/storage/compare.js +181 -0
- package/dist/storage/compare.js.map +1 -0
- package/dist/storage/compat.d.ts +4 -0
- package/dist/storage/compat.d.ts.map +1 -0
- package/dist/storage/compat.js +9 -0
- package/dist/storage/compat.js.map +1 -0
- package/dist/storage/extract.d.ts +7 -0
- package/dist/storage/extract.d.ts.map +1 -0
- package/dist/storage/extract.js +86 -0
- package/dist/storage/extract.js.map +1 -0
- package/dist/storage/index.d.ts +8 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +65 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/layout.d.ts +31 -0
- package/dist/storage/layout.d.ts.map +1 -0
- package/dist/storage/layout.js +46 -0
- package/dist/storage/layout.js.map +1 -0
- package/dist/storage/report.d.ts +8 -0
- package/dist/storage/report.d.ts.map +1 -0
- package/dist/storage/report.js +175 -0
- package/dist/storage/report.js.map +1 -0
- package/dist/storage/report.test.d.ts +2 -0
- package/dist/storage/report.test.d.ts.map +1 -0
- package/dist/storage/report.test.js +82 -0
- package/dist/storage/report.test.js.map +1 -0
- package/dist/storage.test.d.ts +2 -0
- package/dist/storage.test.d.ts.map +1 -0
- package/dist/storage.test.js +436 -0
- package/dist/storage.test.js.map +1 -0
- package/dist/stub-provider.d.ts +14 -0
- package/dist/stub-provider.d.ts.map +1 -0
- package/dist/stub-provider.js +128 -0
- package/dist/stub-provider.js.map +1 -0
- package/dist/utils/assert.d.ts +3 -0
- package/dist/utils/assert.d.ts.map +1 -0
- package/dist/utils/assert.js +14 -0
- package/dist/utils/assert.js.map +1 -0
- package/dist/utils/curry.d.ts +6 -0
- package/dist/utils/curry.d.ts.map +1 -0
- package/dist/utils/curry.js +16 -0
- package/dist/utils/curry.js.map +1 -0
- package/dist/utils/debug.d.ts +4 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/dist/utils/debug.js +8 -0
- package/dist/utils/debug.js.map +1 -0
- package/dist/utils/deep-array.d.ts +3 -0
- package/dist/utils/deep-array.d.ts.map +1 -0
- package/dist/utils/deep-array.js +13 -0
- package/dist/utils/deep-array.js.map +1 -0
- package/dist/utils/deep-array.test.d.ts +2 -0
- package/dist/utils/deep-array.test.d.ts.map +1 -0
- package/dist/utils/deep-array.test.js +23 -0
- package/dist/utils/deep-array.test.js.map +1 -0
- package/dist/utils/function.d.ts +4 -0
- package/dist/utils/function.d.ts.map +1 -0
- package/dist/utils/function.js +43 -0
- package/dist/utils/function.js.map +1 -0
- package/dist/utils/function.test.d.ts +2 -0
- package/dist/utils/function.test.d.ts.map +1 -0
- package/dist/utils/function.test.js +34 -0
- package/dist/utils/function.test.js.map +1 -0
- package/dist/utils/indent.d.ts +2 -0
- package/dist/utils/indent.d.ts.map +1 -0
- package/dist/utils/indent.js +8 -0
- package/dist/utils/indent.js.map +1 -0
- package/dist/utils/is-nullish.d.ts +2 -0
- package/dist/utils/is-nullish.d.ts.map +1 -0
- package/dist/utils/is-nullish.js +8 -0
- package/dist/utils/is-nullish.js.map +1 -0
- package/dist/utils/is-nullish.test.d.ts +2 -0
- package/dist/utils/is-nullish.test.d.ts.map +1 -0
- package/dist/utils/is-nullish.test.js +17 -0
- package/dist/utils/is-nullish.test.js.map +1 -0
- package/dist/utils/is-value-type.d.ts +3 -0
- package/dist/utils/is-value-type.d.ts.map +1 -0
- package/dist/utils/is-value-type.js +8 -0
- package/dist/utils/is-value-type.js.map +1 -0
- package/dist/utils/itemize.d.ts +3 -0
- package/dist/utils/itemize.d.ts.map +1 -0
- package/dist/utils/itemize.js +18 -0
- package/dist/utils/itemize.js.map +1 -0
- package/dist/utils/log.d.ts +4 -0
- package/dist/utils/log.d.ts.map +1 -0
- package/dist/utils/log.js +35 -0
- package/dist/utils/log.js.map +1 -0
- package/dist/utils/make-non-enumerable.d.ts +2 -0
- package/dist/utils/make-non-enumerable.d.ts.map +1 -0
- package/dist/utils/make-non-enumerable.js +9 -0
- package/dist/utils/make-non-enumerable.js.map +1 -0
- package/dist/utils/map-values.d.ts +2 -0
- package/dist/utils/map-values.d.ts.map +1 -0
- package/dist/utils/map-values.js +12 -0
- package/dist/utils/map-values.js.map +1 -0
- package/dist/utils/parse-type-id.d.ts +9 -0
- package/dist/utils/parse-type-id.d.ts.map +1 -0
- package/dist/utils/parse-type-id.js +92 -0
- package/dist/utils/parse-type-id.js.map +1 -0
- package/dist/utils/parse-type-id.test.d.ts +2 -0
- package/dist/utils/parse-type-id.test.d.ts.map +1 -0
- package/dist/utils/parse-type-id.test.js +25 -0
- package/dist/utils/parse-type-id.test.js.map +1 -0
- package/dist/utils/pick.d.ts +2 -0
- package/dist/utils/pick.d.ts.map +1 -0
- package/dist/utils/pick.js +12 -0
- package/dist/utils/pick.js.map +1 -0
- package/dist/utils/type-id.d.ts +4 -0
- package/dist/utils/type-id.d.ts.map +1 -0
- package/dist/utils/type-id.js +65 -0
- package/dist/utils/type-id.js.map +1 -0
- package/dist/validate/compat.d.ts +6 -0
- package/dist/validate/compat.d.ts.map +1 -0
- package/dist/validate/compat.js +4 -0
- package/dist/validate/compat.js.map +1 -0
- package/dist/validate/data.d.ts +14 -0
- package/dist/validate/data.d.ts.map +1 -0
- package/dist/validate/data.js +50 -0
- package/dist/validate/data.js.map +1 -0
- package/dist/validate/error.d.ts +7 -0
- package/dist/validate/error.d.ts.map +1 -0
- package/dist/validate/error.js +78 -0
- package/dist/validate/error.js.map +1 -0
- package/dist/validate/index.d.ts +8 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/index.js +24 -0
- package/dist/validate/index.js.map +1 -0
- package/dist/validate/overrides.d.ts +14 -0
- package/dist/validate/overrides.d.ts.map +1 -0
- package/dist/validate/overrides.js +72 -0
- package/dist/validate/overrides.js.map +1 -0
- package/dist/validate/query.d.ts +15 -0
- package/dist/validate/query.d.ts.map +1 -0
- package/dist/validate/query.js +111 -0
- package/dist/validate/query.js.map +1 -0
- package/dist/validate/query.test.d.ts +2 -0
- package/dist/validate/query.test.d.ts.map +1 -0
- package/dist/validate/query.test.js +48 -0
- package/dist/validate/query.test.js.map +1 -0
- package/dist/validate/run.d.ts +39 -0
- package/dist/validate/run.d.ts.map +1 -0
- package/dist/validate/run.js +199 -0
- package/dist/validate/run.js.map +1 -0
- package/dist/validate.test.d.ts +2 -0
- package/dist/validate.test.d.ts.map +1 -0
- package/dist/validate.test.js +116 -0
- package/dist/validate.test.js.map +1 -0
- package/dist/version.d.ts +9 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +66 -0
- package/dist/version.js.map +1 -0
- package/dist/version.test.d.ts +2 -0
- package/dist/version.test.d.ts.map +1 -0
- package/dist/version.test.js +53 -0
- package/dist/version.test.js.map +1 -0
- package/package.json +58 -0
- package/src/ast-dereferencer.ts +42 -0
- package/src/deployment.test.ts +98 -0
- package/src/deployment.ts +122 -0
- package/src/eip-1967.ts +77 -0
- package/src/error.ts +26 -0
- package/src/impl-store.test.ts +59 -0
- package/src/impl-store.ts +124 -0
- package/src/index.ts +18 -0
- package/src/levenshtein.test.ts +91 -0
- package/src/levenshtein.ts +116 -0
- package/src/link-refs.test.ts +77 -0
- package/src/link-refs.ts +41 -0
- package/src/manifest-storage-layout.test.ts +118 -0
- package/src/manifest-storage-layout.ts +107 -0
- package/src/manifest.test.ts +13 -0
- package/src/manifest.ts +178 -0
- package/src/provider.test.ts +43 -0
- package/src/provider.ts +103 -0
- package/src/scripts/migratable-manifest.test.json +175 -0
- package/src/scripts/migrate-oz-cli-project.test.ts +70 -0
- package/src/scripts/migrate-oz-cli-project.test.ts.md +146 -0
- package/src/scripts/migrate-oz-cli-project.test.ts.snap +0 -0
- package/src/scripts/migrate-oz-cli-project.ts +484 -0
- package/src/scripts/project-file.test.json +25 -0
- package/src/set-proxy-kind.ts +27 -0
- package/src/solc-api.ts +42 -0
- package/src/src-decoder.test.ts +30 -0
- package/src/src-decoder.ts +37 -0
- package/src/storage/compare.ts +249 -0
- package/src/storage/compat.ts +3 -0
- package/src/storage/extract.ts +110 -0
- package/src/storage/index.ts +73 -0
- package/src/storage/layout.ts +88 -0
- package/src/storage/report.test.ts +95 -0
- package/src/storage/report.test.ts.md +154 -0
- package/src/storage/report.test.ts.snap +0 -0
- package/src/storage/report.ts +215 -0
- package/src/storage.test.ts +479 -0
- package/src/storage.test.ts.md +643 -0
- package/src/storage.test.ts.snap +0 -0
- package/src/stub-provider.ts +120 -0
- package/src/utils/assert.ts +9 -0
- package/src/utils/curry.ts +17 -0
- package/src/utils/debug.ts +3 -0
- package/src/utils/deep-array.test.ts +21 -0
- package/src/utils/deep-array.ts +9 -0
- package/src/utils/function.test.ts +37 -0
- package/src/utils/function.ts +53 -0
- package/src/utils/indent.ts +3 -0
- package/src/utils/is-nullish.test.ts +15 -0
- package/src/utils/is-nullish.ts +3 -0
- package/src/utils/is-value-type.ts +5 -0
- package/src/utils/itemize.ts +16 -0
- package/src/utils/log.ts +34 -0
- package/src/utils/make-non-enumerable.ts +4 -0
- package/src/utils/map-values.ts +7 -0
- package/src/utils/parse-type-id.test.ts +22 -0
- package/src/utils/parse-type-id.test.ts.md +264 -0
- package/src/utils/parse-type-id.test.ts.snap +0 -0
- package/src/utils/parse-type-id.ts +104 -0
- package/src/utils/pick.ts +7 -0
- package/src/utils/type-id.ts +57 -0
- package/src/validate/compat.ts +9 -0
- package/src/validate/data.ts +55 -0
- package/src/validate/error.ts +75 -0
- package/src/validate/index.ts +17 -0
- package/src/validate/overrides.ts +93 -0
- package/src/validate/query.test.ts +48 -0
- package/src/validate/query.ts +127 -0
- package/src/validate/run.ts +278 -0
- package/src/validate.test.ts +133 -0
- package/src/version.test.ts +59 -0
- package/src/version.ts +71 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import { EthereumProvider, getTransactionReceipt } from './provider';
|
|
3
|
+
|
|
4
|
+
const hash = '0x1234';
|
|
5
|
+
|
|
6
|
+
function makeProviderReturning(result: unknown): EthereumProvider {
|
|
7
|
+
return { send: (_method: string, _params: unknown[]) => Promise.resolve(result) } as EthereumProvider;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
test('getTransactionReceipt returns null', async t => {
|
|
11
|
+
const provider = makeProviderReturning(null);
|
|
12
|
+
t.is(await getTransactionReceipt(provider, hash), null);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('getTransactionReceipt status returns 0x0', async t => {
|
|
16
|
+
const provider = makeProviderReturning({ status: '0x0' });
|
|
17
|
+
const receipt = await getTransactionReceipt(provider, hash);
|
|
18
|
+
t.is(receipt?.status, '0x0');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('getTransactionReceipt status returns 0x1', async t => {
|
|
22
|
+
const provider = makeProviderReturning({ status: '0x1' });
|
|
23
|
+
const receipt = await getTransactionReceipt(provider, hash);
|
|
24
|
+
t.is(receipt?.status, '0x1');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('getTransactionReceipt status normalizes to 0x0', async t => {
|
|
28
|
+
const provider = makeProviderReturning({ status: '0x000000000000000000000000' });
|
|
29
|
+
const receipt = await getTransactionReceipt(provider, hash);
|
|
30
|
+
t.is(receipt?.status, '0x0');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('getTransactionReceipt status normalizes to 0x1', async t => {
|
|
34
|
+
const provider = makeProviderReturning({ status: '0x000000000000000000000001' });
|
|
35
|
+
const receipt = await getTransactionReceipt(provider, hash);
|
|
36
|
+
t.is(receipt?.status, '0x1');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('getTransactionReceipt status returns empty hex', async t => {
|
|
40
|
+
const provider = makeProviderReturning({ status: '0x' });
|
|
41
|
+
const receipt = await getTransactionReceipt(provider, hash);
|
|
42
|
+
t.is(receipt?.status, '0x');
|
|
43
|
+
});
|
package/src/provider.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import BN from 'bn.js';
|
|
2
|
+
|
|
3
|
+
export interface EthereumProvider {
|
|
4
|
+
send(method: 'web3_clientVersion', params: []): Promise<string>;
|
|
5
|
+
send(method: 'net_version', params: []): Promise<string>;
|
|
6
|
+
send(method: 'eth_chainId', params: []): Promise<string>;
|
|
7
|
+
send(method: 'eth_getCode', params: [string, string]): Promise<string>;
|
|
8
|
+
send(method: 'eth_getStorageAt', params: [string, string, string]): Promise<string>;
|
|
9
|
+
send(method: 'eth_getTransactionByHash', params: [string]): Promise<null | EthereumTransaction>;
|
|
10
|
+
send(method: 'eth_getTransactionReceipt', params: [string]): Promise<null | EthereumTransactionReceipt>;
|
|
11
|
+
send(method: string, params: unknown[]): Promise<unknown>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface EthereumTransaction {
|
|
15
|
+
blockHash: string | null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface EthereumTransactionReceipt {
|
|
19
|
+
status: string;
|
|
20
|
+
to: string | null;
|
|
21
|
+
from: string;
|
|
22
|
+
blockHash: string;
|
|
23
|
+
blockNumber: string;
|
|
24
|
+
transactionHash: string;
|
|
25
|
+
transactionIndex: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function getNetworkId(provider: EthereumProvider): Promise<string> {
|
|
29
|
+
return provider.send('net_version', []);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function getChainId(provider: EthereumProvider): Promise<number> {
|
|
33
|
+
const id = await provider.send('eth_chainId', []);
|
|
34
|
+
return new BN(id.replace(/^0x/, ''), 'hex').toNumber();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function getClientVersion(provider: EthereumProvider): Promise<string> {
|
|
38
|
+
return provider.send('web3_clientVersion', []);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function getStorageAt(
|
|
42
|
+
provider: EthereumProvider,
|
|
43
|
+
address: string,
|
|
44
|
+
position: string,
|
|
45
|
+
block = 'latest',
|
|
46
|
+
): Promise<string> {
|
|
47
|
+
const storage = await provider.send('eth_getStorageAt', [address, position, block]);
|
|
48
|
+
const padded = storage.replace(/^0x/, '').padStart(64, '0');
|
|
49
|
+
return '0x' + padded;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function getCode(provider: EthereumProvider, address: string, block = 'latest'): Promise<string> {
|
|
53
|
+
return provider.send('eth_getCode', [address, block]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function hasCode(provider: EthereumProvider, address: string, block?: string): Promise<boolean> {
|
|
57
|
+
const code = await getCode(provider, address, block);
|
|
58
|
+
return code !== '0x';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export async function getTransactionByHash(
|
|
62
|
+
provider: EthereumProvider,
|
|
63
|
+
txHash: string,
|
|
64
|
+
): Promise<EthereumTransaction | null> {
|
|
65
|
+
return provider.send('eth_getTransactionByHash', [txHash]);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export async function getTransactionReceipt(
|
|
69
|
+
provider: EthereumProvider,
|
|
70
|
+
txHash: string,
|
|
71
|
+
): Promise<EthereumTransactionReceipt | null> {
|
|
72
|
+
const receipt = await provider.send('eth_getTransactionReceipt', [txHash]);
|
|
73
|
+
if (receipt?.status) {
|
|
74
|
+
receipt.status = receipt.status.match(/^0x0+$/) ? '0x0' : receipt.status.replace(/^0x0+/, '0x');
|
|
75
|
+
}
|
|
76
|
+
return receipt;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const networkNames: { [chainId in number]?: string } = Object.freeze({
|
|
80
|
+
1: 'mainnet',
|
|
81
|
+
2: 'morden',
|
|
82
|
+
3: 'ropsten',
|
|
83
|
+
4: 'rinkeby',
|
|
84
|
+
5: 'goerli',
|
|
85
|
+
42: 'kovan',
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export async function isDevelopmentNetwork(provider: EthereumProvider): Promise<boolean> {
|
|
89
|
+
const chainId = await getChainId(provider);
|
|
90
|
+
// 1337 => ganache and geth --dev
|
|
91
|
+
// 31337 => hardhat network
|
|
92
|
+
if (chainId === 1337 || chainId === 31337) {
|
|
93
|
+
return true;
|
|
94
|
+
} else {
|
|
95
|
+
const clientVersion = await getClientVersion(provider);
|
|
96
|
+
const [name] = clientVersion.split('/', 1);
|
|
97
|
+
return name === 'HardhatNetwork' || name === 'EthereumJS TestRPC';
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function isReceiptSuccessful(receipt: Pick<EthereumTransactionReceipt, 'status'>): boolean {
|
|
102
|
+
return receipt.status === '0x1';
|
|
103
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
{
|
|
2
|
+
"contracts": {
|
|
3
|
+
"Box": {
|
|
4
|
+
"address": "0xb682dEEf4f8e298d86bFc3e21f50c675151FB974",
|
|
5
|
+
"constructorCode": "608060405234801561001057600080fd5b506101a3806100206000396000f3fe",
|
|
6
|
+
"bodyBytecodeHash": "0e331fb885de0fa7c715c4819b6ded2449542cb3cce682718791be28ae0789e8",
|
|
7
|
+
"localBytecodeHash": "08100f44a71d905a66088b4c5d72f12417a580d454357e06dcc5ad12b3fa2cbc",
|
|
8
|
+
"deployedBytecodeHash": "08100f44a71d905a66088b4c5d72f12417a580d454357e06dcc5ad12b3fa2cbc",
|
|
9
|
+
"types": {
|
|
10
|
+
"t_uint256": {
|
|
11
|
+
"id": "t_uint256",
|
|
12
|
+
"kind": "elementary",
|
|
13
|
+
"label": "uint256"
|
|
14
|
+
},
|
|
15
|
+
"t_bool": {
|
|
16
|
+
"id": "t_bool",
|
|
17
|
+
"kind": "elementary",
|
|
18
|
+
"label": "bool"
|
|
19
|
+
},
|
|
20
|
+
"t_mapping<t_bool>": {
|
|
21
|
+
"id": "t_mapping<t_bool>",
|
|
22
|
+
"valueType": "t_bool",
|
|
23
|
+
"label": "mapping(key => bool)",
|
|
24
|
+
"kind": "mapping"
|
|
25
|
+
},
|
|
26
|
+
"t_struct<Box.MyStruct>": {
|
|
27
|
+
"id": "t_struct<Box.MyStruct>",
|
|
28
|
+
"kind": "struct",
|
|
29
|
+
"label": "Box.MyStruct",
|
|
30
|
+
"members": [
|
|
31
|
+
{
|
|
32
|
+
"label": "x",
|
|
33
|
+
"astId": 3,
|
|
34
|
+
"type": "t_bool",
|
|
35
|
+
"src": "124:6:0"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"t_enum<Box.MyEnum>": {
|
|
40
|
+
"id": "t_enum<Box.MyEnum>",
|
|
41
|
+
"kind": "enum",
|
|
42
|
+
"label": "Box.MyEnum",
|
|
43
|
+
"members": [
|
|
44
|
+
"UP",
|
|
45
|
+
"DOWN"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"t_array:dyn<t_uint256>": {
|
|
49
|
+
"id": "t_array:dyn<t_uint256>",
|
|
50
|
+
"valueType": "t_uint256",
|
|
51
|
+
"length": "dyn",
|
|
52
|
+
"kind": "array",
|
|
53
|
+
"label": "uint256[]"
|
|
54
|
+
},
|
|
55
|
+
"t_array:10<t_uint256>": {
|
|
56
|
+
"id": "t_array:10<t_uint256>",
|
|
57
|
+
"valueType": "t_uint256",
|
|
58
|
+
"length": "10",
|
|
59
|
+
"kind": "array",
|
|
60
|
+
"label": "uint256[10]"
|
|
61
|
+
},
|
|
62
|
+
"t_array:dyn<t_enum<Box.MyEnum>>": {
|
|
63
|
+
"id": "t_array:dyn<t_enum<Box.MyEnum>>",
|
|
64
|
+
"valueType": "t_enum<Box.MyEnum>",
|
|
65
|
+
"length": "dyn",
|
|
66
|
+
"kind": "array",
|
|
67
|
+
"label": "Box.MyEnum[]"
|
|
68
|
+
},
|
|
69
|
+
"t_bytes8": {
|
|
70
|
+
"id": "t_bytes8",
|
|
71
|
+
"kind": "elementary",
|
|
72
|
+
"label": "bytes8"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"storage": [
|
|
76
|
+
{
|
|
77
|
+
"contract": "Box",
|
|
78
|
+
"path": "contracts/Box.sol",
|
|
79
|
+
"label": "value",
|
|
80
|
+
"astId": 9,
|
|
81
|
+
"type": "t_uint256",
|
|
82
|
+
"src": "173:21:0"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"contract": "Box",
|
|
86
|
+
"path": "contracts/Box.sol",
|
|
87
|
+
"label": "flag",
|
|
88
|
+
"astId": 11,
|
|
89
|
+
"type": "t_bool",
|
|
90
|
+
"src": "200:17:0"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"contract": "Box",
|
|
94
|
+
"path": "contracts/Box.sol",
|
|
95
|
+
"label": "map",
|
|
96
|
+
"astId": 15,
|
|
97
|
+
"type": "t_mapping<t_bool>",
|
|
98
|
+
"src": "223:26:0"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"contract": "Box",
|
|
102
|
+
"path": "contracts/Box.sol",
|
|
103
|
+
"label": "foo",
|
|
104
|
+
"astId": 17,
|
|
105
|
+
"type": "t_struct<Box.MyStruct>",
|
|
106
|
+
"src": "255:20:0"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"contract": "Box",
|
|
110
|
+
"path": "contracts/Box.sol",
|
|
111
|
+
"label": "myEnum",
|
|
112
|
+
"astId": 19,
|
|
113
|
+
"type": "t_enum<Box.MyEnum>",
|
|
114
|
+
"src": "281:21:0"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"contract": "Box",
|
|
118
|
+
"path": "contracts/Box.sol",
|
|
119
|
+
"label": "dynArray",
|
|
120
|
+
"astId": 22,
|
|
121
|
+
"type": "t_array:dyn<t_uint256>",
|
|
122
|
+
"src": "308:23:0"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"contract": "Box",
|
|
126
|
+
"path": "contracts/Box.sol",
|
|
127
|
+
"label": "staticArray",
|
|
128
|
+
"astId": 26,
|
|
129
|
+
"type": "t_array:10<t_uint256>",
|
|
130
|
+
"src": "337:20:0"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"contract": "Box",
|
|
134
|
+
"path": "contracts/Box.sol",
|
|
135
|
+
"label": "enumArray",
|
|
136
|
+
"astId": 29,
|
|
137
|
+
"type": "t_array:dyn<t_enum<Box.MyEnum>>",
|
|
138
|
+
"src": "363:26:0"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"contract": "Box",
|
|
142
|
+
"path": "contracts/Box.sol",
|
|
143
|
+
"label": "byteArray",
|
|
144
|
+
"astId": 31,
|
|
145
|
+
"type": "t_bytes8",
|
|
146
|
+
"src": "395:16:0"
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
"warnings": {
|
|
150
|
+
"hasConstructor": false,
|
|
151
|
+
"hasSelfDestruct": false,
|
|
152
|
+
"hasDelegateCall": false,
|
|
153
|
+
"hasInitialValuesInDeclarations": false,
|
|
154
|
+
"uninitializedBaseContracts": []
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"solidityLibs": {},
|
|
159
|
+
"proxies": {
|
|
160
|
+
"my-project/Box": [
|
|
161
|
+
{
|
|
162
|
+
"address": "0xE4C10Db67595aF2Cb4166c8C274e0140f7E43059",
|
|
163
|
+
"version": "1.0.0",
|
|
164
|
+
"implementation": "0xb682dEEf4f8e298d86bFc3e21f50c675151FB974",
|
|
165
|
+
"admin": "0x1750499D05Ed1674d822430FB960d5F6731fDf64",
|
|
166
|
+
"kind": "Upgradeable"
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
},
|
|
170
|
+
"manifestVersion": "2.2",
|
|
171
|
+
"version": "1.0.0",
|
|
172
|
+
"proxyAdmin": {
|
|
173
|
+
"address": "0x1750499D05Ed1674d822430FB960d5F6731fDf64"
|
|
174
|
+
}
|
|
175
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import os from 'os';
|
|
2
|
+
import test from 'ava';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import util from 'util';
|
|
5
|
+
import rimrafAsync from 'rimraf';
|
|
6
|
+
import { promises as fs } from 'fs';
|
|
7
|
+
import { compare as compareVersions } from 'compare-versions';
|
|
8
|
+
import {
|
|
9
|
+
migrateManifestsData,
|
|
10
|
+
NetworkFileData,
|
|
11
|
+
ProjectFileData,
|
|
12
|
+
MigrationOutput,
|
|
13
|
+
migrateLegacyProject,
|
|
14
|
+
} from './migrate-oz-cli-project';
|
|
15
|
+
|
|
16
|
+
const rimraf = util.promisify(rimrafAsync);
|
|
17
|
+
const BASE_PATH = 'src/scripts';
|
|
18
|
+
const OPENZEPPELIN_FOLDER = '.openzeppelin';
|
|
19
|
+
const PROJECT_FILE = path.join(OPENZEPPELIN_FOLDER, 'project.json');
|
|
20
|
+
const EXPORT_FILE = 'openzeppelin-cli-export.json';
|
|
21
|
+
const NETWORK_FILE = path.join(OPENZEPPELIN_FOLDER, 'rinkeby.json');
|
|
22
|
+
|
|
23
|
+
let migratableData: NetworkFileData;
|
|
24
|
+
let migrationOutput: MigrationOutput;
|
|
25
|
+
let projectData: ProjectFileData;
|
|
26
|
+
|
|
27
|
+
test.before(async () => {
|
|
28
|
+
migratableData = JSON.parse(await fs.readFile(path.join(BASE_PATH, 'migratable-manifest.test.json'), 'utf8'));
|
|
29
|
+
projectData = JSON.parse(await fs.readFile(path.join(BASE_PATH, 'project-file.test.json'), 'utf8'));
|
|
30
|
+
migrationOutput = migrateManifestsData({ rinkeby: migratableData });
|
|
31
|
+
|
|
32
|
+
process.chdir(await fs.mkdtemp(path.join(os.tmpdir(), 'migration-test-')));
|
|
33
|
+
await fs.mkdir(OPENZEPPELIN_FOLDER);
|
|
34
|
+
await fs.writeFile(PROJECT_FILE, JSON.stringify(projectData, null, 2));
|
|
35
|
+
await fs.writeFile(NETWORK_FILE, JSON.stringify(migratableData, null, 2));
|
|
36
|
+
await migrateLegacyProject();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test.after(async () => {
|
|
40
|
+
await rimraf(process.cwd());
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('transforms manifest data', async t => {
|
|
44
|
+
t.snapshot(migrationOutput.newManifestsData);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('produces network export data', async t => {
|
|
48
|
+
t.snapshot(migrationOutput.networksExportData);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('deletes project file', async t => {
|
|
52
|
+
const error = await t.throwsAsync(() => fs.access(PROJECT_FILE));
|
|
53
|
+
t.is(error.message, `ENOENT: no such file or directory, access '${PROJECT_FILE}'`);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('export file contains networks and compiler data', async t => {
|
|
57
|
+
const actual = JSON.parse(await fs.readFile(EXPORT_FILE, 'utf8'));
|
|
58
|
+
const expected = {
|
|
59
|
+
networks: migrationOutput.networksExportData,
|
|
60
|
+
compiler: projectData.compiler,
|
|
61
|
+
};
|
|
62
|
+
t.deepEqual(actual, expected);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('zosversion', t => {
|
|
66
|
+
const migratableDataZosVersion = { zosversion: '2.2', ...migratableData };
|
|
67
|
+
delete migratableDataZosVersion.manifestVersion;
|
|
68
|
+
const output = migrateManifestsData({ rinkeby: migratableDataZosVersion });
|
|
69
|
+
t.true(compareVersions(output.newManifestsData.rinkeby.manifestVersion, '3.0', '>='));
|
|
70
|
+
});
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Snapshot report for `src/scripts/migrate-oz-cli-project.test.ts`
|
|
2
|
+
|
|
3
|
+
The actual snapshot is saved in `migrate-oz-cli-project.test.ts.snap`.
|
|
4
|
+
|
|
5
|
+
Generated by [AVA](https://avajs.dev).
|
|
6
|
+
|
|
7
|
+
## transforms manifest data
|
|
8
|
+
|
|
9
|
+
> Snapshot 1
|
|
10
|
+
|
|
11
|
+
{
|
|
12
|
+
rinkeby: {
|
|
13
|
+
admin: {
|
|
14
|
+
address: '0x1750499D05Ed1674d822430FB960d5F6731fDf64',
|
|
15
|
+
},
|
|
16
|
+
impls: {
|
|
17
|
+
'08100f44a71d905a66088b4c5d72f12417a580d454357e06dcc5ad12b3fa2cbc': {
|
|
18
|
+
address: '0xb682dEEf4f8e298d86bFc3e21f50c675151FB974',
|
|
19
|
+
layout: {
|
|
20
|
+
storage: [
|
|
21
|
+
{
|
|
22
|
+
contract: 'Box',
|
|
23
|
+
label: 'value',
|
|
24
|
+
src: 'contracts/Box.sol',
|
|
25
|
+
type: 't_uint256',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
contract: 'Box',
|
|
29
|
+
label: 'flag',
|
|
30
|
+
src: 'contracts/Box.sol',
|
|
31
|
+
type: 't_bool',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
contract: 'Box',
|
|
35
|
+
label: 'map',
|
|
36
|
+
src: 'contracts/Box.sol',
|
|
37
|
+
type: 't_mapping(unknown,t_bool)',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
contract: 'Box',
|
|
41
|
+
label: 'foo',
|
|
42
|
+
src: 'contracts/Box.sol',
|
|
43
|
+
type: 't_struct(MyStruct)3_storage',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
contract: 'Box',
|
|
47
|
+
label: 'myEnum',
|
|
48
|
+
src: 'contracts/Box.sol',
|
|
49
|
+
type: 't_enum(MyEnum)4',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
contract: 'Box',
|
|
53
|
+
label: 'dynArray',
|
|
54
|
+
src: 'contracts/Box.sol',
|
|
55
|
+
type: 't_array(t_uint256)dyn_storage',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
contract: 'Box',
|
|
59
|
+
label: 'staticArray',
|
|
60
|
+
src: 'contracts/Box.sol',
|
|
61
|
+
type: 't_array(t_uint256)10_storage',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
contract: 'Box',
|
|
65
|
+
label: 'enumArray',
|
|
66
|
+
src: 'contracts/Box.sol',
|
|
67
|
+
type: 't_array(t_enum(MyEnum)4)dyn_storage',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
contract: 'Box',
|
|
71
|
+
label: 'byteArray',
|
|
72
|
+
src: 'contracts/Box.sol',
|
|
73
|
+
type: 't_bytes8',
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
types: {
|
|
77
|
+
't_array(t_enum(MyEnum)4)dyn_storage': {
|
|
78
|
+
label: 'MyEnum[]',
|
|
79
|
+
},
|
|
80
|
+
't_array(t_uint256)10_storage': {
|
|
81
|
+
label: 'uint256[10]',
|
|
82
|
+
},
|
|
83
|
+
't_array(t_uint256)dyn_storage': {
|
|
84
|
+
label: 'uint256[]',
|
|
85
|
+
},
|
|
86
|
+
t_bool: {
|
|
87
|
+
label: 'bool',
|
|
88
|
+
},
|
|
89
|
+
t_bytes8: {
|
|
90
|
+
label: 'bytes8',
|
|
91
|
+
},
|
|
92
|
+
't_enum(MyEnum)4': {
|
|
93
|
+
label: 'MyEnum',
|
|
94
|
+
members: [
|
|
95
|
+
'UP',
|
|
96
|
+
'DOWN',
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
't_mapping(unknown,t_bool)': {
|
|
100
|
+
label: 'mapping(key => bool)',
|
|
101
|
+
},
|
|
102
|
+
't_struct(MyStruct)3_storage': {
|
|
103
|
+
label: 'MyStruct',
|
|
104
|
+
members: [
|
|
105
|
+
{
|
|
106
|
+
label: 'x',
|
|
107
|
+
type: 't_bool',
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
t_uint256: {
|
|
112
|
+
label: 'uint256',
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
manifestVersion: '3.2',
|
|
119
|
+
proxies: [
|
|
120
|
+
{
|
|
121
|
+
address: '0xE4C10Db67595aF2Cb4166c8C274e0140f7E43059',
|
|
122
|
+
kind: 'transparent',
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
## produces network export data
|
|
129
|
+
|
|
130
|
+
> Snapshot 1
|
|
131
|
+
|
|
132
|
+
{
|
|
133
|
+
rinkeby: {
|
|
134
|
+
proxies: {
|
|
135
|
+
'my-project/Box': [
|
|
136
|
+
{
|
|
137
|
+
address: '0xE4C10Db67595aF2Cb4166c8C274e0140f7E43059',
|
|
138
|
+
admin: '0x1750499D05Ed1674d822430FB960d5F6731fDf64',
|
|
139
|
+
implementation: '0xb682dEEf4f8e298d86bFc3e21f50c675151FB974',
|
|
140
|
+
kind: 'Upgradeable',
|
|
141
|
+
version: '1.0.0',
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
}
|