@stellar-expert/contract-wasm-interface-parser 3.0.0 → 3.1.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 +82 -70
- package/package.json +1 -1
- package/src/xdr-spec-parser.js +15 -11
package/README.md
CHANGED
|
@@ -22,14 +22,16 @@ Example output:
|
|
|
22
22
|
{
|
|
23
23
|
"enums": {
|
|
24
24
|
"SubscriptionStatus": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
25
|
+
"cases": {
|
|
26
|
+
"Active": {
|
|
27
|
+
"value": 0
|
|
28
|
+
},
|
|
29
|
+
"Cancelled": {
|
|
30
|
+
"value": 2
|
|
31
|
+
},
|
|
32
|
+
"Suspended": {
|
|
33
|
+
"value": 1
|
|
34
|
+
}
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
},
|
|
@@ -178,82 +180,92 @@ Example output:
|
|
|
178
180
|
},
|
|
179
181
|
"structs": {
|
|
180
182
|
"ConfigData": {
|
|
181
|
-
"
|
|
182
|
-
"
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
"
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
"
|
|
183
|
+
"fields": {
|
|
184
|
+
"admin": {
|
|
185
|
+
"type": "address"
|
|
186
|
+
},
|
|
187
|
+
"fee": {
|
|
188
|
+
"type": "u64"
|
|
189
|
+
},
|
|
190
|
+
"token": {
|
|
191
|
+
"type": "address"
|
|
192
|
+
}
|
|
189
193
|
}
|
|
190
194
|
},
|
|
191
195
|
"CreateSubscription": {
|
|
192
|
-
"
|
|
193
|
-
"
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
"
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
"
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
"
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
"
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
"
|
|
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
|
+
}
|
|
209
215
|
}
|
|
210
216
|
},
|
|
211
217
|
"Subscription": {
|
|
212
|
-
"
|
|
213
|
-
"
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
"
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
"
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
"
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
"
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
"
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
"
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
"
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
"
|
|
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
|
+
}
|
|
238
246
|
}
|
|
239
247
|
},
|
|
240
248
|
"TickerAsset": {
|
|
241
|
-
"
|
|
242
|
-
"
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
"
|
|
249
|
+
"fields": {
|
|
250
|
+
"asset": {
|
|
251
|
+
"type": "Asset"
|
|
252
|
+
},
|
|
253
|
+
"source": {
|
|
254
|
+
"type": "string"
|
|
255
|
+
}
|
|
246
256
|
}
|
|
247
257
|
}
|
|
248
258
|
},
|
|
249
259
|
"unions": {
|
|
250
260
|
"Asset": {
|
|
251
|
-
"
|
|
252
|
-
"
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
"
|
|
256
|
-
|
|
261
|
+
"cases": {
|
|
262
|
+
"Other": [
|
|
263
|
+
"symbol"
|
|
264
|
+
],
|
|
265
|
+
"Stellar": [
|
|
266
|
+
"address"
|
|
267
|
+
]
|
|
268
|
+
}
|
|
257
269
|
}
|
|
258
270
|
},
|
|
259
271
|
"interfaceVersion": "85899345920",
|
package/package.json
CHANGED
package/src/xdr-spec-parser.js
CHANGED
|
@@ -73,13 +73,13 @@ class SpecParser {
|
|
|
73
73
|
into[attr.name.toString()] = this.withDocs({
|
|
74
74
|
inputs,
|
|
75
75
|
outputs: attr.outputs.map(o => this.parseParameterType(o))
|
|
76
|
-
}, attr
|
|
76
|
+
}, attr)
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
parseStruct(attr, into) {
|
|
80
80
|
const fields = {}
|
|
81
81
|
attr.fields.forEach(f => this.parseParameter(f, fields))
|
|
82
|
-
into[this.parseStructName(attr)] = this.withDocs(fields, attr
|
|
82
|
+
into[this.parseStructName(attr)] = this.withDocs({fields}, attr)
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
parseUnion(attr, into) {
|
|
@@ -90,7 +90,7 @@ class SpecParser {
|
|
|
90
90
|
value.type().map(t => this.parseParameterType(t)) :
|
|
91
91
|
[]
|
|
92
92
|
})
|
|
93
|
-
into[this.parseStructName(attr)] = this.withDocs(cases, attr
|
|
93
|
+
into[this.parseStructName(attr)] = this.withDocs({cases}, attr)
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
parseEnum(attr, into) {
|
|
@@ -100,14 +100,18 @@ class SpecParser {
|
|
|
100
100
|
if (value.name) {
|
|
101
101
|
cases[value.name().toString()] = value.value()
|
|
102
102
|
} else {
|
|
103
|
-
|
|
103
|
+
const attr = c._attributes
|
|
104
|
+
cases[attr.name.toString()] = this.withDocs({value}, attr)
|
|
104
105
|
}
|
|
105
106
|
})
|
|
106
|
-
into[this.parseStructName(attr)] = this.withDocs(cases, attr
|
|
107
|
+
into[this.parseStructName(attr)] = this.withDocs({cases}, attr)
|
|
107
108
|
}
|
|
108
109
|
|
|
109
110
|
parseError(attr, into) {
|
|
110
|
-
attr.cases.forEach(c =>
|
|
111
|
+
attr.cases.forEach(c => {
|
|
112
|
+
const attr = c._attributes
|
|
113
|
+
into[attr.name.toString()] = this.withDocs({value: attr.value}, attr)
|
|
114
|
+
})
|
|
111
115
|
}
|
|
112
116
|
|
|
113
117
|
parseParameterType(type) {
|
|
@@ -141,13 +145,13 @@ class SpecParser {
|
|
|
141
145
|
}
|
|
142
146
|
|
|
143
147
|
parseParameter(param, into) {
|
|
144
|
-
const
|
|
145
|
-
into[attr.name.toString()] = this.withDocs({type: this.parseParameterType(attr.type)}, attr
|
|
148
|
+
const attr = param._attributes
|
|
149
|
+
into[attr.name.toString()] = this.withDocs({type: this.parseParameterType(attr.type)}, attr)
|
|
146
150
|
}
|
|
147
151
|
|
|
148
|
-
withDocs(descriptor,
|
|
149
|
-
if (doc?.length) {
|
|
150
|
-
descriptor.doc = doc.toString()
|
|
152
|
+
withDocs(descriptor, attr) {
|
|
153
|
+
if (attr.doc?.length) {
|
|
154
|
+
descriptor.doc = attr.doc.toString()
|
|
151
155
|
}
|
|
152
156
|
return descriptor
|
|
153
157
|
}
|