@xrplkit/xls26 2.1.0 → 2.3.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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/readme.md +40 -28
  3. package/xls26.js +70 -7
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xrplkit/xls26",
3
3
  "type": "module",
4
- "version": "2.1.0",
4
+ "version": "2.3.0",
5
5
  "main": "xls26.js",
6
6
  "dependencies": {
7
7
  "@xrplkit/toml": "1.0.0"
package/readme.md CHANGED
@@ -22,24 +22,29 @@ console.log(xls26Data)
22
22
 
23
23
  ```toml
24
24
  [[ISSUERS]]
25
- address = "rCSCManTZ8ME9EoLrSHHYKW8PPwWMgkwr"
26
- name = "CasinoCoin"
25
+ address = "rHXuEaRYnnJHbDeuBH5w8yPh5uwNVh5zAg"
26
+ name = "Aesthetes"
27
27
 
28
- [[TOKENS]]
29
- issuer = "rCSCManTZ8ME9EoLrSHHYKW8PPwWMgkwr"
30
- currency = "CSC"
31
- name = "CasinoCoin"
32
- desc = "CasinoCoin (CSC) is a digital currency, developed specifically for the regulated gaming industry."
33
- icon = "https://static.xrplmeta.org/icons/csc.png"
34
-
35
- [[TOKENS.WEBLINKS]]
36
- url = "https://casinocoin.im"
37
- type = "website"
28
+ [[ISSUERS.WEBLINKS]]
29
+ url = "https://aesthetes.art"
30
+ type = "info"
38
31
  title = "Official Website"
39
32
 
40
- [[TOKENS.WEBLINKS]]
41
- url = "https://twitter.com/CasinoCoin"
33
+ [[ISSUERS.WEBLINKS]]
34
+ url = "https://twitter.com/aesthetes_art"
42
35
  type = "socialmedia"
36
+
37
+ [[TOKENS]]
38
+ issuer = "rHXuEaRYnnJHbDeuBH5w8yPh5uwNVh5zAg"
39
+ currency = "ELS"
40
+ name = "Elysian"
41
+ desc = "The first Token for the Art and NFT Industry running on the XRPL."
42
+ icon = "https://static.xrplmeta.org/icons/els.png"
43
+ asset_class = "cryptocurrency"
44
+
45
+ [[TOKENS.WEBLINKS]]
46
+ url = "https://twitter.com/Elysianers"
47
+ type = "community"
43
48
  ```
44
49
 
45
50
 
@@ -49,30 +54,37 @@ type = "socialmedia"
49
54
  {
50
55
  issuers: [
51
56
  {
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',
57
+ address: 'rHXuEaRYnnJHbDeuBH5w8yPh5uwNVh5zAg',
58
+ name: 'Aesthetes',
63
59
  weblinks: [
64
60
  {
65
- url: 'https://casinocoin.im',
66
- type: 'website',
61
+ url: 'https://aesthetes.art',
62
+ type: 'info',
67
63
  title: 'Official Website'
68
64
  },
69
65
  {
70
- url: 'https://twitter.com/CasinoCoin',
66
+ url: 'https://twitter.com/aesthetes_art',
71
67
  type: 'socialmedia'
72
68
  }
73
69
  ]
74
70
  }
75
71
  ],
72
+ tokens: [
73
+ {
74
+ currency: 'ELS',
75
+ issuer: 'rHXuEaRYnnJHbDeuBH5w8yPh5uwNVh5zAg',
76
+ name: 'Elysian',
77
+ desc: 'The first Token for the Art and NFT Industry running on the XRPL.',
78
+ icon: 'https://static.xrplmeta.org/icons/els.png',
79
+ asset_class: 'cryptocurrency',
80
+ weblinks: [
81
+ {
82
+ url: 'https://twitter.com/Elysianers',
83
+ type: 'community'
84
+ }
85
+ ]
86
+ }
87
+ ],
76
88
  issues: []
77
89
  }
78
90
 
package/xls26.js CHANGED
@@ -6,13 +6,27 @@
6
6
  import { parse as parseToml } from '@xrplkit/toml'
7
7
 
8
8
  const validWeblinkTypes = [
9
- 'website',
9
+ 'info',
10
10
  'socialmedia',
11
+ 'community',
11
12
  'support',
12
- 'sourcecode',
13
13
  'whitepaper',
14
- 'audit',
15
- 'report'
14
+ 'certificate'
15
+ ]
16
+
17
+ const validAdvisoryTypes = [
18
+ 'scam',
19
+ 'spam',
20
+ 'illegal',
21
+ 'offensive',
22
+ 'hijacked'
23
+ ]
24
+
25
+ const validAssetClasses = [
26
+ 'fiat',
27
+ 'commodity',
28
+ 'stocks',
29
+ 'cryptocurrency'
16
30
  ]
17
31
 
18
32
  const issuerFields = [
@@ -115,6 +129,13 @@ const tokenFields = [
115
129
  if(v < 0 || v > 3)
116
130
  throw 'has to be between 0 and 3'
117
131
  }
132
+ },
133
+ {
134
+ key: 'asset_class',
135
+ validate: v => {
136
+ if(!validAssetClasses.includes(v))
137
+ throw `needs to be one of the following: ${validAssetClasses.join(', ')}`
138
+ }
118
139
  }
119
140
  ]
