@0xsequence/catapult 1.4.0 → 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 +27 -0
- package/dist/lib/__tests__/network-loader.spec.js.map +1 -1
- package/dist/lib/core/__tests__/resolver.spec.js +22 -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 +173 -0
- package/dist/lib/core/engine.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/parsers/__tests__/source.spec.js +37 -0
- package/dist/lib/parsers/__tests__/source.spec.js.map +1 -1
- package/dist/lib/parsers/source.js +1 -1
- package/dist/lib/parsers/source.js.map +1 -1
- package/dist/lib/provenance.js +51 -2
- package/dist/lib/provenance.js.map +1 -1
- package/dist/lib/types/actions.d.ts +26 -2
- package/dist/lib/types/actions.d.ts.map +1 -1
- package/dist/lib/types/actions.js +3 -0
- package/dist/lib/types/actions.js.map +1 -1
- package/dist/lib/types/source.d.ts +2 -0
- package/dist/lib/types/source.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 -18
- 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 -6
- package/src/commands/list.ts +0 -262
- package/src/commands/provenance.ts +0 -120
- 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 -2269
- 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/__tests__/provenance.spec.ts +0 -208
- 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 -612
- package/src/lib/contracts/repository.ts +0 -411
- package/src/lib/core/__tests__/assert-action.spec.ts +0 -474
- package/src/lib/core/__tests__/context.spec.ts +0 -37
- package/src/lib/core/__tests__/engine.spec.ts +0 -2005
- 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 -367
- package/src/lib/core/__tests__/multi-platform-verification.spec.ts +0 -406
- package/src/lib/core/__tests__/resolver.spec.ts +0 -2496
- 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 -1834
- package/src/lib/core/graph.ts +0 -252
- package/src/lib/core/loader.ts +0 -253
- package/src/lib/core/resolver.ts +0 -873
- package/src/lib/deployer.ts +0 -1005
- 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 -17
- 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 -439
- package/src/lib/parsers/__tests__/source.spec.ts +0 -134
- 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 -6
- package/src/lib/parsers/job.ts +0 -160
- package/src/lib/parsers/source.ts +0 -129
- package/src/lib/parsers/template.ts +0 -135
- package/src/lib/provenance.ts +0 -785
- 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 -148
- 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 -26
- package/src/lib/types/definitions.ts +0 -77
- package/src/lib/types/index.ts +0 -9
- package/src/lib/types/network.ts +0 -33
- package/src/lib/types/project.ts +0 -9
- package/src/lib/types/source.ts +0 -26
- package/src/lib/types/task.ts +0 -9
- package/src/lib/types/values.ts +0 -221
- 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,243 +0,0 @@
|
|
|
1
|
-
import { JsonRequestAction } from '../actions'
|
|
2
|
-
|
|
3
|
-
describe('JsonRequestAction', () => {
|
|
4
|
-
describe('type definition', () => {
|
|
5
|
-
it('should have correct type structure for basic GET request', () => {
|
|
6
|
-
const action: JsonRequestAction = {
|
|
7
|
-
type: 'json-request',
|
|
8
|
-
arguments: {
|
|
9
|
-
url: 'https://api.example.com/data'
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
expect(action.type).toBe('json-request')
|
|
14
|
-
expect(action.arguments.url).toBe('https://api.example.com/data')
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
it('should support optional method parameter', () => {
|
|
18
|
-
const action: JsonRequestAction = {
|
|
19
|
-
type: 'json-request',
|
|
20
|
-
arguments: {
|
|
21
|
-
url: 'https://api.example.com/data',
|
|
22
|
-
method: 'POST'
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
expect(action.arguments.method).toBe('POST')
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('should support optional headers parameter', () => {
|
|
30
|
-
const action: JsonRequestAction = {
|
|
31
|
-
type: 'json-request',
|
|
32
|
-
arguments: {
|
|
33
|
-
url: 'https://api.example.com/data',
|
|
34
|
-
headers: {
|
|
35
|
-
'Content-Type': 'application/json',
|
|
36
|
-
'Authorization': 'Bearer token123'
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
expect(action.arguments.headers).toEqual({
|
|
42
|
-
'Content-Type': 'application/json',
|
|
43
|
-
'Authorization': 'Bearer token123'
|
|
44
|
-
})
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it('should support optional body parameter', () => {
|
|
48
|
-
const requestBody = {
|
|
49
|
-
name: 'John Doe',
|
|
50
|
-
email: 'john@example.com'
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const action: JsonRequestAction = {
|
|
54
|
-
type: 'json-request',
|
|
55
|
-
arguments: {
|
|
56
|
-
url: 'https://api.example.com/users',
|
|
57
|
-
method: 'POST',
|
|
58
|
-
body: requestBody
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
expect(action.arguments.body).toEqual(requestBody)
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
it('should support template variables in url', () => {
|
|
66
|
-
const action: JsonRequestAction = {
|
|
67
|
-
type: 'json-request',
|
|
68
|
-
arguments: {
|
|
69
|
-
url: '{{apiBaseUrl}}/users/{{userId}}'
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
expect(action.arguments.url).toBe('{{apiBaseUrl}}/users/{{userId}}')
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
it('should support template variables in method', () => {
|
|
77
|
-
const action: JsonRequestAction = {
|
|
78
|
-
type: 'json-request',
|
|
79
|
-
arguments: {
|
|
80
|
-
url: 'https://api.example.com/data',
|
|
81
|
-
method: '{{httpMethod}}'
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
expect(action.arguments.method).toBe('{{httpMethod}}')
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
it('should support template variables in headers', () => {
|
|
89
|
-
const action: JsonRequestAction = {
|
|
90
|
-
type: 'json-request',
|
|
91
|
-
arguments: {
|
|
92
|
-
url: 'https://api.example.com/data',
|
|
93
|
-
headers: {
|
|
94
|
-
'Authorization': '{{authToken}}',
|
|
95
|
-
'X-API-Key': '{{apiKey}}'
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
expect(action.arguments.headers).toEqual({
|
|
101
|
-
'Authorization': '{{authToken}}',
|
|
102
|
-
'X-API-Key': '{{apiKey}}'
|
|
103
|
-
})
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
it('should support template variables in body', () => {
|
|
107
|
-
const action: JsonRequestAction = {
|
|
108
|
-
type: 'json-request',
|
|
109
|
-
arguments: {
|
|
110
|
-
url: 'https://api.example.com/users',
|
|
111
|
-
method: 'POST',
|
|
112
|
-
body: {
|
|
113
|
-
name: '{{userName}}',
|
|
114
|
-
email: '{{userEmail}}',
|
|
115
|
-
data: '{{userData}}'
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
expect(action.arguments.body).toEqual({
|
|
121
|
-
name: '{{userName}}',
|
|
122
|
-
email: '{{userEmail}}',
|
|
123
|
-
data: '{{userData}}'
|
|
124
|
-
})
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
it('should support complex nested body structures', () => {
|
|
128
|
-
const action: JsonRequestAction = {
|
|
129
|
-
type: 'json-request',
|
|
130
|
-
arguments: {
|
|
131
|
-
url: 'https://api.example.com/transactions',
|
|
132
|
-
method: 'POST',
|
|
133
|
-
body: {
|
|
134
|
-
transaction: {
|
|
135
|
-
to: '{{recipientAddress}}',
|
|
136
|
-
value: '{{amount}}',
|
|
137
|
-
data: '{{calldata}}'
|
|
138
|
-
},
|
|
139
|
-
metadata: {
|
|
140
|
-
timestamp: '{{currentTime}}',
|
|
141
|
-
source: 'live-contracts'
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
expect(action.arguments.body).toEqual({
|
|
148
|
-
transaction: {
|
|
149
|
-
to: '{{recipientAddress}}',
|
|
150
|
-
value: '{{amount}}',
|
|
151
|
-
data: '{{calldata}}'
|
|
152
|
-
},
|
|
153
|
-
metadata: {
|
|
154
|
-
timestamp: '{{currentTime}}',
|
|
155
|
-
source: 'live-contracts'
|
|
156
|
-
}
|
|
157
|
-
})
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
it('should support all HTTP methods', () => {
|
|
161
|
-
const methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS']
|
|
162
|
-
|
|
163
|
-
methods.forEach(method => {
|
|
164
|
-
const action: JsonRequestAction = {
|
|
165
|
-
type: 'json-request',
|
|
166
|
-
arguments: {
|
|
167
|
-
url: 'https://api.example.com/data',
|
|
168
|
-
method: method
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
expect(action.arguments.method).toBe(method)
|
|
173
|
-
})
|
|
174
|
-
})
|
|
175
|
-
|
|
176
|
-
it('should work with minimal configuration (only url)', () => {
|
|
177
|
-
const action: JsonRequestAction = {
|
|
178
|
-
type: 'json-request',
|
|
179
|
-
arguments: {
|
|
180
|
-
url: 'https://api.example.com/status'
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
expect(action.type).toBe('json-request')
|
|
185
|
-
expect(action.arguments.url).toBe('https://api.example.com/status')
|
|
186
|
-
expect(action.arguments.method).toBeUndefined()
|
|
187
|
-
expect(action.arguments.headers).toBeUndefined()
|
|
188
|
-
expect(action.arguments.body).toBeUndefined()
|
|
189
|
-
})
|
|
190
|
-
|
|
191
|
-
it('should work with full configuration', () => {
|
|
192
|
-
const action: JsonRequestAction = {
|
|
193
|
-
type: 'json-request',
|
|
194
|
-
arguments: {
|
|
195
|
-
url: 'https://api.example.com/users',
|
|
196
|
-
method: 'POST',
|
|
197
|
-
headers: {
|
|
198
|
-
'Content-Type': 'application/json',
|
|
199
|
-
'Authorization': 'Bearer token123',
|
|
200
|
-
'X-Custom-Header': 'custom-value'
|
|
201
|
-
},
|
|
202
|
-
body: {
|
|
203
|
-
user: {
|
|
204
|
-
name: 'Alice',
|
|
205
|
-
email: 'alice@example.com',
|
|
206
|
-
preferences: {
|
|
207
|
-
theme: 'dark',
|
|
208
|
-
notifications: true
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
metadata: {
|
|
212
|
-
source: 'api',
|
|
213
|
-
version: '1.0'
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
expect(action.type).toBe('json-request')
|
|
220
|
-
expect(action.arguments.url).toBe('https://api.example.com/users')
|
|
221
|
-
expect(action.arguments.method).toBe('POST')
|
|
222
|
-
expect(action.arguments.headers).toEqual({
|
|
223
|
-
'Content-Type': 'application/json',
|
|
224
|
-
'Authorization': 'Bearer token123',
|
|
225
|
-
'X-Custom-Header': 'custom-value'
|
|
226
|
-
})
|
|
227
|
-
expect(action.arguments.body).toEqual({
|
|
228
|
-
user: {
|
|
229
|
-
name: 'Alice',
|
|
230
|
-
email: 'alice@example.com',
|
|
231
|
-
preferences: {
|
|
232
|
-
theme: 'dark',
|
|
233
|
-
notifications: true
|
|
234
|
-
}
|
|
235
|
-
},
|
|
236
|
-
metadata: {
|
|
237
|
-
source: 'api',
|
|
238
|
-
version: '1.0'
|
|
239
|
-
}
|
|
240
|
-
})
|
|
241
|
-
})
|
|
242
|
-
})
|
|
243
|
-
})
|
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
import { ReadJsonValue } from '../values'
|
|
2
|
-
|
|
3
|
-
describe('ReadJsonValue', () => {
|
|
4
|
-
describe('type definition', () => {
|
|
5
|
-
it('should have correct type structure for basic path', () => {
|
|
6
|
-
const value: ReadJsonValue = {
|
|
7
|
-
type: 'read-json',
|
|
8
|
-
arguments: {
|
|
9
|
-
json: { name: 'John', age: 30 },
|
|
10
|
-
path: 'name'
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
expect(value.type).toBe('read-json')
|
|
15
|
-
expect(value.arguments.json).toEqual({ name: 'John', age: 30 })
|
|
16
|
-
expect(value.arguments.path).toBe('name')
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
it('should support nested path access', () => {
|
|
20
|
-
const value: ReadJsonValue = {
|
|
21
|
-
type: 'read-json',
|
|
22
|
-
arguments: {
|
|
23
|
-
json: {
|
|
24
|
-
txs: {
|
|
25
|
-
to: '0x596aF90CecdBF9A768886E771178fd5561dD27Ab',
|
|
26
|
-
data: '0x1234'
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
path: 'txs.data'
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
expect(value.arguments.path).toBe('txs.data')
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('should support deeply nested path access', () => {
|
|
37
|
-
const value: ReadJsonValue = {
|
|
38
|
-
type: 'read-json',
|
|
39
|
-
arguments: {
|
|
40
|
-
json: {
|
|
41
|
-
user: {
|
|
42
|
-
profile: {
|
|
43
|
-
personal: {
|
|
44
|
-
name: 'Alice'
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
path: 'user.profile.personal.name'
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
expect(value.arguments.path).toBe('user.profile.personal.name')
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
it('should support array index access', () => {
|
|
57
|
-
const value: ReadJsonValue = {
|
|
58
|
-
type: 'read-json',
|
|
59
|
-
arguments: {
|
|
60
|
-
json: {
|
|
61
|
-
transactions: [
|
|
62
|
-
{ hash: '0xabc123' },
|
|
63
|
-
{ hash: '0xdef456' }
|
|
64
|
-
]
|
|
65
|
-
},
|
|
66
|
-
path: 'transactions.0.hash'
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
expect(value.arguments.path).toBe('transactions.0.hash')
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
it('should support template variables in json', () => {
|
|
74
|
-
const value: ReadJsonValue = {
|
|
75
|
-
type: 'read-json',
|
|
76
|
-
arguments: {
|
|
77
|
-
json: '{{apiResponse}}',
|
|
78
|
-
path: 'result.data'
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
expect(value.arguments.json).toBe('{{apiResponse}}')
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
it('should support template variables in path', () => {
|
|
86
|
-
const value: ReadJsonValue = {
|
|
87
|
-
type: 'read-json',
|
|
88
|
-
arguments: {
|
|
89
|
-
json: { data: { field1: 'value1', field2: 'value2' } },
|
|
90
|
-
path: '{{fieldPath}}'
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
expect(value.arguments.path).toBe('{{fieldPath}}')
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
it('should support numeric keys in path', () => {
|
|
98
|
-
const value: ReadJsonValue = {
|
|
99
|
-
type: 'read-json',
|
|
100
|
-
arguments: {
|
|
101
|
-
json: {
|
|
102
|
-
137: { calldata: '0xdeadbeef' }
|
|
103
|
-
},
|
|
104
|
-
path: 137
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
expect(value.arguments.path).toBe(137)
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
it('should support both json and path as template variables', () => {
|
|
112
|
-
const value: ReadJsonValue = {
|
|
113
|
-
type: 'read-json',
|
|
114
|
-
arguments: {
|
|
115
|
-
json: '{{responseData}}',
|
|
116
|
-
path: '{{extractionPath}}'
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
expect(value.arguments.json).toBe('{{responseData}}')
|
|
121
|
-
expect(value.arguments.path).toBe('{{extractionPath}}')
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
it('should work with complex JSON structures', () => {
|
|
125
|
-
const complexJson = {
|
|
126
|
-
blockchain: {
|
|
127
|
-
ethereum: {
|
|
128
|
-
mainnet: {
|
|
129
|
-
contracts: {
|
|
130
|
-
erc20: [
|
|
131
|
-
{
|
|
132
|
-
address: '0xA0b86a33E6441e6e80D0c4C6C7527d72e1d7e4e1',
|
|
133
|
-
symbol: 'USDC',
|
|
134
|
-
decimals: 6
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
address: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
|
|
138
|
-
symbol: 'DAI',
|
|
139
|
-
decimals: 18
|
|
140
|
-
}
|
|
141
|
-
]
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const value: ReadJsonValue = {
|
|
149
|
-
type: 'read-json',
|
|
150
|
-
arguments: {
|
|
151
|
-
json: complexJson,
|
|
152
|
-
path: 'blockchain.ethereum.mainnet.contracts.erc20.1.symbol'
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
expect(value.arguments.json).toEqual(complexJson)
|
|
157
|
-
expect(value.arguments.path).toBe('blockchain.ethereum.mainnet.contracts.erc20.1.symbol')
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
it('should work with the example from the task description', () => {
|
|
161
|
-
const exampleJson = {
|
|
162
|
-
txs: {
|
|
163
|
-
to: '0x596aF90CecdBF9A768886E771178fd5561dD27Ab',
|
|
164
|
-
data: '0x1234'
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const value: ReadJsonValue = {
|
|
169
|
-
type: 'read-json',
|
|
170
|
-
arguments: {
|
|
171
|
-
json: exampleJson,
|
|
172
|
-
path: 'txs.data'
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
expect(value.arguments.json).toEqual(exampleJson)
|
|
177
|
-
expect(value.arguments.path).toBe('txs.data')
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
it('should support root level access', () => {
|
|
181
|
-
const value: ReadJsonValue = {
|
|
182
|
-
type: 'read-json',
|
|
183
|
-
arguments: {
|
|
184
|
-
json: 'simple string value',
|
|
185
|
-
path: ''
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
expect(value.arguments.json).toBe('simple string value')
|
|
190
|
-
expect(value.arguments.path).toBe('')
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
it('should support accessing array elements directly', () => {
|
|
194
|
-
const value: ReadJsonValue = {
|
|
195
|
-
type: 'read-json',
|
|
196
|
-
arguments: {
|
|
197
|
-
json: ['first', 'second', 'third'],
|
|
198
|
-
path: '1'
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
expect(value.arguments.json).toEqual(['first', 'second', 'third'])
|
|
203
|
-
expect(value.arguments.path).toBe('1')
|
|
204
|
-
})
|
|
205
|
-
|
|
206
|
-
it('should support mixed object and array access', () => {
|
|
207
|
-
const value: ReadJsonValue = {
|
|
208
|
-
type: 'read-json',
|
|
209
|
-
arguments: {
|
|
210
|
-
json: {
|
|
211
|
-
results: [
|
|
212
|
-
{ id: 1, data: { value: 'first' } },
|
|
213
|
-
{ id: 2, data: { value: 'second' } }
|
|
214
|
-
]
|
|
215
|
-
},
|
|
216
|
-
path: 'results.0.data.value'
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
expect(value.arguments.path).toBe('results.0.data.value')
|
|
221
|
-
})
|
|
222
|
-
|
|
223
|
-
it('should support boolean and number values in JSON', () => {
|
|
224
|
-
const value: ReadJsonValue = {
|
|
225
|
-
type: 'read-json',
|
|
226
|
-
arguments: {
|
|
227
|
-
json: {
|
|
228
|
-
config: {
|
|
229
|
-
enabled: true,
|
|
230
|
-
maxRetries: 5,
|
|
231
|
-
timeout: 30.5
|
|
232
|
-
}
|
|
233
|
-
},
|
|
234
|
-
path: 'config.enabled'
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
expect(value.arguments.json).toEqual({
|
|
239
|
-
config: {
|
|
240
|
-
enabled: true,
|
|
241
|
-
maxRetries: 5,
|
|
242
|
-
timeout: 30.5
|
|
243
|
-
}
|
|
244
|
-
})
|
|
245
|
-
})
|
|
246
|
-
|
|
247
|
-
it('should support null values in JSON', () => {
|
|
248
|
-
const value: ReadJsonValue = {
|
|
249
|
-
type: 'read-json',
|
|
250
|
-
arguments: {
|
|
251
|
-
json: {
|
|
252
|
-
user: {
|
|
253
|
-
name: 'John',
|
|
254
|
-
avatar: null
|
|
255
|
-
}
|
|
256
|
-
},
|
|
257
|
-
path: 'user.avatar'
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
expect(value.arguments.json.user.avatar).toBeNull()
|
|
262
|
-
})
|
|
263
|
-
|
|
264
|
-
it('should work with response from json-request action', () => {
|
|
265
|
-
// This simulates using the result of a json-request action
|
|
266
|
-
const value: ReadJsonValue = {
|
|
267
|
-
type: 'read-json',
|
|
268
|
-
arguments: {
|
|
269
|
-
json: '{{apiCall.response}}', // Reference to a json-request action output
|
|
270
|
-
path: 'data.transactions.0.hash'
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
expect(value.arguments.json).toBe('{{apiCall.response}}')
|
|
275
|
-
expect(value.arguments.path).toBe('data.transactions.0.hash')
|
|
276
|
-
})
|
|
277
|
-
})
|
|
278
|
-
})
|