@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
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import { Network } from '../../types/network'
|
|
2
|
-
import { SourcifyVerificationPlatform } from '../sourcify'
|
|
3
|
-
|
|
4
|
-
// Mock fetch globally
|
|
5
|
-
const mockFetch = jest.fn()
|
|
6
|
-
global.fetch = mockFetch as any
|
|
7
|
-
|
|
8
|
-
describe('Sourcify Verification Platform', () => {
|
|
9
|
-
let platform: SourcifyVerificationPlatform
|
|
10
|
-
let mockNetwork: Network
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
platform = new SourcifyVerificationPlatform()
|
|
14
|
-
mockNetwork = {
|
|
15
|
-
name: 'Ethereum Mainnet',
|
|
16
|
-
chainId: 1,
|
|
17
|
-
rpcUrl: 'https://mainnet.infura.io/v3/test'
|
|
18
|
-
}
|
|
19
|
-
jest.clearAllMocks()
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
describe('platform properties', () => {
|
|
23
|
-
it('should have correct name', () => {
|
|
24
|
-
expect(platform.name).toBe('sourcify')
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
it('should not support networks by default when supports is undefined', () => {
|
|
28
|
-
expect(platform.supportsNetwork(mockNetwork)).toBe(false)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it('should respect network supports configuration', () => {
|
|
32
|
-
const restrictedNetwork: Network = {
|
|
33
|
-
name: 'Custom Network',
|
|
34
|
-
chainId: 999,
|
|
35
|
-
rpcUrl: 'https://custom.rpc',
|
|
36
|
-
supports: ['etherscan_v2'] // Only supports etherscan
|
|
37
|
-
}
|
|
38
|
-
expect(platform.supportsNetwork(restrictedNetwork)).toBe(false)
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('should be configured by default', () => {
|
|
42
|
-
expect(platform.isConfigured()).toBe(true)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('should have no configuration requirements', () => {
|
|
46
|
-
expect(platform.getConfigurationRequirements()).toBe('Sourcify requires no configuration')
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
describe('isContractAlreadyVerified', () => {
|
|
51
|
-
it('should return true for verified contract', async () => {
|
|
52
|
-
const mockResponse = [{
|
|
53
|
-
address: '0x1234567890123456789012345678901234567890',
|
|
54
|
-
chainId: '1',
|
|
55
|
-
status: 'perfect'
|
|
56
|
-
}]
|
|
57
|
-
|
|
58
|
-
mockFetch.mockResolvedValueOnce({
|
|
59
|
-
ok: true,
|
|
60
|
-
json: jest.fn().mockResolvedValue(mockResponse)
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
const result = await platform.isContractAlreadyVerified(
|
|
64
|
-
'0x1234567890123456789012345678901234567890',
|
|
65
|
-
mockNetwork
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
expect(result).toBe(true)
|
|
69
|
-
expect(mockFetch).toHaveBeenCalledWith(
|
|
70
|
-
'https://sourcify.dev/server/check-by-addresses?addresses=0x1234567890123456789012345678901234567890&chainIds=1',
|
|
71
|
-
expect.objectContaining({
|
|
72
|
-
method: 'GET',
|
|
73
|
-
signal: expect.any(AbortSignal)
|
|
74
|
-
})
|
|
75
|
-
)
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
it('should return false for non-verified contract', async () => {
|
|
79
|
-
const mockResponse: any[] = []
|
|
80
|
-
|
|
81
|
-
mockFetch.mockResolvedValueOnce({
|
|
82
|
-
ok: true,
|
|
83
|
-
json: jest.fn().mockResolvedValue(mockResponse)
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
const result = await platform.isContractAlreadyVerified(
|
|
87
|
-
'0x1234567890123456789012345678901234567890',
|
|
88
|
-
mockNetwork
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
expect(result).toBe(false)
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
it('should handle network errors gracefully', async () => {
|
|
95
|
-
mockFetch.mockRejectedValueOnce(new Error('Network error'))
|
|
96
|
-
|
|
97
|
-
const result = await platform.isContractAlreadyVerified(
|
|
98
|
-
'0x1234567890123456789012345678901234567890',
|
|
99
|
-
mockNetwork
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
expect(result).toBe(false)
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
it('should handle HTTP errors gracefully', async () => {
|
|
106
|
-
mockFetch.mockResolvedValueOnce({
|
|
107
|
-
ok: false,
|
|
108
|
-
status: 500,
|
|
109
|
-
statusText: 'Internal Server Error'
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
const result = await platform.isContractAlreadyVerified(
|
|
113
|
-
'0x1234567890123456789012345678901234567890',
|
|
114
|
-
mockNetwork
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
expect(result).toBe(false)
|
|
118
|
-
})
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
describe('verifyContract', () => {
|
|
122
|
-
let mockRequest: any
|
|
123
|
-
|
|
124
|
-
beforeEach(() => {
|
|
125
|
-
mockRequest = {
|
|
126
|
-
address: '0x1234567890123456789012345678901234567890',
|
|
127
|
-
contract: {
|
|
128
|
-
uniqueHash: 'test-hash',
|
|
129
|
-
creationCode: '0x608060405234801561001057600080fd5b50',
|
|
130
|
-
sourceName: 'contracts/MyToken.sol',
|
|
131
|
-
contractName: 'MyToken',
|
|
132
|
-
buildInfoId: 'test-build-info',
|
|
133
|
-
compiler: { version: '0.8.19' },
|
|
134
|
-
_sources: new Set(['contracts/MyToken.sol', '/path/to/build-info/test.json'])
|
|
135
|
-
},
|
|
136
|
-
buildInfo: {
|
|
137
|
-
_format: 'hh-sol-build-info-1' as const,
|
|
138
|
-
id: 'test-id',
|
|
139
|
-
solcVersion: '0.8.19',
|
|
140
|
-
solcLongVersion: '0.8.19+commit.7dd6d404',
|
|
141
|
-
input: {
|
|
142
|
-
language: 'Solidity',
|
|
143
|
-
sources: {
|
|
144
|
-
'contracts/MyToken.sol': {
|
|
145
|
-
content: 'contract MyToken { }'
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
settings: {
|
|
149
|
-
optimizer: { enabled: true, runs: 200 },
|
|
150
|
-
outputSelection: { '*': { '*': ['*'] } }
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
output: {
|
|
154
|
-
contracts: {},
|
|
155
|
-
sources: {}
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
network: mockNetwork
|
|
159
|
-
}
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
it('should return already verified if contract is verified', async () => {
|
|
163
|
-
// Mock already verified check
|
|
164
|
-
mockFetch.mockResolvedValueOnce({
|
|
165
|
-
ok: true,
|
|
166
|
-
json: jest.fn().mockResolvedValue([{
|
|
167
|
-
address: '0x1234567890123456789012345678901234567890',
|
|
168
|
-
chainId: '1',
|
|
169
|
-
status: 'perfect'
|
|
170
|
-
}])
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
const result = await platform.verifyContract(mockRequest)
|
|
174
|
-
|
|
175
|
-
expect(result.success).toBe(true)
|
|
176
|
-
expect(result.isAlreadyVerified).toBe(true)
|
|
177
|
-
expect(result.message).toContain('already verified')
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
it('should submit verification successfully', async () => {
|
|
181
|
-
// Mock not verified check
|
|
182
|
-
mockFetch.mockResolvedValueOnce({
|
|
183
|
-
ok: true,
|
|
184
|
-
json: jest.fn().mockResolvedValue([])
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
// Mock successful verification
|
|
188
|
-
mockFetch.mockResolvedValueOnce({
|
|
189
|
-
ok: true,
|
|
190
|
-
json: jest.fn().mockResolvedValue({
|
|
191
|
-
status: 'perfect'
|
|
192
|
-
})
|
|
193
|
-
})
|
|
194
|
-
|
|
195
|
-
const result = await platform.verifyContract(mockRequest)
|
|
196
|
-
|
|
197
|
-
expect(result.success).toBe(true)
|
|
198
|
-
expect(result.message).toContain('verified successfully')
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
it('should handle verification failure', async () => {
|
|
202
|
-
// Mock not verified check
|
|
203
|
-
mockFetch.mockResolvedValueOnce({
|
|
204
|
-
ok: true,
|
|
205
|
-
json: jest.fn().mockResolvedValue([])
|
|
206
|
-
})
|
|
207
|
-
|
|
208
|
-
// Mock failed verification
|
|
209
|
-
mockFetch.mockResolvedValueOnce({
|
|
210
|
-
ok: true,
|
|
211
|
-
json: jest.fn().mockResolvedValue({
|
|
212
|
-
status: 'error',
|
|
213
|
-
message: 'Compilation failed'
|
|
214
|
-
})
|
|
215
|
-
})
|
|
216
|
-
|
|
217
|
-
const result = await platform.verifyContract(mockRequest)
|
|
218
|
-
|
|
219
|
-
expect(result.success).toBe(false)
|
|
220
|
-
expect(result.message).toContain('Compilation failed')
|
|
221
|
-
})
|
|
222
|
-
|
|
223
|
-
it('should handle HTTP errors during verification', async () => {
|
|
224
|
-
// Mock not verified check
|
|
225
|
-
mockFetch.mockResolvedValueOnce({
|
|
226
|
-
ok: true,
|
|
227
|
-
json: jest.fn().mockResolvedValue([])
|
|
228
|
-
})
|
|
229
|
-
|
|
230
|
-
// Mock HTTP error
|
|
231
|
-
mockFetch.mockResolvedValueOnce({
|
|
232
|
-
ok: false,
|
|
233
|
-
status: 500,
|
|
234
|
-
statusText: 'Internal Server Error'
|
|
235
|
-
})
|
|
236
|
-
|
|
237
|
-
const result = await platform.verifyContract(mockRequest)
|
|
238
|
-
|
|
239
|
-
expect(result.success).toBe(false)
|
|
240
|
-
expect(result.message).toContain('API request failed')
|
|
241
|
-
})
|
|
242
|
-
|
|
243
|
-
it('should treat 409 partial already verified as success (notice)', async () => {
|
|
244
|
-
// Mock not verified check
|
|
245
|
-
mockFetch.mockResolvedValueOnce({
|
|
246
|
-
ok: true,
|
|
247
|
-
json: jest.fn().mockResolvedValue([])
|
|
248
|
-
})
|
|
249
|
-
|
|
250
|
-
// Mock 409 Conflict with partial match message
|
|
251
|
-
mockFetch.mockResolvedValueOnce({
|
|
252
|
-
ok: false,
|
|
253
|
-
status: 409,
|
|
254
|
-
statusText: 'Conflict',
|
|
255
|
-
text: jest.fn().mockResolvedValue(
|
|
256
|
-
JSON.stringify({
|
|
257
|
-
error:
|
|
258
|
-
'The contract 0x... on chainId 1 is already partially verified. The provided new source code also yielded a partial match and will not be stored unless it\'s a full match',
|
|
259
|
-
message:
|
|
260
|
-
'The contract 0x... on chainId 1 is already partially verified. The provided new source code also yielded a partial match and will not be stored unless it\'s a full match'
|
|
261
|
-
})
|
|
262
|
-
)
|
|
263
|
-
})
|
|
264
|
-
|
|
265
|
-
const result = await platform.verifyContract(mockRequest)
|
|
266
|
-
|
|
267
|
-
expect(result.success).toBe(true)
|
|
268
|
-
expect(result.isAlreadyVerified).toBe(true)
|
|
269
|
-
expect(result.message.toLowerCase()).toContain('partially verified')
|
|
270
|
-
})
|
|
271
|
-
|
|
272
|
-
it('should handle network errors during verification', async () => {
|
|
273
|
-
// Mock not verified check
|
|
274
|
-
mockFetch.mockResolvedValueOnce({
|
|
275
|
-
ok: true,
|
|
276
|
-
json: jest.fn().mockResolvedValue([])
|
|
277
|
-
})
|
|
278
|
-
|
|
279
|
-
// Mock network error
|
|
280
|
-
mockFetch.mockRejectedValueOnce(new Error('Network timeout'))
|
|
281
|
-
|
|
282
|
-
const result = await platform.verifyContract(mockRequest)
|
|
283
|
-
|
|
284
|
-
expect(result.success).toBe(false)
|
|
285
|
-
expect(result.message).toContain('Network timeout')
|
|
286
|
-
})
|
|
287
|
-
})
|
|
288
|
-
})
|