edge-currency-accountbased 0.7.72

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 (58) hide show
  1. package/CHANGELOG.md +713 -0
  2. package/LICENSE +29 -0
  3. package/README.md +63 -0
  4. package/index.js +3 -0
  5. package/lib/binance/bnbEngine.js +591 -0
  6. package/lib/binance/bnbInfo.js +43 -0
  7. package/lib/binance/bnbPlugin.js +168 -0
  8. package/lib/binance/bnbSchema.js +83 -0
  9. package/lib/binance/bnbTypes.js +39 -0
  10. package/lib/common/engine.js +918 -0
  11. package/lib/common/plugin.js +152 -0
  12. package/lib/common/schema.js +108 -0
  13. package/lib/common/types.js +85 -0
  14. package/lib/common/utils.js +378 -0
  15. package/lib/eos/eosEngine.js +1216 -0
  16. package/lib/eos/eosInfo.js +98 -0
  17. package/lib/eos/eosPlugin.js +314 -0
  18. package/lib/eos/eosSchema.js +190 -0
  19. package/lib/eos/eosTypes.js +88 -0
  20. package/lib/eos/telosInfo.js +94 -0
  21. package/lib/eos/waxInfo.js +95 -0
  22. package/lib/ethereum/etcInfo.js +121 -0
  23. package/lib/ethereum/ethEngine.js +832 -0
  24. package/lib/ethereum/ethInfo.js +1300 -0
  25. package/lib/ethereum/ethMiningFees.js +157 -0
  26. package/lib/ethereum/ethNetwork.js +2195 -0
  27. package/lib/ethereum/ethPlugin.js +377 -0
  28. package/lib/ethereum/ethSchema.js +61 -0
  29. package/lib/ethereum/ethTypes.js +461 -0
  30. package/lib/ethereum/ftminfo.js +102 -0
  31. package/lib/ethereum/rskInfo.js +101 -0
  32. package/lib/fio/fioConst.js +38 -0
  33. package/lib/fio/fioEngine.js +1250 -0
  34. package/lib/fio/fioError.js +38 -0
  35. package/lib/fio/fioInfo.js +72 -0
  36. package/lib/fio/fioPlugin.js +486 -0
  37. package/lib/fio/fioSchema.js +56 -0
  38. package/lib/index.js +44 -0
  39. package/lib/pluginError.js +32 -0
  40. package/lib/react-native/edge-currency-accountbased.js +239635 -0
  41. package/lib/react-native/edge-currency-accountbased.js.map +1 -0
  42. package/lib/react-native-io.js +41 -0
  43. package/lib/stellar/stellarEngine.js +563 -0
  44. package/lib/stellar/stellarInfo.js +37 -0
  45. package/lib/stellar/stellarPlugin.js +215 -0
  46. package/lib/stellar/stellarSchema.js +54 -0
  47. package/lib/stellar/stellarTypes.js +66 -0
  48. package/lib/tezos/tezosEngine.js +497 -0
  49. package/lib/tezos/tezosInfo.js +60 -0
  50. package/lib/tezos/tezosPlugin.js +174 -0
  51. package/lib/tezos/tezosTypes.js +110 -0
  52. package/lib/xrp/xrpEngine.js +583 -0
  53. package/lib/xrp/xrpInfo.js +47 -0
  54. package/lib/xrp/xrpPlugin.js +229 -0
  55. package/lib/xrp/xrpSchema.js +74 -0
  56. package/lib/xrp/xrpTypes.js +38 -0
  57. package/package.json +139 -0
  58. package/postinstall.sh +7 -0