120
141
 
@@ -143,6 +164,31 @@ const weblinkFields = [
143
164
  },
144
165
  ]
145
166
 
167
+ const advisoryFields = [
168
+ {
169
+ key: 'address',
170
+ essential: true,
171
+ validate: v => {
172
+ if(!/^[rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz]{25,35}$/.test(v))
173
+ throw 'is not a valid XRPL address'
174
+ },
175
+ },
176
+ {
177
+ key: 'type',
178
+ validate: v => {
179
+ if(!validAdvisoryTypes.includes(v))
180
+ throw `has to be one of (${validAdvisoryTypes.join(', ')})`
181
+ }
182
+ },
183
+ {
184
+ key: 'description',
185
+ alternativeKeys: ['desc'],
186
+ validate: v => {
187
+ if(typeof v !== 'string' || v.length === 0)
188
+ throw 'has to be a non empty string'
189
+ }
190
+ }
191
+ ]
146
192
 
147
193
  export function parse(str){
148
194
  try{
@@ -154,6 +200,7 @@ export function parse(str){
154
200
  let issuers = []
155
201
  let tokens = []
156
202
  let issues = []
203
+ let advisories = []
157
204
 
158
205
 
159
206
  if(toml.ISSUERS){
@@ -224,11 +271,27 @@ export function parse(str){
224
271
  }
225
272
  }
226
273
 
274
+ if(toml.ADVISORIES){
275
+ for(let stanza of toml.ADVISORIES){
276
+ let { valid, parsed: advisory, issues: advisoryIssues } = parseStanza(stanza, advisoryFields)
277
+
278
+ if(valid)
279
+ advisories.push(advisory)
280
+
281
+ issues.push(
282
+ ...advisoryIssues.map(
283
+ issue => `[[ADVISORIES]] ${issue}`
284
+ )
285
+ )
286
+ }
287
+ }
288
+
227
289
 
228
290
  return {
229
291
  issuers,
230
292
  tokens,
231
- issues
293
+ issues,
294
+ advisories
232
295
  }
233
296
  }
234
297
 
@@ -253,12 +316,12 @@ function parseStanza(stanza, schemas){
253
316
  try{
254
317
  validate(value)
255
318
  }catch(issue){
256
- issues.push(`${key} field: ${issue}`)
319
+ issues.push(`${k} field: ${issue}`)
257
320
  break
258
321
  }
259
322
  }
260
323
 
261
- parsed[k] = value
324
+ parsed[key] = value
262
325
  break
263
326
  }
264
327