@0xsequence/catapult 1.3.17 → 1.5.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/README.md +276 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +1 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +12 -0
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/provenance.d.ts +3 -0
- package/dist/commands/provenance.d.ts.map +1 -0
- package/dist/commands/provenance.js +138 -0
- package/dist/commands/provenance.js.map +1 -0
- package/dist/lib/__tests__/deployer.spec.js +118 -1
- package/dist/lib/__tests__/deployer.spec.js.map +1 -1
- package/dist/lib/__tests__/network-loader.spec.js.map +1 -1
- package/dist/lib/__tests__/provenance.spec.d.ts +2 -0
- package/dist/lib/__tests__/provenance.spec.d.ts.map +1 -0
- package/dist/lib/__tests__/provenance.spec.js +205 -0
- package/dist/lib/__tests__/provenance.spec.js.map +1 -0
- package/dist/lib/contracts/__tests__/repository.spec.js +243 -0
- package/dist/lib/contracts/__tests__/repository.spec.js.map +1 -1
- package/dist/lib/contracts/repository.d.ts +9 -1
- package/dist/lib/contracts/repository.d.ts.map +1 -1
- package/dist/lib/contracts/repository.js +93 -7
- package/dist/lib/contracts/repository.js.map +1 -1
- package/dist/lib/core/__tests__/assert-action.spec.d.ts +2 -0
- package/dist/lib/core/__tests__/assert-action.spec.d.ts.map +1 -0
- package/dist/lib/core/__tests__/assert-action.spec.js +377 -0
- package/dist/lib/core/__tests__/assert-action.spec.js.map +1 -0
- package/dist/lib/core/__tests__/engine.spec.js +80 -0
- package/dist/lib/core/__tests__/engine.spec.js.map +1 -1
- package/dist/lib/core/__tests__/loader.spec.js +29 -0
- package/dist/lib/core/__tests__/loader.spec.js.map +1 -1
- package/dist/lib/core/__tests__/resolver.spec.js +405 -0
- package/dist/lib/core/__tests__/resolver.spec.js.map +1 -1
- package/dist/lib/core/__tests__/sign-actions.spec.d.ts +2 -0
- package/dist/lib/core/__tests__/sign-actions.spec.d.ts.map +1 -0
- package/dist/lib/core/__tests__/sign-actions.spec.js +128 -0
- package/dist/lib/core/__tests__/sign-actions.spec.js.map +1 -0
- package/dist/lib/core/__tests__/signer.spec.d.ts +2 -0
- package/dist/lib/core/__tests__/signer.spec.d.ts.map +1 -0
- package/dist/lib/core/__tests__/signer.spec.js +40 -0
- package/dist/lib/core/__tests__/signer.spec.js.map +1 -0
- package/dist/lib/core/context.d.ts +3 -2
- package/dist/lib/core/context.d.ts.map +1 -1
- package/dist/lib/core/context.js +3 -2
- package/dist/lib/core/context.js.map +1 -1
- package/dist/lib/core/engine.d.ts +4 -0
- package/dist/lib/core/engine.d.ts.map +1 -1
- package/dist/lib/core/engine.js +206 -0
- package/dist/lib/core/engine.js.map +1 -1
- package/dist/lib/core/loader.d.ts +1 -0
- package/dist/lib/core/loader.d.ts.map +1 -1
- package/dist/lib/core/loader.js +6 -1
- package/dist/lib/core/loader.js.map +1 -1
- package/dist/lib/core/resolver.d.ts +2 -0
- package/dist/lib/core/resolver.d.ts.map +1 -1
- package/dist/lib/core/resolver.js +89 -0
- package/dist/lib/core/resolver.js.map +1 -1
- package/dist/lib/core/signer.d.ts +7 -0
- package/dist/lib/core/signer.d.ts.map +1 -0
- package/dist/lib/core/signer.js +60 -0
- package/dist/lib/core/signer.js.map +1 -0
- package/dist/lib/deployer.d.ts.map +1 -1
- package/dist/lib/deployer.js +21 -4
- package/dist/lib/deployer.js.map +1 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +1 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/parsers/__tests__/job.spec.js +77 -0
- package/dist/lib/parsers/__tests__/job.spec.js.map +1 -1
- package/dist/lib/parsers/__tests__/source.spec.d.ts +2 -0
- package/dist/lib/parsers/__tests__/source.spec.d.ts.map +1 -0
- package/dist/lib/parsers/__tests__/source.spec.js +158 -0
- package/dist/lib/parsers/__tests__/source.spec.js.map +1 -0
- package/dist/lib/parsers/index.d.ts +1 -0
- package/dist/lib/parsers/index.d.ts.map +1 -1
- package/dist/lib/parsers/index.js +1 -0
- package/dist/lib/parsers/index.js.map +1 -1
- package/dist/lib/parsers/job.d.ts.map +1 -1
- package/dist/lib/parsers/job.js +11 -0
- package/dist/lib/parsers/job.js.map +1 -1
- package/dist/lib/parsers/source.d.ts +4 -0
- package/dist/lib/parsers/source.d.ts.map +1 -0
- package/dist/lib/parsers/source.js +107 -0
- package/dist/lib/parsers/source.js.map +1 -0
- package/dist/lib/provenance.d.ts +34 -0
- package/dist/lib/provenance.d.ts.map +1 -0
- package/dist/lib/provenance.js +694 -0
- package/dist/lib/provenance.js.map +1 -0
- package/dist/lib/types/actions.d.ts +42 -2
- package/dist/lib/types/actions.d.ts.map +1 -1
- package/dist/lib/types/actions.js +4 -0
- package/dist/lib/types/actions.js.map +1 -1
- package/dist/lib/types/contracts.d.ts +3 -0
- package/dist/lib/types/contracts.d.ts.map +1 -1
- package/dist/lib/types/definitions.d.ts +1 -0
- package/dist/lib/types/definitions.d.ts.map +1 -1
- package/dist/lib/types/index.d.ts +1 -0
- package/dist/lib/types/index.d.ts.map +1 -1
- package/dist/lib/types/index.js +1 -0
- package/dist/lib/types/index.js.map +1 -1
- package/dist/lib/types/source.d.ts +26 -0
- package/dist/lib/types/source.d.ts.map +1 -0
- package/dist/lib/types/source.js +3 -0
- package/dist/lib/types/source.js.map +1 -0
- package/dist/lib/types/values.d.ts +33 -1
- package/dist/lib/types/values.d.ts.map +1 -1
- package/package.json +4 -1
- package/.eslintrc.json +0 -29
- package/.github/workflows/ci.yml +0 -181
- package/CONCEPT.md +0 -24
- package/contracts/checked-call.huff +0 -65
- package/eslint.config.js +0 -48
- package/examples/jobs/guards-v1.yaml +0 -17
- package/examples/jobs/sequence-seq-0001-patch.yaml +0 -59
- package/examples/jobs/sequence-v1.yaml +0 -59
- package/examples/templates/sequence-factory-v1.yaml +0 -56
- package/jest.config.js +0 -25
- package/src/cli.ts +0 -17
- package/src/commands/common.ts +0 -61
- package/src/commands/dry.ts +0 -209
- package/src/commands/etherscan.ts +0 -360
- package/src/commands/index.ts +0 -5
- package/src/commands/list.ts +0 -249
- package/src/commands/run.ts +0 -146
- package/src/commands/utils.ts +0 -215
- package/src/index.ts +0 -67
- package/src/lib/__tests__/deployer-events.spec.ts +0 -338
- package/src/lib/__tests__/deployer.spec.ts +0 -2093
- package/src/lib/__tests__/network-loader.spec.ts +0 -150
- package/src/lib/__tests__/network-selection.spec.ts +0 -41
- package/src/lib/__tests__/network-utils.spec.ts +0 -230
- package/src/lib/artifacts/__tests__/fixtures/contract1.json +0 -19
- package/src/lib/artifacts/__tests__/fixtures/contract2.json +0 -19
- package/src/lib/artifacts/__tests__/fixtures/duplicate-name.json +0 -19
- package/src/lib/artifacts/__tests__/fixtures/nested/nested-contract.json +0 -18
- package/src/lib/artifacts/__tests__/fixtures/not-an-artifact.json +0 -8
- package/src/lib/artifacts/__tests__/fixtures/readme.txt +0 -2
- package/src/lib/contracts/__tests__/repository.spec.ts +0 -344
- package/src/lib/contracts/repository.ts +0 -313
- package/src/lib/core/__tests__/context.spec.ts +0 -37
- package/src/lib/core/__tests__/engine.spec.ts +0 -1889
- package/src/lib/core/__tests__/graph.spec.ts +0 -125
- package/src/lib/core/__tests__/json-integration.spec.ts +0 -425
- package/src/lib/core/__tests__/loader.spec.ts +0 -334
- package/src/lib/core/__tests__/multi-platform-verification.spec.ts +0 -406
- package/src/lib/core/__tests__/resolver.spec.ts +0 -2053
- package/src/lib/core/__tests__/static-action.spec.ts +0 -172
- package/src/lib/core/context.ts +0 -127
- package/src/lib/core/engine.ts +0 -1782
- package/src/lib/core/graph.ts +0 -252
- package/src/lib/core/loader.ts +0 -247
- package/src/lib/core/resolver.ts +0 -757
- package/src/lib/deployer.ts +0 -981
- package/src/lib/events/__tests__/event-system.spec.ts +0 -392
- package/src/lib/events/cli-adapter.ts +0 -369
- package/src/lib/events/emitter.ts +0 -62
- package/src/lib/events/index.ts +0 -3
- package/src/lib/events/types.ts +0 -520
- package/src/lib/index.ts +0 -14
- package/src/lib/network-loader.ts +0 -90
- package/src/lib/network-selection.ts +0 -73
- package/src/lib/network-utils.ts +0 -64
- package/src/lib/parsers/__tests__/buildinfo.spec.ts +0 -122
- package/src/lib/parsers/__tests__/fixtures/buildinfo/invalid-bytecode-buildinfo.json +0 -62
- package/src/lib/parsers/__tests__/fixtures/buildinfo/invalid-json.txt +0 -2
- package/src/lib/parsers/__tests__/fixtures/buildinfo/multi-contract-buildinfo.json +0 -89
- package/src/lib/parsers/__tests__/fixtures/buildinfo/no-contracts-buildinfo.json +0 -17
- package/src/lib/parsers/__tests__/fixtures/buildinfo/simple-buildinfo.json +0 -63
- package/src/lib/parsers/__tests__/fixtures/buildinfo/wrong-format.json +0 -4
- package/src/lib/parsers/__tests__/job.spec.ts +0 -358
- package/src/lib/parsers/__tests__/template.spec.ts +0 -111
- package/src/lib/parsers/artifact/__tests__/artifact.spec.ts +0 -117
- package/src/lib/parsers/artifact/__tests__/fixtures/empty-bytecode.json +0 -5
- package/src/lib/parsers/artifact/__tests__/fixtures/hardhat-artifact.json +0 -67
- package/src/lib/parsers/artifact/__tests__/fixtures/invalid-bytecode.json +0 -5
- package/src/lib/parsers/artifact/__tests__/fixtures/invalid-json.txt +0 -11
- package/src/lib/parsers/artifact/__tests__/fixtures/minimal-artifact.json +0 -5
- package/src/lib/parsers/artifact/__tests__/fixtures/missing-abi.json +0 -4
- package/src/lib/parsers/artifact/__tests__/fixtures/missing-bytecode.json +0 -11
- package/src/lib/parsers/artifact/__tests__/fixtures/missing-contract-name.json +0 -11
- package/src/lib/parsers/artifact/__tests__/fixtures/simple-artifact.json +0 -40
- package/src/lib/parsers/artifact/__tests__/fixtures/wrong-types.json +0 -7
- package/src/lib/parsers/artifact/foundry-1.2.ts +0 -72
- package/src/lib/parsers/artifact/index.ts +0 -27
- package/src/lib/parsers/artifact/types.ts +0 -9
- package/src/lib/parsers/buildinfo.ts +0 -127
- package/src/lib/parsers/constants.ts +0 -56
- package/src/lib/parsers/index.ts +0 -5
- package/src/lib/parsers/job.ts +0 -148
- package/src/lib/parsers/template.ts +0 -135
- package/src/lib/std/templates/arachnid-deterministic-deployment-proxy.yaml +0 -68
- package/src/lib/std/templates/assured-deployment.yaml +0 -46
- package/src/lib/std/templates/era-evm-predeploy.yaml +0 -35
- package/src/lib/std/templates/erc-2470.yaml +0 -70
- package/src/lib/std/templates/min-balance.yaml +0 -35
- package/src/lib/std/templates/nano-universal-deployer.yaml +0 -61
- package/src/lib/std/templates/raw-erc-2470.yaml +0 -62
- package/src/lib/std/templates/raw-nano-universal-deployer.yaml +0 -54
- package/src/lib/std/templates/raw-sequence-universal-deployer-2.yaml +0 -52
- package/src/lib/std/templates/sequence-universal-deployer-2.yaml +0 -61
- package/src/lib/types/__tests__/json-request-action.spec.ts +0 -243
- package/src/lib/types/__tests__/read-json-value.spec.ts +0 -278
- package/src/lib/types/__tests__/resolve-json-value.spec.ts +0 -769
- package/src/lib/types/actions.ts +0 -127
- package/src/lib/types/artifacts.ts +0 -21
- package/src/lib/types/buildinfo.ts +0 -116
- package/src/lib/types/conditions.ts +0 -50
- package/src/lib/types/contracts.ts +0 -23
- package/src/lib/types/definitions.ts +0 -70
- package/src/lib/types/index.ts +0 -8
- package/src/lib/types/network.ts +0 -33
- package/src/lib/types/project.ts +0 -9
- package/src/lib/types/task.ts +0 -9
- package/src/lib/types/values.ts +0 -150
- package/src/lib/utils/assertion.ts +0 -24
- package/src/lib/utils/validation.ts +0 -116
- package/src/lib/validation/contract-references.ts +0 -210
- package/src/lib/validation/index.ts +0 -1
- package/src/lib/verification/__tests__/etherscan.spec.ts +0 -710
- package/src/lib/verification/__tests__/sourcify.spec.ts +0 -288
- package/src/lib/verification/etherscan.ts +0 -547
- package/src/lib/verification/sourcify.ts +0 -248
- package/test_validation/artifacts/TestContract.json +0 -9
- package/test_validation/jobs/test-missing.yaml +0 -16
- package/test_validation/networks.yaml +0 -3
- package/tsconfig.json +0 -36
|
@@ -20,6 +20,16 @@ describe('ValueResolver', () => {
|
|
|
20
20
|
supports: ["sourcify", "etherscan_v2"],
|
|
21
21
|
gasLimit: 10000000,
|
|
22
22
|
evmVersion: 'cancun',
|
|
23
|
+
params: {
|
|
24
|
+
dataSource: {
|
|
25
|
+
endpoint: 'https://api.example.com/data',
|
|
26
|
+
domain: {
|
|
27
|
+
name: 'Example',
|
|
28
|
+
version: '1',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
blockMode: 'small',
|
|
32
|
+
},
|
|
23
33
|
};
|
|
24
34
|
const mockPrivateKey = '0x0000000000000000000000000000000000000000000000000000000000000001';
|
|
25
35
|
context = new context_1.ExecutionContext(mockNetwork, mockPrivateKey, mockRegistry);
|
|
@@ -1298,6 +1308,14 @@ describe('ValueResolver', () => {
|
|
|
1298
1308
|
const result = await resolver.resolve('{{Network().evmVersion}}', context);
|
|
1299
1309
|
expect(result).toBe(mockNetwork.evmVersion);
|
|
1300
1310
|
});
|
|
1311
|
+
it('should return params metadata object for valid network', async () => {
|
|
1312
|
+
const result = await resolver.resolve('{{Network().params}}', context);
|
|
1313
|
+
expect(result).toEqual(mockNetwork.params);
|
|
1314
|
+
});
|
|
1315
|
+
it('should resolve nested params metadata path', async () => {
|
|
1316
|
+
const result = await resolver.resolve('{{Network().params.dataSource.endpoint}}', context);
|
|
1317
|
+
expect(result).toBe('https://api.example.com/data');
|
|
1318
|
+
});
|
|
1301
1319
|
});
|
|
1302
1320
|
describe('Network().params dotted paths', () => {
|
|
1303
1321
|
const mockPrivateKey = '0x0000000000000000000000000000000000000000000000000000000000000001';
|
|
@@ -1348,6 +1366,10 @@ describe('ValueResolver', () => {
|
|
|
1348
1366
|
await expect(resolver.resolve('{{Network().undefined}}', context))
|
|
1349
1367
|
.rejects.toThrow('Property "undefined" does not exist on network');
|
|
1350
1368
|
});
|
|
1369
|
+
it('should default missing nested property to false', async () => {
|
|
1370
|
+
const result = await resolver.resolve('{{Network().params.missing}}', context);
|
|
1371
|
+
expect(result).toBe(false);
|
|
1372
|
+
});
|
|
1351
1373
|
it('should fail for network with reference', async () => {
|
|
1352
1374
|
await expect(resolver.resolve('{{Network(testnet).name}}', context))
|
|
1353
1375
|
.rejects.toThrow('Failed to resolve expression \"{{Network(testnet).name}}\". It is not a valid Contract(...) or Network() reference, local scope variable, constant, or a known output.');
|
|
@@ -1678,5 +1700,388 @@ describe('ValueResolver', () => {
|
|
|
1678
1700
|
expect(result).toBe('0x010203');
|
|
1679
1701
|
});
|
|
1680
1702
|
});
|
|
1703
|
+
describe('get-storage-at', () => {
|
|
1704
|
+
const testAddress = '0x1234567890123456789012345678901234567890';
|
|
1705
|
+
const testSlot = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
|
1706
|
+
const testSlotNumber = 0;
|
|
1707
|
+
const expectedStorageValue = '0x0000000000000000000000000000000000000000000000000000000000000001';
|
|
1708
|
+
let anvilProvider;
|
|
1709
|
+
beforeEach(async () => {
|
|
1710
|
+
anvilProvider = context.provider;
|
|
1711
|
+
});
|
|
1712
|
+
it('should read storage slot with hex string slot', async () => {
|
|
1713
|
+
await anvilProvider.send('anvil_setStorageAt', [testAddress, testSlot, expectedStorageValue]);
|
|
1714
|
+
const value = {
|
|
1715
|
+
type: 'get-storage-at',
|
|
1716
|
+
arguments: {
|
|
1717
|
+
address: testAddress,
|
|
1718
|
+
slot: testSlot
|
|
1719
|
+
},
|
|
1720
|
+
};
|
|
1721
|
+
const result = await resolver.resolve(value, context);
|
|
1722
|
+
expect(result).toBe(expectedStorageValue);
|
|
1723
|
+
});
|
|
1724
|
+
it('should read storage slot with numeric slot', async () => {
|
|
1725
|
+
await anvilProvider.send('anvil_setStorageAt', [testAddress, testSlot, expectedStorageValue]);
|
|
1726
|
+
const value = {
|
|
1727
|
+
type: 'get-storage-at',
|
|
1728
|
+
arguments: {
|
|
1729
|
+
address: testAddress,
|
|
1730
|
+
slot: testSlotNumber
|
|
1731
|
+
},
|
|
1732
|
+
};
|
|
1733
|
+
const result = await resolver.resolve(value, context);
|
|
1734
|
+
expect(result).toBe(expectedStorageValue);
|
|
1735
|
+
});
|
|
1736
|
+
it('should read storage slot with string number slot', async () => {
|
|
1737
|
+
await anvilProvider.send('anvil_setStorageAt', [testAddress, testSlot, expectedStorageValue]);
|
|
1738
|
+
const value = {
|
|
1739
|
+
type: 'get-storage-at',
|
|
1740
|
+
arguments: {
|
|
1741
|
+
address: testAddress,
|
|
1742
|
+
slot: '0'
|
|
1743
|
+
},
|
|
1744
|
+
};
|
|
1745
|
+
const result = await resolver.resolve(value, context);
|
|
1746
|
+
expect(result).toBe(expectedStorageValue);
|
|
1747
|
+
});
|
|
1748
|
+
it('should read different storage slots', async () => {
|
|
1749
|
+
const slot1 = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
|
1750
|
+
const slot2 = '0x0000000000000000000000000000000000000000000000000000000000000001';
|
|
1751
|
+
const value1 = '0x00000000000000000000000000000000000000000000000000000000000000aa';
|
|
1752
|
+
const value2 = '0x00000000000000000000000000000000000000000000000000000000000000bb';
|
|
1753
|
+
await anvilProvider.send('anvil_setStorageAt', [testAddress, slot1, value1]);
|
|
1754
|
+
await anvilProvider.send('anvil_setStorageAt', [testAddress, slot2, value2]);
|
|
1755
|
+
const valueForSlot1 = {
|
|
1756
|
+
type: 'get-storage-at',
|
|
1757
|
+
arguments: {
|
|
1758
|
+
address: testAddress,
|
|
1759
|
+
slot: slot1
|
|
1760
|
+
},
|
|
1761
|
+
};
|
|
1762
|
+
const valueForSlot2 = {
|
|
1763
|
+
type: 'get-storage-at',
|
|
1764
|
+
arguments: {
|
|
1765
|
+
address: testAddress,
|
|
1766
|
+
slot: slot2
|
|
1767
|
+
},
|
|
1768
|
+
};
|
|
1769
|
+
const result1 = await resolver.resolve(valueForSlot1, context);
|
|
1770
|
+
const result2 = await resolver.resolve(valueForSlot2, context);
|
|
1771
|
+
expect(result1).toBe(value1);
|
|
1772
|
+
expect(result2).toBe(value2);
|
|
1773
|
+
});
|
|
1774
|
+
it('should resolve address from context variable', async () => {
|
|
1775
|
+
context.setOutput('myAddress', testAddress);
|
|
1776
|
+
await anvilProvider.send('anvil_setStorageAt', [testAddress, testSlot, expectedStorageValue]);
|
|
1777
|
+
const value = {
|
|
1778
|
+
type: 'get-storage-at',
|
|
1779
|
+
arguments: {
|
|
1780
|
+
address: '{{myAddress}}',
|
|
1781
|
+
slot: testSlot
|
|
1782
|
+
},
|
|
1783
|
+
};
|
|
1784
|
+
const result = await resolver.resolve(value, context);
|
|
1785
|
+
expect(result).toBe(expectedStorageValue);
|
|
1786
|
+
});
|
|
1787
|
+
it('should resolve slot from context variable', async () => {
|
|
1788
|
+
context.setOutput('mySlot', testSlot);
|
|
1789
|
+
await anvilProvider.send('anvil_setStorageAt', [testAddress, testSlot, expectedStorageValue]);
|
|
1790
|
+
const value = {
|
|
1791
|
+
type: 'get-storage-at',
|
|
1792
|
+
arguments: {
|
|
1793
|
+
address: testAddress,
|
|
1794
|
+
slot: '{{mySlot}}'
|
|
1795
|
+
},
|
|
1796
|
+
};
|
|
1797
|
+
const result = await resolver.resolve(value, context);
|
|
1798
|
+
expect(result).toBe(expectedStorageValue);
|
|
1799
|
+
});
|
|
1800
|
+
it('should return zero storage for non-existent slot', async () => {
|
|
1801
|
+
const nonExistentSlot = '0x000000000000000000000000000000000000000000000000000000000000ffff';
|
|
1802
|
+
const value = {
|
|
1803
|
+
type: 'get-storage-at',
|
|
1804
|
+
arguments: {
|
|
1805
|
+
address: testAddress,
|
|
1806
|
+
slot: nonExistentSlot
|
|
1807
|
+
},
|
|
1808
|
+
};
|
|
1809
|
+
const result = await resolver.resolve(value, context);
|
|
1810
|
+
expect(result).toBe('0x0000000000000000000000000000000000000000000000000000000000000000');
|
|
1811
|
+
});
|
|
1812
|
+
it('should throw error for invalid address', async () => {
|
|
1813
|
+
const value = {
|
|
1814
|
+
type: 'get-storage-at',
|
|
1815
|
+
arguments: {
|
|
1816
|
+
address: 'invalid-address',
|
|
1817
|
+
slot: testSlot
|
|
1818
|
+
},
|
|
1819
|
+
};
|
|
1820
|
+
await expect(resolver.resolve(value, context)).rejects.toThrow('Invalid address: invalid-address');
|
|
1821
|
+
});
|
|
1822
|
+
it('should throw error for null address', async () => {
|
|
1823
|
+
const value = {
|
|
1824
|
+
type: 'get-storage-at',
|
|
1825
|
+
arguments: {
|
|
1826
|
+
address: null,
|
|
1827
|
+
slot: testSlot
|
|
1828
|
+
},
|
|
1829
|
+
};
|
|
1830
|
+
await expect(resolver.resolve(value, context)).rejects.toThrow('Invalid address: null');
|
|
1831
|
+
});
|
|
1832
|
+
it('should throw error for undefined address', async () => {
|
|
1833
|
+
const value = {
|
|
1834
|
+
type: 'get-storage-at',
|
|
1835
|
+
arguments: {
|
|
1836
|
+
address: undefined,
|
|
1837
|
+
slot: testSlot
|
|
1838
|
+
},
|
|
1839
|
+
};
|
|
1840
|
+
await expect(resolver.resolve(value, context)).rejects.toThrow('Invalid address: undefined');
|
|
1841
|
+
});
|
|
1842
|
+
it('should handle checksummed addresses', async () => {
|
|
1843
|
+
const checksummedAddress = '0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed';
|
|
1844
|
+
await anvilProvider.send('anvil_setStorageAt', [checksummedAddress, testSlot, expectedStorageValue]);
|
|
1845
|
+
const value = {
|
|
1846
|
+
type: 'get-storage-at',
|
|
1847
|
+
arguments: {
|
|
1848
|
+
address: checksummedAddress,
|
|
1849
|
+
slot: testSlot
|
|
1850
|
+
},
|
|
1851
|
+
};
|
|
1852
|
+
const result = await resolver.resolve(value, context);
|
|
1853
|
+
expect(result).toBe(expectedStorageValue);
|
|
1854
|
+
});
|
|
1855
|
+
it('should handle lowercase addresses', async () => {
|
|
1856
|
+
const lowercaseAddress = testAddress.toLowerCase();
|
|
1857
|
+
await anvilProvider.send('anvil_setStorageAt', [lowercaseAddress, testSlot, expectedStorageValue]);
|
|
1858
|
+
const value = {
|
|
1859
|
+
type: 'get-storage-at',
|
|
1860
|
+
arguments: {
|
|
1861
|
+
address: lowercaseAddress,
|
|
1862
|
+
slot: testSlot
|
|
1863
|
+
},
|
|
1864
|
+
};
|
|
1865
|
+
const result = await resolver.resolve(value, context);
|
|
1866
|
+
expect(result).toBe(expectedStorageValue);
|
|
1867
|
+
});
|
|
1868
|
+
it('should handle large slot numbers', async () => {
|
|
1869
|
+
const eip1967Slot = '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc';
|
|
1870
|
+
await anvilProvider.send('anvil_setStorageAt', [testAddress, eip1967Slot, expectedStorageValue]);
|
|
1871
|
+
const value = {
|
|
1872
|
+
type: 'get-storage-at',
|
|
1873
|
+
arguments: {
|
|
1874
|
+
address: testAddress,
|
|
1875
|
+
slot: eip1967Slot
|
|
1876
|
+
},
|
|
1877
|
+
};
|
|
1878
|
+
const result = await resolver.resolve(value, context);
|
|
1879
|
+
expect(result).toBe(expectedStorageValue);
|
|
1880
|
+
});
|
|
1881
|
+
});
|
|
1882
|
+
describe('compute-slot', () => {
|
|
1883
|
+
describe('mapping', () => {
|
|
1884
|
+
it('should compute a mapping value slot with an address key', async () => {
|
|
1885
|
+
const value = {
|
|
1886
|
+
type: 'compute-slot',
|
|
1887
|
+
arguments: {
|
|
1888
|
+
kind: 'mapping',
|
|
1889
|
+
slot: 2,
|
|
1890
|
+
key: '0x1111111111111111111111111111111111111111',
|
|
1891
|
+
keyType: 'address',
|
|
1892
|
+
},
|
|
1893
|
+
};
|
|
1894
|
+
const result = await resolver.resolve(value, context);
|
|
1895
|
+
expect(result).toBe('0x06bb1b9bc4293ba066a12274418b7ea4df183c2e4e6b39591987369520ca3956');
|
|
1896
|
+
});
|
|
1897
|
+
it('should default keyType to uint256', async () => {
|
|
1898
|
+
const value = {
|
|
1899
|
+
type: 'compute-slot',
|
|
1900
|
+
arguments: {
|
|
1901
|
+
kind: 'mapping',
|
|
1902
|
+
slot: 1,
|
|
1903
|
+
key: 5,
|
|
1904
|
+
},
|
|
1905
|
+
};
|
|
1906
|
+
const result = await resolver.resolve(value, context);
|
|
1907
|
+
expect(result).toBe('0xe2689cd4a84e23ad2f564004f1c9013e9589d260bde6380aba3ca7e09e4df40c');
|
|
1908
|
+
});
|
|
1909
|
+
it('should pack dynamic (string) keys', async () => {
|
|
1910
|
+
const value = {
|
|
1911
|
+
type: 'compute-slot',
|
|
1912
|
+
arguments: {
|
|
1913
|
+
kind: 'mapping',
|
|
1914
|
+
slot: 7,
|
|
1915
|
+
key: 'hello',
|
|
1916
|
+
keyType: 'string',
|
|
1917
|
+
},
|
|
1918
|
+
};
|
|
1919
|
+
const result = await resolver.resolve(value, context);
|
|
1920
|
+
expect(result).toBe('0xa39e328cf6237afe41b514c6c18ccdc6b503f43ce841d4b5bca5e763723b44a9');
|
|
1921
|
+
});
|
|
1922
|
+
it('should support nesting for nested mappings', async () => {
|
|
1923
|
+
const value = {
|
|
1924
|
+
type: 'compute-slot',
|
|
1925
|
+
arguments: {
|
|
1926
|
+
kind: 'mapping',
|
|
1927
|
+
key: '0x2222222222222222222222222222222222222222',
|
|
1928
|
+
keyType: 'address',
|
|
1929
|
+
slot: {
|
|
1930
|
+
type: 'compute-slot',
|
|
1931
|
+
arguments: {
|
|
1932
|
+
kind: 'mapping',
|
|
1933
|
+
slot: 0,
|
|
1934
|
+
key: '0x1111111111111111111111111111111111111111',
|
|
1935
|
+
keyType: 'address',
|
|
1936
|
+
},
|
|
1937
|
+
},
|
|
1938
|
+
},
|
|
1939
|
+
};
|
|
1940
|
+
const result = await resolver.resolve(value, context);
|
|
1941
|
+
expect(result).toBe('0xd1360c905f62126f789549525bc3219e0fb5feba645fd0705768a3cc3bf3fc5c');
|
|
1942
|
+
});
|
|
1943
|
+
it('should resolve references in arguments', async () => {
|
|
1944
|
+
context.setOutput('mapSlot', 2);
|
|
1945
|
+
context.setOutput('owner', '0x1111111111111111111111111111111111111111');
|
|
1946
|
+
const value = {
|
|
1947
|
+
type: 'compute-slot',
|
|
1948
|
+
arguments: {
|
|
1949
|
+
kind: 'mapping',
|
|
1950
|
+
slot: '{{mapSlot}}',
|
|
1951
|
+
key: '{{owner}}',
|
|
1952
|
+
keyType: 'address',
|
|
1953
|
+
},
|
|
1954
|
+
};
|
|
1955
|
+
const result = await resolver.resolve(value, context);
|
|
1956
|
+
expect(result).toBe('0x06bb1b9bc4293ba066a12274418b7ea4df183c2e4e6b39591987369520ca3956');
|
|
1957
|
+
});
|
|
1958
|
+
it('should throw when key is missing', async () => {
|
|
1959
|
+
const value = {
|
|
1960
|
+
type: 'compute-slot',
|
|
1961
|
+
arguments: { kind: 'mapping', slot: 0 },
|
|
1962
|
+
};
|
|
1963
|
+
await expect(resolver.resolve(value, context)).rejects.toThrow('compute-slot (mapping): "key" is required');
|
|
1964
|
+
});
|
|
1965
|
+
});
|
|
1966
|
+
describe('dynamic-array', () => {
|
|
1967
|
+
it('should compute an element slot', async () => {
|
|
1968
|
+
const value = {
|
|
1969
|
+
type: 'compute-slot',
|
|
1970
|
+
arguments: { kind: 'dynamic-array', slot: 3, index: 4 },
|
|
1971
|
+
};
|
|
1972
|
+
const result = await resolver.resolve(value, context);
|
|
1973
|
+
expect(result).toBe('0xc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85f');
|
|
1974
|
+
});
|
|
1975
|
+
it('should default index to 0', async () => {
|
|
1976
|
+
const value = {
|
|
1977
|
+
type: 'compute-slot',
|
|
1978
|
+
arguments: { kind: 'dynamic-array', slot: 3 },
|
|
1979
|
+
};
|
|
1980
|
+
const result = await resolver.resolve(value, context);
|
|
1981
|
+
expect(result).toBe(ethers_1.ethers.keccak256(ethers_1.ethers.toBeHex(3, 32)));
|
|
1982
|
+
});
|
|
1983
|
+
it('should account for multi-slot elements via elementSize', async () => {
|
|
1984
|
+
const value = {
|
|
1985
|
+
type: 'compute-slot',
|
|
1986
|
+
arguments: { kind: 'dynamic-array', slot: 3, index: 1, elementSize: 2 },
|
|
1987
|
+
};
|
|
1988
|
+
const result = await resolver.resolve(value, context);
|
|
1989
|
+
expect(result).toBe('0xc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85d');
|
|
1990
|
+
});
|
|
1991
|
+
});
|
|
1992
|
+
describe('struct-field', () => {
|
|
1993
|
+
it('should add the field offset to the base slot', async () => {
|
|
1994
|
+
const value = {
|
|
1995
|
+
type: 'compute-slot',
|
|
1996
|
+
arguments: { kind: 'struct-field', slot: 100, offset: 3 },
|
|
1997
|
+
};
|
|
1998
|
+
const result = await resolver.resolve(value, context);
|
|
1999
|
+
expect(result).toBe('0x0000000000000000000000000000000000000000000000000000000000000067');
|
|
2000
|
+
});
|
|
2001
|
+
it('should throw when offset is missing', async () => {
|
|
2002
|
+
const value = {
|
|
2003
|
+
type: 'compute-slot',
|
|
2004
|
+
arguments: { kind: 'struct-field', slot: 1 },
|
|
2005
|
+
};
|
|
2006
|
+
await expect(resolver.resolve(value, context)).rejects.toThrow('compute-slot (struct-field): "offset" is required');
|
|
2007
|
+
});
|
|
2008
|
+
});
|
|
2009
|
+
describe('erc7201', () => {
|
|
2010
|
+
it('should compute the namespaced root for the EIP-7201 example', async () => {
|
|
2011
|
+
const value = {
|
|
2012
|
+
type: 'compute-slot',
|
|
2013
|
+
arguments: { kind: 'erc7201', id: 'example.main' },
|
|
2014
|
+
};
|
|
2015
|
+
const result = await resolver.resolve(value, context);
|
|
2016
|
+
expect(result).toBe('0x183a6125c38840424c4a85fa12bab2ab606c4b6d0e7cc73c0c06ba5300eab500');
|
|
2017
|
+
});
|
|
2018
|
+
it('should match OpenZeppelin Ownable namespace', async () => {
|
|
2019
|
+
const value = {
|
|
2020
|
+
type: 'compute-slot',
|
|
2021
|
+
arguments: { kind: 'erc7201', id: 'openzeppelin.storage.Ownable' },
|
|
2022
|
+
};
|
|
2023
|
+
const result = await resolver.resolve(value, context);
|
|
2024
|
+
expect(result).toBe('0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300');
|
|
2025
|
+
});
|
|
2026
|
+
it('should throw on empty id', async () => {
|
|
2027
|
+
const value = {
|
|
2028
|
+
type: 'compute-slot',
|
|
2029
|
+
arguments: { kind: 'erc7201', id: '' },
|
|
2030
|
+
};
|
|
2031
|
+
await expect(resolver.resolve(value, context)).rejects.toThrow('compute-slot (erc7201): "id" must be a non-empty string');
|
|
2032
|
+
});
|
|
2033
|
+
});
|
|
2034
|
+
describe('eip1967', () => {
|
|
2035
|
+
it('should compute the implementation slot', async () => {
|
|
2036
|
+
const value = {
|
|
2037
|
+
type: 'compute-slot',
|
|
2038
|
+
arguments: { kind: 'eip1967', name: 'implementation' },
|
|
2039
|
+
};
|
|
2040
|
+
const result = await resolver.resolve(value, context);
|
|
2041
|
+
expect(result).toBe('0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc');
|
|
2042
|
+
});
|
|
2043
|
+
it('should compute the admin slot', async () => {
|
|
2044
|
+
const value = {
|
|
2045
|
+
type: 'compute-slot',
|
|
2046
|
+
arguments: { kind: 'eip1967', name: 'admin' },
|
|
2047
|
+
};
|
|
2048
|
+
const result = await resolver.resolve(value, context);
|
|
2049
|
+
expect(result).toBe('0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103');
|
|
2050
|
+
});
|
|
2051
|
+
it('should compute the beacon slot', async () => {
|
|
2052
|
+
const value = {
|
|
2053
|
+
type: 'compute-slot',
|
|
2054
|
+
arguments: { kind: 'eip1967', name: 'beacon' },
|
|
2055
|
+
};
|
|
2056
|
+
const result = await resolver.resolve(value, context);
|
|
2057
|
+
expect(result).toBe('0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50');
|
|
2058
|
+
});
|
|
2059
|
+
it('should throw on unknown name', async () => {
|
|
2060
|
+
const value = {
|
|
2061
|
+
type: 'compute-slot',
|
|
2062
|
+
arguments: { kind: 'eip1967', name: 'nope' },
|
|
2063
|
+
};
|
|
2064
|
+
await expect(resolver.resolve(value, context)).rejects.toThrow('compute-slot (eip1967): "name" must be one of');
|
|
2065
|
+
});
|
|
2066
|
+
});
|
|
2067
|
+
it('should chain into get-storage-at as the slot argument', async () => {
|
|
2068
|
+
const computed = await resolver.resolve({
|
|
2069
|
+
type: 'compute-slot',
|
|
2070
|
+
arguments: { kind: 'eip1967', name: 'implementation' },
|
|
2071
|
+
}, context);
|
|
2072
|
+
expect(computed).toBe('0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc');
|
|
2073
|
+
});
|
|
2074
|
+
it('should throw when kind is missing', async () => {
|
|
2075
|
+
const value = { type: 'compute-slot', arguments: {} };
|
|
2076
|
+
await expect(resolver.resolve(value, context)).rejects.toThrow('compute-slot: "kind" is required');
|
|
2077
|
+
});
|
|
2078
|
+
it('should throw on unknown kind', async () => {
|
|
2079
|
+
const value = {
|
|
2080
|
+
type: 'compute-slot',
|
|
2081
|
+
arguments: { kind: 'bogus' },
|
|
2082
|
+
};
|
|
2083
|
+
await expect(resolver.resolve(value, context)).rejects.toThrow('compute-slot: unknown kind "bogus"');
|
|
2084
|
+
});
|
|
2085
|
+
});
|
|
1681
2086
|
});
|
|
1682
2087
|
//# sourceMappingURL=resolver.spec.js.map
|