@@ -0,0 +1,38 @@
1
+ //
2
+
3
+ import { currencyInfo } from './fioInfo.js'
4
+
5
+ export const fioApiErrorCodes = [400, 403, 404]
6
+ export const fioRegApiErrorCodes = {
7
+ INVALID_FIO_NAME: currencyInfo.defaultSettings.errorCodes.INVALID_FIO_ADDRESS,
8
+ ALREADY_REGISTERED:
9
+ currencyInfo.defaultSettings.errorCodes.ALREADY_REGISTERED,
10
+ DOMAIN_IS_NOT_REGISTERED:
11
+ currencyInfo.defaultSettings.errorCodes.FIO_DOMAIN_IS_NOT_EXIST,
12
+ DOMAIN_IS_NOT_PUBLIC:
13
+ currencyInfo.defaultSettings.errorCodes.FIO_DOMAIN_IS_NOT_PUBLIC,
14
+ SERVER_ERROR: currencyInfo.defaultSettings.errorCodes.SERVER_ERROR,
15
+ ALREADY_SENT_REGISTRATION_REQ_FOR_DOMAIN:
16
+ currencyInfo.defaultSettings.errorCodes
17
+ .ALREADY_SENT_REGISTRATION_REQ_FOR_DOMAIN
18
+ }
19
+
20
+ export class FioError extends Error {
21
+
22
+
23
+
24
+
25
+
26
+ constructor(message, code, labelCode, json) {
27
+ super(message)
28
+
29
+ if (Error.captureStackTrace) {
30
+ Error.captureStackTrace(this, FioError)
31
+ }
32
+
33
+ this.name = 'FioError'
34
+ if (code) this.errorCode = code
35
+ if (labelCode) this.labelCode = labelCode
36
+ if (json) this.json = json
37
+ }
38
+ }
@@ -0,0 +1,72 @@
1
+
2
+
3
+
4
+
5
+
6
+ const defaultSettings = {
7
+ apiUrls: [
8
+ 'https://fio.eu.eosamsterdam.net/v1/',
9
+ 'https://fio.eosdac.io/v1/',
10
+ 'https://fio.eosphere.io/v1/',
11
+ 'https://fio.eosrio.io/v1/',
12
+ 'https://fio.acherontrading.com/v1/',
13
+ 'https://fio.eos.barcelona/v1/',
14
+ 'https://api.fio.eosdetroit.io/v1/',
15
+ 'https://fio.zenblocks.io/v1/',
16
+ 'https://api.fio.alohaeos.com/v1/',
17
+ 'https://fio.greymass.com/v1/',
18
+ 'https://fio.eosusa.news/v1/',
19
+ 'https://fio.eosargentina.io/v1/',
20
+ 'https://fio.cryptolions.io/v1/',
21
+ 'https://fio-mainnet.eosblocksmith.io/v1/',
22
+ 'https://api.fio.currencyhub.io/v1/',
23
+ 'https://fio.eoscannon.io/v1/',
24
+ 'https://fio.eosdublin.io/v1/',
25
+ 'https://api.fiosweden.org/v1/'
26
+ ],
27
+ historyNodeUrls: [
28
+ 'https://fio.greymass.com/v1/',
29
+ 'https://fio.greymass.com/v1/',
30
+ 'https://fio.eosphere.io/v1/',
31
+ 'https://fio.eossweden.org/v1/'
32
+ ],
33
+ fioRegApiUrl: 'https://reg.fioprotocol.io/public-api/',
34
+ fioDomainRegUrl: 'https://reg.fioprotocol.io/domain/',
35
+ fioAddressRegUrl: 'https://reg.fioprotocol.io/address/',
36
+ defaultRef: 'edge',
37
+ fallbackRef: 'edge',
38
+ freeAddressRef: 'edgefree',
39
+ errorCodes: {
40
+ INVALID_FIO_ADDRESS: 'INVALID_FIO_ADDRESS',
41
+ ALREADY_REGISTERED: 'ALREADY_REGISTERED',
42
+ FIO_ADDRESS_IS_NOT_EXIST: 'FIO_ADDRESS_IS_NOT_EXIST',
43
+ FIO_DOMAIN_IS_NOT_EXIST: 'FIO_DOMAIN_IS_NOT_EXIST',
44
+ FIO_DOMAIN_IS_NOT_PUBLIC: 'FIO_DOMAIN_IS_NOT_PUBLIC',
45
+ IS_DOMAIN_PUBLIC_ERROR: 'IS_DOMAIN_PUBLIC_ERROR',
46
+ FIO_ADDRESS_IS_NOT_LINKED: 'FIO_ADDRESS_IS_NOT_LINKED',
47
+ SERVER_ERROR: 'SERVER_ERROR'
48
+ }
49
+ }
50
+
51
+ export const currencyInfo = {
52
+ // Basic currency information:
53
+ currencyCode: 'FIO',
54
+ displayName: 'FIO',
55
+ pluginId: 'fio',
56
+ walletType: 'wallet:fio',
57
+
58
+ defaultSettings,
59
+
60
+ addressExplorer: 'https://fio.bloks.io/key/%s',
61
+ transactionExplorer: 'https://fio.bloks.io/transaction/%s',
62
+
63
+ denominations: [
64
+ // An array of Objects of the possible denominations for this currency
65
+ {
66
+ name: 'FIO',
67
+ multiplier: '1000000000',
68
+ symbol: 'ᵮ'
69
+ }
70
+ ],
71
+ metaTokens: []
72
+ }
@@ -0,0 +1,486 @@
1
+ //
2
+
3
+ import { FIOSDK } from '@fioprotocol/fiosdk'
4
+ import { Transactions } from '@fioprotocol/fiosdk/lib/transactions/Transactions'
5
+ import { bns } from 'biggystring'
6
+ import { validateMnemonic } from 'bip39'
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+ import ecc from 'eosjs-ecc'
18
+
19
+ import { CurrencyPlugin } from '../common/plugin.js'
20
+ import { asyncWaterfall, getDenomInfo, shuffleArray } from '../common/utils'
21
+ import { FIO_REG_API_ENDPOINTS } from './fioConst.js'
22
+ import { FioEngine } from './fioEngine'
23
+ import { fioApiErrorCodes, FioError, fioRegApiErrorCodes } from './fioError.js'
24
+ import { currencyInfo } from './fioInfo.js'
25
+
26
+ const FIO_CURRENCY_CODE = 'FIO'
27
+ const FIO_TYPE = 'fio'
28
+ const FIO_REG_SITE_API_KEY = ''
29
+
30
+
31
+
32
+ export function checkAddress(address) {
33
+ const start = address.startsWith(FIO_CURRENCY_CODE)
34
+ const length = address.length === 53
35
+ return start && length
36
+ }
37
+
38
+ export class FioPlugin extends CurrencyPlugin {
39
+
40
+
41
+ constructor(io) {
42
+ super(io, FIO_TYPE, currencyInfo)
43
+ }
44
+
45
+ async importPrivateKey(userInput) {
46
+ const { pluginId } = this.currencyInfo
47
+ const keys = {}
48
+ if (/[0-9a-zA-Z]{51}$/.test(userInput)) {
49
+ if (!ecc.isValidPrivate(userInput)) {
50
+ throw new Error('Invalid private key')
51
+ }
52
+
53
+ keys.fioKey = userInput
54
+ } else {
55
+ // it looks like a mnemonic, so validate that way:
56
+ if (!validateMnemonic(userInput)) {
57
+ // "input" instead of "mnemonic" in case private key
58
+ // was just the wrong length
59
+ throw new Error('Invalid input')
60
+ }
61
+ const privKeys = await FIOSDK.createPrivateKeyMnemonic(userInput)
62
+ keys.fioKey = privKeys.fioKey
63
+ keys.mnemonic = privKeys.mnemonic
64
+ }
65
+
66
+ // Validate the address derivation:
67
+ const pubKeys = await this.derivePublicKey({
68
+ type: `wallet:${pluginId}`,
69
+ id: 'fake',
70
+ keys
71
+ })
72
+ keys.publicKey = pubKeys.publicKey
73
+
74
+ return keys
75
+ }
76
+
77
+ async createPrivateKey(walletType) {
78
+ const type = walletType.replace('wallet:', '')
79
+ if (type === FIO_TYPE) {
80
+ const buffer = this.io.random(32)
81
+ return FIOSDK.createPrivateKey(buffer)
82
+ } else {
83
+ throw new Error('InvalidWalletType')
84
+ }
85
+ }
86
+
87
+ async derivePublicKey(walletInfo) {
88
+ const type = walletInfo.type.replace('wallet:', '')
89
+ if (type === FIO_TYPE) {
90
+ return FIOSDK.derivedPublicKey(walletInfo.keys.fioKey)
91
+ } else {
92
+ throw new Error('InvalidWalletType')
93
+ }
94
+ }
95
+
96
+ async parseUri(uri) {
97
+ const { edgeParsedUri } = this.parseUriCommon(
98
+ currencyInfo,
99
+ uri,
100
+ {
101
+ fio: true
102
+ },
103
+ FIO_CURRENCY_CODE
104
+ )
105
+ const valid = checkAddress(edgeParsedUri.publicAddress || '')
106
+ if (!valid) {
107
+ throw new Error('InvalidPublicAddressError')
108
+ }
109
+
110
+ return edgeParsedUri
111
+ }
112
+
113
+ async encodeUri(obj) {
114
+ const valid = checkAddress(obj.publicAddress)
115
+ if (!valid) {
116
+ throw new Error('InvalidPublicAddressError')
117
+ }
118
+ let amount
119
+ if (typeof obj.nativeAmount === 'string') {
120
+ const currencyCode = FIO_CURRENCY_CODE
121
+ const nativeAmount = obj.nativeAmount
122
+ const denom = getDenomInfo(currencyInfo, currencyCode)
123
+ if (!denom) {
124
+ throw new Error('InternalErrorInvalidCurrencyCode')
125
+ }
126
+ amount = bns.div(nativeAmount, denom.multiplier, 16)
127
+ }
128
+ const encodedUri = this.encodeUriCommon(obj, FIO_TYPE, amount)
129
+ return encodedUri
130
+ }
131
+ }
132
+
133
+ export function makeFioPlugin(opts) {
134
+ const { initOptions, io } = opts
135
+ const { fetchCors = io.fetch } = io
136
+ const { tpid = 'finance@edge', fioRegApiToken = FIO_REG_SITE_API_KEY } =
137
+ initOptions
138
+ const connection = new FIOSDK('', '', '', fetchCors, undefined, tpid)
139
+
140
+ let toolsPromise
141
+ function makeCurrencyTools() {
142
+ if (toolsPromise != null) return toolsPromise
143
+ toolsPromise = Promise.resolve(new FioPlugin(io))
144
+ return toolsPromise
145
+ }
146
+
147
+ async function multicastServers(
148
+ actionName,
149
+ params
150
+ ) {
151
+ const res = await asyncWaterfall(
152
+ shuffleArray(
153
+ currencyInfo.defaultSettings.apiUrls.map(apiUrl => async () => {
154
+ let out
155
+
156
+ Transactions.baseUrl = apiUrl
157
+
158
+ try {
159
+ out = await connection.genericAction(actionName, params)
160
+ } catch (e) {
161
+ // handle FIO API error
162
+ if (e.errorCode && fioApiErrorCodes.indexOf(e.errorCode) > -1) {
163
+ out = {
164
+ isError: true,
165
+ data: {
166
+ code: e.errorCode,
167
+ message: e.message,
168
+ json: e.json,
169
+ list: e.list
170
+ }
171
+ }
172
+ } else {
173
+ throw e
174
+ }
175
+ }
176
+
177
+ return out
178
+ })
179
+ )
180
+ )
181
+
182
+ if (res.isError) {
183
+ const error = new FioError(res.errorMessage)
184
+ error.json = res.data.json
185
+ error.list = res.data.list
186
+ error.errorCode = res.data.code
187
+
188
+ throw error
189
+ }
190
+
191
+ return res
192
+ }
193
+
194
+ async function makeCurrencyEngine(
195
+ walletInfo,
196
+ opts
197
+ ) {
198
+ const tools = await makeCurrencyTools()
199
+ const currencyEngine = new FioEngine(
200
+ tools,
201
+ walletInfo,
202
+ opts,
203
+ fetchCors,
204
+ tpid
205
+ )
206
+ await currencyEngine.loadEngine(tools, walletInfo, opts)
207
+
208
+ // This is just to make sure otherData is Flow type checked
209
+ currencyEngine.otherData = currencyEngine.walletLocalData.otherData
210
+
211
+ // Initialize otherData defaults if they weren't on disk
212
+ if (!currencyEngine.otherData.highestTxHeight) {
213
+ currencyEngine.otherData.highestTxHeight = 0
214
+ }
215
+ if (!currencyEngine.otherData.fioAddresses) {
216
+ currencyEngine.otherData.fioAddresses = []
217
+ }
218
+ if (!currencyEngine.otherData.fioDomains) {
219
+ currencyEngine.otherData.fioDomains = []
220
+ }
221
+ if (!currencyEngine.otherData.fioRequestsToApprove) {
222
+ currencyEngine.otherData.fioRequestsToApprove = {}
223
+ }
224
+
225
+ const out = currencyEngine
226
+ return out
227
+ }
228
+
229
+ const otherMethods = {
230
+ async getConnectedPublicAddress(
231
+ fioAddress,
232
+ chainCode,
233
+ tokenCode
234
+ ) {
235
+ try {
236
+ FIOSDK.isFioAddressValid(fioAddress)
237
+ } catch (e) {
238
+ throw new FioError(
239
+ '',
240
+ 400,
241
+ currencyInfo.defaultSettings.errorCodes.INVALID_FIO_ADDRESS
242
+ )
243
+ }
244
+ try {
245
+ const isAvailableRes = await multicastServers('isAvailable', {
246
+ fioName: fioAddress
247
+ })
248
+ if (!isAvailableRes.is_registered) {
249
+ throw new FioError(
250
+ '',
251
+ 404,
252
+ currencyInfo.defaultSettings.errorCodes.FIO_ADDRESS_IS_NOT_EXIST
253
+ )
254
+ }
255
+ } catch (e) {
256
+ if (
257
+ e.name === 'FioError' &&
258
+ e.json &&
259
+ e.json.fields &&
260
+ e.errorCode === 400
261
+ ) {
262
+ e.labelCode =
263
+ currencyInfo.defaultSettings.errorCodes.INVALID_FIO_ADDRESS
264
+ }
265
+
266
+ throw e
267
+ }
268
+ try {
269
+ const result = await multicastServers('getPublicAddress', {
270
+ fioAddress,
271
+ chainCode,
272
+ tokenCode
273
+ })
274
+ if (!result.public_address || result.public_address === '0') {
275
+ throw new FioError(
276
+ '',
277
+ 404,
278
+ currencyInfo.defaultSettings.errorCodes.FIO_ADDRESS_IS_NOT_LINKED
279
+ )
280
+ }
281
+ return result
282
+ } catch (e) {
283
+ if (
284
+ (e.name === 'FioError' &&
285
+ e.labelCode ===
286
+ currencyInfo.defaultSettings.errorCodes
287
+ .FIO_ADDRESS_IS_NOT_LINKED) ||
288
+ e.errorCode === 404
289
+ ) {
290
+ throw new FioError(
291
+ '',
292
+ 404,
293
+ currencyInfo.defaultSettings.errorCodes.FIO_ADDRESS_IS_NOT_LINKED
294
+ )
295
+ }
296
+ throw e
297
+ }
298
+ },
299
+ async isFioAddressValid(fioAddress) {
300
+ try {
301
+ return FIOSDK.isFioAddressValid(fioAddress)
302
+ } catch (e) {
303
+ return false
304
+ }
305
+ },
306
+ async validateAccount(
307
+ fioName,
308
+ isDomain = false
309
+ ) {
310
+ try {
311
+ if (isDomain) {
312
+ if (!FIOSDK.isFioDomainValid(fioName)) return false
313
+ } else {
314
+ if (!FIOSDK.isFioAddressValid(fioName)) return false
315
+ }
316
+ } catch (e) {
317
+ throw new FioError(
318
+ '',
319
+ 400,
320
+ currencyInfo.defaultSettings.errorCodes.INVALID_FIO_ADDRESS
321
+ )
322
+ }
323
+ try {
324
+ const isAvailableRes = await multicastServers('isAvailable', {
325
+ fioName
326
+ })
327
+
328
+ return !isAvailableRes.is_registered
329
+ } catch (e) {
330
+ if (
331
+ e.name === 'FioError' &&
332
+ e.json &&
333
+ e.json.fields &&
334
+ e.errorCode === 400
335
+ ) {
336
+ e.labelCode =
337
+ currencyInfo.defaultSettings.errorCodes.INVALID_FIO_ADDRESS
338
+ }
339
+
340
+ throw e
341
+ }
342
+ },
343
+ async isDomainPublic(domain) {
344
+ const isAvailableRes = await multicastServers('isAvailable', {
345
+ fioName: domain
346
+ })
347
+ if (!isAvailableRes.is_registered)
348
+ throw new FioError(
349
+ '',
350
+ 400,
351
+ currencyInfo.defaultSettings.errorCodes.FIO_DOMAIN_IS_NOT_EXIST
352
+ )
353
+ const result = await fetchCors(
354
+ `${currencyInfo.defaultSettings.fioRegApiUrl}${FIO_REG_API_ENDPOINTS.isDomainPublic}/${domain}`,
355
+ {
356
+ method: 'GET'
357
+ }
358
+ )
359
+ if (!result.ok) {
360
+ const data = await result.json()
361
+ throw new FioError(
362
+ '',
363
+ result.status,
364
+ currencyInfo.defaultSettings.errorCodes.IS_DOMAIN_PUBLIC_ERROR,
365
+ data
366
+ )
367
+ }
368
+ const { isPublic } = await result.json()
369
+ return isPublic
370
+ },
371
+ async doesAccountExist(fioName) {
372
+ try {
373
+ if (!FIOSDK.isFioAddressValid(fioName)) return false
374
+ } catch (e) {
375
+ return false
376
+ }
377
+ try {
378
+ const isAvailableRes = await multicastServers('isAvailable', {
379
+ fioName
380
+ })
381
+
382
+ return isAvailableRes.is_registered
383
+ } catch (e) {
384
+ this.log.error('doesAccountExist error: ' + e)
385
+ return false
386
+ }
387
+ },
388
+ async buyAddressRequest(
389
+ options
390
+
391
+
392
+
393
+
394
+ ,
395
+ isFree = false
396
+ ) {
397
+ const headers = {
398
+ Accept: 'application/json',
399
+ 'Content-Type': 'application/json'
400
+ }
401
+ if (isFree) {
402
+ options.apiToken = fioRegApiToken
403
+ }
404
+ try {
405
+ const result = await fetchCors(
406
+ `${currencyInfo.defaultSettings.fioRegApiUrl}${FIO_REG_API_ENDPOINTS.buyAddress}`,
407
+ {
408
+ method: 'POST',
409
+ headers,
410
+ body: JSON.stringify(options)
411
+ }
412
+ )
413
+ if (!result.ok) {
414
+ const data = await result.json()
415
+
416
+ if (fioRegApiErrorCodes[data.errorCode]) {
417
+ throw new FioError(
418
+ data.error,
419
+ result.status,
420
+ fioRegApiErrorCodes[data.errorCode],
421
+ data
422
+ )
423
+ }
424
+
425
+ if (data.error === 'Already registered') {
426
+ throw new FioError(
427
+ data.error,
428
+ result.status,
429
+ fioRegApiErrorCodes.ALREADY_REGISTERED,
430
+ data
431
+ )
432
+ }
433
+
434
+ throw new Error(data.error)
435
+ }
436
+ return result.json()
437
+ } catch (e) {
438
+ if (e.labelCode) throw e
439
+ throw new FioError(
440
+ e.message,
441
+ 500,
442
+ currencyInfo.defaultSettings.errorCodes.SERVER_ERROR
443
+ )
444
+ }
445
+ },
446
+ async getDomains(ref = '') {
447
+ if (!ref) ref = currencyInfo.defaultSettings.defaultRef
448
+ try {
449
+ const result = await fetchCors(
450
+ `${currencyInfo.defaultSettings.fioRegApiUrl}${FIO_REG_API_ENDPOINTS.getDomains}/${ref}`,
451
+ {
452
+ method: 'GET'
453
+ }
454
+ )
455
+ const json = await result.json()
456
+ if (!result.ok) {
457
+ if (fioRegApiErrorCodes[json.errorCode]) {
458
+ throw new FioError(
459
+ json.error,
460
+ result.status,
461
+ fioRegApiErrorCodes[json.errorCode],
462
+ json
463
+ )
464
+ }
465
+
466
+ throw new Error(json.error)
467
+ }
468
+ return json.domains
469
+ } catch (e) {
470
+ if (e.labelCode) throw e
471
+ throw new FioError(
472
+ e.message,
473
+ 500,
474
+ currencyInfo.defaultSettings.errorCodes.SERVER_ERROR
475
+ )
476
+ }
477
+ }
478
+ }
479
+
480
+ return {
481
+ currencyInfo,
482
+ makeCurrencyEngine,
483
+ makeCurrencyTools,
484
+ otherMethods
485
+ }
486
+ }
@@ -0,0 +1,56 @@
1
+ //
2
+
3
+ import { asArray, asNumber, asObject, asOptional, asString } from 'cleaners'
4
+
5
+ export const asGetFioName = asObject({
6
+ fio_domains: asArray(
7
+ asObject({
8
+ fio_domain: asString,
9
+ expiration: asString,
10
+ is_public: asNumber
11
+ })
12
+ ),
13
+ fio_addresses: asArray(
14
+ asObject({
15
+ fio_address: asString,
16
+ expiration: asString
17
+ })
18
+ )
19
+ })
20
+
21
+
22
+
23
+ export const asFioHistoryNodeAction = asObject({
24
+ account_action_seq: asNumber,
25
+ block_num: asNumber,
26
+ block_time: asString,
27
+ action_trace: asObject({
28
+ receiver: asString,
29
+ act: asObject({
30
+ account: asString,
31
+ name: asString,
32
+ data: asObject({
33
+ payee_public_key: asOptional(asString),
34
+ amount: asOptional(asNumber),
35
+ max_fee: asOptional(asNumber),
36
+ actor: asOptional(asString),
37
+ tpid: asOptional(asString),
38
+ quantity: asOptional(asString),
39
+ memo: asOptional(asString),
40
+ to: asOptional(asString),
41
+ from: asOptional(asString)
42
+ }),
43
+ hex_data: asString
44
+ }),
45
+ trx_id: asString,
46
+ block_num: asNumber,
47
+ block_time: asString,
48
+ producer_block_id: asString
49
+ })
50
+ })
51
+
52
+ export const asHistoryResponse = asObject({
53
+ actions: asArray(asFioHistoryNodeAction)
54
+ })
55
+
56
+
package/lib/index.js ADDED
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Created by paul on 8/8/17.
3
+ */
4
+ //
5
+
6
+ import 'regenerator-runtime/runtime'
7
+
8
+ import { makeBinancePlugin } from './binance/bnbPlugin.js'
9
+ import { makeEosPlugin } from './eos/eosInfo.js'
10
+ import { makeTelosPlugin } from './eos/telosInfo.js'
11
+ import { makeWaxPlugin } from './eos/waxInfo.js'
12
+ import { makeEthereumClassicPlugin } from './ethereum/etcInfo.js'
13
+ import { makeEthereumPlugin } from './ethereum/ethInfo.js'
14
+ import { makeFantomPlugin } from './ethereum/ftminfo.js'
15
+ import { makeRskPlugin } from './ethereum/rskInfo.js'
16
+ import { makeFioPlugin } from './fio/fioPlugin'
17
+ import { makeStellarPlugin } from './stellar/stellarPlugin.js'
18
+ import { makeTezosPlugin } from './tezos/tezosPlugin.js'
19
+ import { makeRipplePlugin } from './xrp/xrpPlugin.js'
20
+
21
+ const plugins = {
22
+ eos: makeEosPlugin,
23
+ telos: makeTelosPlugin,
24
+ wax: makeWaxPlugin,
25
+ ethereum: makeEthereumPlugin,
26
+ ethereumclassic: makeEthereumClassicPlugin,
27
+ fantom: makeFantomPlugin,
28
+ fio: makeFioPlugin,
29
+ // "ripple" is network name. XRP is just an asset:
30
+ ripple: makeRipplePlugin,
31
+ stellar: makeStellarPlugin,
32
+ tezos: makeTezosPlugin,
33
+ rsk: makeRskPlugin,
34
+ binance: makeBinancePlugin
35
+ }
36
+
37
+ if (
38
+ typeof window !== 'undefined' &&
39
+ typeof window.addEdgeCorePlugins === 'function'
40
+ ) {
41
+ window.addEdgeCorePlugins(plugins)
42
+ }
43
+
44
+ export default plugins