@xrplkit/xls26 2.0.0 → 2.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/package.json +9 -2
- package/readme.md +30 -30
- package/xls26.js +20 -12
package/package.json
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xrplkit/xls26",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"main": "xls26.js",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@xrplkit/toml": "1.0.0"
|
|
8
8
|
},
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
|
-
}
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"xrpl",
|
|
14
|
+
"xls-26",
|
|
15
|
+
"parser",
|
|
16
|
+
"metadata",
|
|
17
|
+
"tokens"
|
|
18
|
+
]
|
|
12
19
|
}
|
package/readme.md
CHANGED
|
@@ -7,7 +7,7 @@ This package exports one single function called `parse` that converts the string
|
|
|
7
7
|
## Example
|
|
8
8
|
Assuming you have a file named `xrp-ledger.toml` in the current working directory. An example file can be found below.
|
|
9
9
|
|
|
10
|
-
```
|
|
10
|
+
```javascript
|
|
11
11
|
import fs from 'fs'
|
|
12
12
|
import { parse } from '@xrplkit/xls26'
|
|
13
13
|
|
|
@@ -20,7 +20,7 @@ console.log(xls26Data)
|
|
|
20
20
|
|
|
21
21
|
### Example File
|
|
22
22
|
|
|
23
|
-
```
|
|
23
|
+
```toml
|
|
24
24
|
[[ISSUERS]]
|
|
25
25
|
address = "rCSCManTZ8ME9EoLrSHHYKW8PPwWMgkwr"
|
|
26
26
|
name = "CasinoCoin"
|
|
@@ -45,35 +45,35 @@ type = "socialmedia"
|
|
|
45
45
|
|
|
46
46
|
### Example Output
|
|
47
47
|
|
|
48
|
-
```
|
|
48
|
+
```javascript
|
|
49
49
|
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
50
|
+
issuers: [
|
|
51
|
+
{
|
|
52
|
+
address: 'rCSCManTZ8ME9EoLrSHHYKW8PPwWMgkwr',
|
|
53
|
+
name: 'CasinoCoin'
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
tokens: [
|
|
57
|
+
{
|
|
58
|
+
currency: 'CSC',
|
|
59
|
+
issuer: 'rCSCManTZ8ME9EoLrSHHYKW8PPwWMgkwr',
|
|
60
|
+
name: 'CasinoCoin',
|
|
61
|
+
desc: 'CasinoCoin (CSC) is a digital currency, developed specifically for the regulated gaming industry.',
|
|
62
|
+
icon: 'https://static.xrplmeta.org/icons/csc.png',
|
|
63
|
+
weblinks: [
|
|
64
|
+
{
|
|
65
|
+
url: 'https://casinocoin.im',
|
|
66
|
+
type: 'website',
|
|
67
|
+
title: 'Official Website'
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
url: 'https://twitter.com/CasinoCoin',
|
|
71
|
+
type: 'socialmedia'
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
issues: []
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
```
|
package/xls26.js
CHANGED
|
@@ -39,6 +39,13 @@ const issuerFields = [
|
|
|
39
39
|
throw 'has to be a non empty string'
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
|
+
{
|
|
43
|
+
key: 'domain',
|
|
44
|
+
validate: v => {
|
|
45
|
+
if(typeof v !== 'string' || v.length === 0)
|
|
46
|
+
throw 'has to be a non empty string'
|
|
47
|
+
}
|
|
48
|
+
},
|
|
42
49
|
{
|
|
43
50
|
key: 'icon',
|
|
44
51
|
alternativeKeys: ['avatar'],
|
|
@@ -139,7 +146,7 @@ const weblinkFields = [
|
|
|
139
146
|
|
|
140
147
|
export function parse(str){
|
|
141
148
|
try{
|
|
142
|
-
var toml = parseToml(str
|
|
149
|
+
var toml = parseToml(str)
|
|
143
150
|
}catch(error){
|
|
144
151
|
throw new Error(`Failed to parse .toml: Syntax error at line ${error.line}:${error.column}`)
|
|
145
152
|
}
|
|
@@ -148,8 +155,9 @@ export function parse(str){
|
|
|
148
155
|
let tokens = []
|
|
149
156
|
let issues = []
|
|
150
157
|
|
|
151
|
-
|
|
152
|
-
|
|
158
|
+
|
|
159
|
+
if(toml.ISSUERS){
|
|
160
|
+
for(let stanza of toml.ISSUERS){
|
|
153
161
|
let { valid, parsed: issuer, issues: issuerIssues } = parseStanza(stanza, issuerFields)
|
|
154
162
|
|
|
155
163
|
if(valid)
|
|
@@ -161,13 +169,13 @@ export function parse(str){
|
|
|
161
169
|
)
|
|
162
170
|
)
|
|
163
171
|
|
|
164
|
-
if(valid && stanza.
|
|
165
|
-
for(let substanza of stanza.
|
|
172
|
+
if(valid && stanza.WEBLINKS){
|
|
173
|
+
for(let substanza of stanza.WEBLINKS){
|
|
166
174
|
let { valid, parsed: weblink, issues: weblinkIssues } = parseStanza(substanza, weblinkFields)
|
|
167
175
|
|
|
168
176
|
if(valid){
|
|
169
177
|
issuer.weblinks = [
|
|
170
|
-
...(
|
|
178
|
+
...(issuer.weblinks || []),
|
|
171
179
|
weblink
|
|
172
180
|
]
|
|
173
181
|
}
|
|
@@ -182,8 +190,8 @@ export function parse(str){
|
|
|
182
190
|
}
|
|
183
191
|
}
|
|
184
192
|
|
|
185
|
-
if(toml.
|
|
186
|
-
for(let stanza of toml.
|
|
193
|
+
if(toml.TOKENS){
|
|
194
|
+
for(let stanza of toml.TOKENS){
|
|
187
195
|
let { valid, parsed: token, issues: tokenIssues } = parseStanza(stanza, tokenFields)
|
|
188
196
|
|
|
189
197
|
if(valid)
|
|
@@ -195,8 +203,8 @@ export function parse(str){
|
|
|
195
203
|
)
|
|
196
204
|
)
|
|
197
205
|
|
|
198
|
-
if(valid && stanza.
|
|
199
|
-
for(let substanza of stanza.
|
|
206
|
+
if(valid && stanza.WEBLINKS){
|
|
207
|
+
for(let substanza of stanza.WEBLINKS){
|
|
200
208
|
let { valid, parsed: weblink, issues: weblinkIssues } = parseStanza(substanza, weblinkFields)
|
|
201
209
|
|
|
202
210
|
if(valid){
|
|
@@ -236,7 +244,7 @@ function parseStanza(stanza, schemas){
|
|
|
236
244
|
keys.push(...alternativeKeys)
|
|
237
245
|
|
|
238
246
|
for(let k of keys){
|
|
239
|
-
if(
|
|
247
|
+
if(stanza[k] === undefined)
|
|
240
248
|
continue
|
|
241
249
|
|
|
242
250
|
let value = stanza[k]
|
|
@@ -254,7 +262,7 @@ function parseStanza(stanza, schemas){
|
|
|
254
262
|
break
|
|
255
263
|
}
|
|
256
264
|
|
|
257
|
-
if(essential &&
|
|
265
|
+
if(essential && parsed[key] === undefined){
|
|
258
266
|
issues.push(`${key} field missing: skipping stanza`)
|
|
259
267
|
valid = false
|
|
260
268
|
}
|