@stellar-expert/contract-wasm-interface-parser 6.0.0 → 6.0.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.
Files changed (2) hide show
  1. package/README.md +318 -275
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,275 +1,318 @@
1
- # @stellar-expert/contract-wasm-interface-parser
2
-
3
- > Lightweight contract interface metadata parser for Soroban binary WASM
4
-
5
- ## Installation
6
-
7
- ```shell
8
- npm i @stellar-expert/contract-wasm-interface-parser
9
- ```
10
-
11
- ## Usage
12
-
13
- Download WASM contract code and call `parseContractMetadata()` function to obtain a parsed contract interface.
14
-
15
- ```js
16
- parseContractMetadata(Buffer.from(/*binary wasm code*/))
17
- ```
18
-
19
- Example output:
20
-
21
- ```json
22
- {
23
- "enums": {
24
- "SubscriptionStatus": {
25
- "cases": {
26
- "Active": {
27
- "value": 0
28
- },
29
- "Cancelled": {
30
- "value": 2
31
- },
32
- "Suspended": {
33
- "value": 1
34
- }
35
- }
36
- }
37
- },
38
- "errors": {
39
- "AlreadyInitialized": {
40
- "value": 0
41
- },
42
- "InvalidAmount": {
43
- "value": 4
44
- },
45
- "InvalidHeartbeat": {
46
- "value": 5
47
- },
48
- "InvalidSubscriptionStatusError": {
49
- "value": 8
50
- },
51
- "InvalidThreshold": {
52
- "value": 6
53
- },
54
- "NotInitialized": {
55
- "value": 3
56
- },
57
- "SubscriptionNotFound": {
58
- "value": 2
59
- },
60
- "Unauthorized": {
61
- "value": 1
62
- },
63
- "WebhookTooLong": {
64
- "value": 7
65
- }
66
- },
67
- "functions": {
68
- "admin": {
69
- "inputs": {},
70
- "outputs": [
71
- "Option<Address>"
72
- ]
73
- },
74
- "cancel": {
75
- "inputs": {
76
- "subscription_id": {
77
- "type": "u64"
78
- }
79
- },
80
- "outputs": []
81
- },
82
- "charge": {
83
- "inputs": {
84
- "subscription_ids": {
85
- "type": "Vec<u64>"
86
- }
87
- },
88
- "outputs": []
89
- },
90
- "config": {
91
- "inputs": {
92
- "config": {
93
- "type": "ConfigData"
94
- }
95
- },
96
- "outputs": []
97
- },
98
- "create_subscription": {
99
- "inputs": {
100
- "amount": {
101
- "type": "u64"
102
- },
103
- "new_subscription": {
104
- "type": "CreateSubscription"
105
- }
106
- },
107
- "outputs": [
108
- "(u64, Subscription)"
109
- ]
110
- },
111
- "deposit": {
112
- "inputs": {
113
- "amount": {
114
- "type": "u64"
115
- },
116
- "from": {
117
- "type": "Address"
118
- },
119
- "subscription_id": {
120
- "type": "u64"
121
- }
122
- },
123
- "outputs": []
124
- },
125
- "fee": {
126
- "inputs": {},
127
- "outputs": [
128
- "u64"
129
- ]
130
- },
131
- "get_subscription": {
132
- "inputs": {
133
- "subscription_id": {
134
- "type": "u64"
135
- }
136
- },
137
- "outputs": [
138
- "Subscription"
139
- ]
140
- },
141
- "set_fee": {
142
- "inputs": {
143
- "fee": {
144
- "type": "u64"
145
- }
146
- },
147
- "outputs": []
148
- },
149
- "token": {
150
- "inputs": {},
151
- "outputs": [
152
- "address"
153
- ]
154
- },
155
- "trigger": {
156
- "inputs": {
157
- "timestamp": {
158
- "type": "u64"
159
- },
160
- "trigger_hash": {
161
- "type": "BytesN<32>"
162
- }
163
- },
164
- "outputs": []
165
- },
166
- "update_contract": {
167
- "inputs": {
168
- "wasm_hash": {
169
- "type": "BytesN<32>"
170
- }
171
- },
172
- "outputs": []
173
- },
174
- "version": {
175
- "inputs": {},
176
- "outputs": [
177
- "u32"
178
- ]
179
- }
180
- },
181
- "structs": {
182
- "ConfigData": {
183
- "fields": {
184
- "admin": {
185
- "type": "Address"
186
- },
187
- "fee": {
188
- "type": "u64"
189
- },
190
- "token": {
191
- "type": "Address"
192
- }
193
- }
194
- },
195
- "CreateSubscription": {
196
- "fields": {
197
- "asset1": {
198
- "type": "TickerAsset"
199
- },
200
- "asset2": {
201
- "type": "TickerAsset"
202
- },
203
- "heartbeat": {
204
- "type": "u32"
205
- },
206
- "owner": {
207
- "type": "Address"
208
- },
209
- "threshold": {
210
- "type": "u32"
211
- },
212
- "webhook": {
213
- "type": "Bytes"
214
- }
215
- }
216
- },
217
- "Subscription": {
218
- "fields": {
219
- "asset1": {
220
- "type": "TickerAsset"
221
- },
222
- "asset2": {
223
- "type": "TickerAsset"
224
- },
225
- "balance": {
226
- "type": "u64"
227
- },
228
- "heartbeat": {
229
- "type": "u32"
230
- },
231
- "last_charge": {
232
- "type": "u64"
233
- },
234
- "owner": {
235
- "type": "Address"
236
- },
237
- "status": {
238
- "type": "SubscriptionStatus"
239
- },
240
- "threshold": {
241
- "type": "u32"
242
- },
243
- "webhook": {
244
- "type": "Bytes"
245
- }
246
- }
247
- },
248
- "TickerAsset": {
249
- "fields": {
250
- "asset": {
251
- "type": "Asset"
252
- },
253
- "source": {
254
- "type": "string"
255
- }
256
- }
257
- }
258
- },
259
- "unions": {
260
- "Asset": {
261
- "cases": {
262
- "Other": [
263
- "symbol"
264
- ],
265
- "Stellar": [
266
- "address"
267
- ]
268
- }
269
- }
270
- },
271
- "interfaceVersion": "20.0",
272
- "rustVersion": "1.74.0",
273
- "sdkVersion": "20.5.0#9e2c3022b4355b224a7a814e13ba51761eeb14bb"
274
- }
275
- ```
1
+ # @stellar-expert/contract-wasm-interface-parser
2
+
3
+ > Lightweight contract interface metadata parser for Soroban binary WASM
4
+
5
+ ## Installation
6
+
7
+ ```shell
8
+ npm i @stellar-expert/contract-wasm-interface-parser
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Download WASM contract code and call `parseContractMetadata()` function to obtain a parsed contract interface.
14
+
15
+ ```js
16
+ parseContractMetadata(Buffer.from(/*binary wasm code*/))
17
+ ```
18
+
19
+ Example output:
20
+
21
+ ```json
22
+ {
23
+ "unions": {
24
+ "Asset": {
25
+ "cases": {
26
+ "Stellar": [
27
+ "Address"
28
+ ],
29
+ "Other": [
30
+ "Symbol"
31
+ ]
32
+ }
33
+ }
34
+ },
35
+ "structs": {
36
+ "TickerAsset": {
37
+ "fields": {
38
+ "asset": {
39
+ "type": "Asset"
40
+ },
41
+ "source": {
42
+ "type": "String"
43
+ }
44
+ }
45
+ },
46
+ "Subscription": {
47
+ "fields": {
48
+ "asset1": {
49
+ "type": "TickerAsset"
50
+ },
51
+ "asset2": {
52
+ "type": "TickerAsset"
53
+ },
54
+ "balance": {
55
+ "type": "u64"
56
+ },
57
+ "heartbeat": {
58
+ "type": "u32"
59
+ },
60
+ "last_charge": {
61
+ "type": "u64"
62
+ },
63
+ "owner": {
64
+ "type": "Address"
65
+ },
66
+ "status": {
67
+ "type": "SubscriptionStatus"
68
+ },
69
+ "threshold": {
70
+ "type": "u32"
71
+ },
72
+ "webhook": {
73
+ "type": "Bytes"
74
+ }
75
+ }
76
+ },
77
+ "ConfigData": {
78
+ "fields": {
79
+ "admin": {
80
+ "type": "Address"
81
+ },
82
+ "fee": {
83
+ "type": "u64"
84
+ },
85
+ "token": {
86
+ "type": "Address"
87
+ }
88
+ }
89
+ },
90
+ "CreateSubscription": {
91
+ "fields": {
92
+ "asset1": {
93
+ "type": "TickerAsset"
94
+ },
95
+ "asset2": {
96
+ "type": "TickerAsset"
97
+ },
98
+ "heartbeat": {
99
+ "type": "u32"
100
+ },
101
+ "owner": {
102
+ "type": "Address"
103
+ },
104
+ "threshold": {
105
+ "type": "u32"
106
+ },
107
+ "webhook": {
108
+ "type": "Bytes"
109
+ }
110
+ }
111
+ }
112
+ },
113
+ "errors": {
114
+ "AlreadyInitialized": {
115
+ "value": 0
116
+ },
117
+ "Unauthorized": {
118
+ "value": 1
119
+ },
120
+ "SubscriptionNotFound": {
121
+ "value": 2
122
+ },
123
+ "NotInitialized": {
124
+ "value": 3
125
+ },
126
+ "InvalidAmount": {
127
+ "value": 4
128
+ },
129
+ "InvalidHeartbeat": {
130
+ "value": 5
131
+ },
132
+ "InvalidThreshold": {
133
+ "value": 6
134
+ },
135
+ "WebhookTooLong": {
136
+ "value": 7
137
+ },
138
+ "InvalidSubscriptionStatusError": {
139
+ "value": 8
140
+ }
141
+ },
142
+ "enums": {
143
+ "SubscriptionStatus": {
144
+ "cases": {
145
+ "Active": {
146
+ "value": 0
147
+ },
148
+ "Suspended": {
149
+ "value": 1
150
+ },
151
+ "Cancelled": {
152
+ "value": 2
153
+ }
154
+ }
155
+ }
156
+ },
157
+ "functions": {
158
+ "config": {
159
+ "inputs": [
160
+ {
161
+ "name": "config",
162
+ "type": "ConfigData"
163
+ }
164
+ ],
165
+ "outputs": []
166
+ },
167
+ "set_fee": {
168
+ "inputs": [
169
+ {
170
+ "name": "fee",
171
+ "type": "u64"
172
+ }
173
+ ],
174
+ "outputs": []
175
+ },
176
+ "trigger": {
177
+ "inputs": [
178
+ {
179
+ "name": "timestamp",
180
+ "type": "u64"
181
+ },
182
+ {
183
+ "name": "trigger_hash",
184
+ "type": "BytesN<32>"
185
+ }
186
+ ],
187
+ "outputs": []
188
+ },
189
+ "update_contract": {
190
+ "inputs": [
191
+ {
192
+ "name": "wasm_hash",
193
+ "type": "BytesN<32>"
194
+ }
195
+ ],
196
+ "outputs": []
197
+ },
198
+ "charge": {
199
+ "inputs": [
200
+ {
201
+ "name": "subscription_ids",
202
+ "type": "Vec<u64>"
203
+ }
204
+ ],
205
+ "outputs": []
206
+ },
207
+ "create_subscription": {
208
+ "inputs": [
209
+ {
210
+ "name": "new_subscription",
211
+ "type": "CreateSubscription"
212
+ },
213
+ {
214
+ "name": "amount",
215
+ "type": "u64"
216
+ }
217
+ ],
218
+ "outputs": [
219
+ "(u64, Subscription)"
220
+ ]
221
+ },
222
+ "deposit": {
223
+ "inputs": [
224
+ {
225
+ "name": "from",
226
+ "type": "Address"
227
+ },
228
+ {
229
+ "name": "subscription_id",
230
+ "type": "u64"
231
+ },
232
+ {
233
+ "name": "amount",
234
+ "type": "u64"
235
+ }
236
+ ],
237
+ "outputs": []
238
+ },
239
+ "cancel": {
240
+ "inputs": [
241
+ {
242
+ "name": "subscription_id",
243
+ "type": "u64"
244
+ }
245
+ ],
246
+ "outputs": []
247
+ },
248
+ "get_subscription": {
249
+ "inputs": [
250
+ {
251
+ "name": "subscription_id",
252
+ "type": "u64"
253
+ }
254
+ ],
255
+ "outputs": [
256
+ "Subscription"
257
+ ]
258
+ },
259
+ "admin": {
260
+ "inputs": [],
261
+ "outputs": [
262
+ "Option<Address>"
263
+ ]
264
+ },
265
+ "version": {
266
+ "inputs": [],
267
+ "outputs": [
268
+ "u32"
269
+ ]
270
+ },
271
+ "fee": {
272
+ "inputs": [],
273
+ "outputs": [
274
+ "u64"
275
+ ]
276
+ },
277
+ "token": {
278
+ "inputs": [],
279
+ "outputs": [
280
+ "Address"
281
+ ]
282
+ }
283
+ },
284
+ "interfaceVersion": "20.0",
285
+ "rustVersion": "1.74.0",
286
+ "sdkVersion": "20.5.0#9e2c3022b4355b224a7a814e13ba51761eeb14bb"
287
+ }
288
+ ```
289
+
290
+ Contracts compiled with newer SDK versions may contain additional metadata. Rust doc comments are exposed as `doc`
291
+ properties on functions, function inputs, structs, struct fields, enums, unions, errors, and their cases. Contract
292
+ events declared with `#[contractevent]` are parsed into a separate `events` section:
293
+
294
+ ```json
295
+ {
296
+ "events": {
297
+ "ZapInitializedEvent": {
298
+ "prefixTopics": [
299
+ "zap_initialized"
300
+ ],
301
+ "params": [
302
+ {
303
+ "name": "factory",
304
+ "type": "Address",
305
+ "location": "data"
306
+ },
307
+ {
308
+ "name": "position_manager",
309
+ "type": "Address",
310
+ "location": "data"
311
+ }
312
+ ],
313
+ "dataFormat": "Map",
314
+ "doc": "Zap router initialization event"
315
+ }
316
+ }
317
+ }
318
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stellar-expert/contract-wasm-interface-parser",
3
- "version": "6.0.0",
3
+ "version": "6.0.1",
4
4
  "description": "Contract interface metadata parser for binary WASM",
5
5
  "author": "orbitlens <orbit@stellar.expert>",
6
6
  "license": "MIT",