File tree Expand file tree Collapse file tree 9 files changed +1042
-959
lines changed
Expand file tree Collapse file tree 9 files changed +1042
-959
lines changed Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 8484 ·
8585 ·
8686 ·
87- < button onClick ="runBlockchain('bch ') " id ="goBtn "> Blockchain Method</ button >
87+ < button onClick ="runBlockchain('xlm ') " id ="goBtn "> Blockchain Method</ button >
8888 </ div >
8989 < div id ="output ">
9090 < p > Results< p >
108108 console . log ( 'status ->' , status . type )
109109 } )
110110
111- web3data . on ( { eventName : 'block' } , data => {
112- console . log ( 'block' , data )
113- setResult ( data )
114- } )
115- web3data . on ( { eventName : 'block' , filters : { number : 605859 } } , data => {
116- console . log ( 'block NUMBER' , data )
117- setResult ( data )
118- } )
111+ // web3data.on({eventName: 'block'}, data => {
112+ // console.log('block', data)
113+ // setResult(data)
114+ // })
115+ // web3data.on({eventName: 'block', filters: { number: 26811436 }}, data => {
116+ // console.log('block NUMBER', data)
117+ // setResult(data)
118+ // })
119119 web3data . on ( { eventName : 'transaction' } , data => {
120120 console . log ( 'transaction' , data )
121121 setResult ( data )
140140 }
141141
142142 // run specific blockchain things
143- const activeBlockchain = 'btc '
143+ const activeBlockchain = 'xlm '
144144 function runBlockchain ( namespace ) {
145145 namespace = namespace || activeBlockchain
146146 const apiKey = document . querySelector ( '#apikey-input' ) . value
Original file line number Diff line number Diff line change 11{
22 "name" : " web3data-js" ,
3- "version" : " 0.6.0 " ,
3+ "version" : " 0.6.1 " ,
44 "description" : " A javascript wrapper for accessing amberdata's public API." ,
55 "main" : " index.js" ,
66 "browser" : " dist/web3data.min.js" ,
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ module.exports.BLOCKCHAIN_ID_BITCOIN_SV = 'a818635d36dbe125e26167c4438e2217'
1313module . exports . BLOCKCHAIN_ID_LITECOIN = 'f94be61fd9f4fa684f992ddfd4e92272'
1414module . exports . BLOCKCHAIN_ID_RIPPLE = '2b8a5d8975e8c2a2ed92450450979a3c'
1515module . exports . BLOCKCHAIN_ID_ZCASH = 'b7d4f994f33c709be4ce6cbae31d7b8e'
16+ module . exports . BLOCKCHAIN_ID_STELLAR = '822e2ebe02f74df8'
1617
1718/* Endpoints */
1819module . exports . ADDRESSES_ENDPOINT = '/addresses'
@@ -106,5 +107,30 @@ module.exports.LTC_METHODS = {
106107 transaction : [ 'getTransactions' , 'getTransaction' , 'getPendingTransactions' ]
107108}
108109
110+ module . exports . XLM_METHODS = {
111+ address : [
112+ 'getAllAddresses' ,
113+ 'getInformation' ,
114+ 'getMetadata' ,
115+ 'getTransactions' ,
116+ // 'getPendingTransactions',
117+ 'getBalance' ,
118+ 'getMetrics'
119+ ] ,
120+ block : [
121+ 'getBlocks' ,
122+ 'getBlock' ,
123+ 'getBlockNumber' ,
124+ 'getTransactions' ,
125+ 'getTransactionFromBlock' ,
126+ 'getMetrics'
127+ ] ,
128+ transaction : [
129+ 'getTransactions' ,
130+ 'getTransaction'
131+ // 'getPendingTransactions'
132+ ]
133+ }
134+
109135/* HTTP Response codes */
110136module . exports . HTTP_CODE_NOT_FOUND = 404
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ const Btc = require('./btc')
1919const Bch = require ( './bch' )
2020const Bsv = require ( './bsv' )
2121const Ltc = require ( './ltc' )
22+ const Xlm = require ( './xlm' )
2223const Zec = require ( './zec' )
2324const WebSocketClient = require ( './websocket' )
2425
@@ -128,6 +129,7 @@ class Web3Data extends Web3DataFactory {
128129 this . bch = new Bch ( Web3DataFactory , apiKey , options )
129130 this . bsv = new Bsv ( Web3DataFactory , apiKey , options )
130131 this . ltc = new Ltc ( Web3DataFactory , apiKey , options )
132+ this . xlm = new Xlm ( Web3DataFactory , apiKey , options )
131133 this . zec = new Zec ( Web3DataFactory , apiKey , options )
132134
133135 this . websocket = null
Original file line number Diff line number Diff line change 1+ const {
2+ BLOCKCHAIN_ID_STELLAR : BLOCKCHAIN_ID ,
3+ BTC_METHODS : METHODS
4+ } = require ( './constants' )
5+ const { methodFactory} = require ( './utils' )
6+
7+ /**
8+ * Class for all Stellar based methods.
9+ *
10+ * @private
11+ */
12+ class Xlm {
13+ constructor ( Web3data , apiKey , options ) {
14+ options . blockchainId = BLOCKCHAIN_ID
15+ this . web3data = new Web3data ( apiKey , options )
16+ methodFactory ( this , METHODS )
17+ }
18+
19+ /* See Web3Data class for details on rpc method */
20+ rpc ( method , params ) {
21+ return this . web3data . rpc ( method , params )
22+ }
23+ }
24+
25+ module . exports = Xlm
Original file line number Diff line number Diff line change 1+ import test from 'ava'
2+ import { setUpPolly , getNewWeb3DataInstance } from "./utils" ;
3+ import { XLM_METHODS as METHODS } from "../src/constants" ;
4+
5+ /***********************************
6+ * -------- Tests Setup ---------- *
7+ **********************************/
8+ test . before ( t => {
9+ t . context . polly = setUpPolly ( 'xlm' )
10+ } )
11+
12+ test . after ( async t => {
13+ await t . context . polly . stop ( )
14+ } )
15+
16+ test . beforeEach ( t => {
17+ t . context . web3data = getNewWeb3DataInstance ( )
18+ } ) ;
19+
20+ /*********************************
21+ * ----------- Tests ----------- *
22+ *********************************/
23+
24+ test ( 'Check the xlm namespace contains all defined methods' , t => {
25+ for ( const namespace of Object . keys ( METHODS ) ) {
26+ for ( const method of METHODS [ namespace ] ) {
27+ t . truthy ( t . context . web3data . xlm [ namespace ] [ method ] )
28+ }
29+ }
30+ } )
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { BTC_METHODS as METHODS } from "../src/constants";
66 * -------- Tests Setup ---------- *
77 **********************************/
88test . before ( t => {
9- t . context . polly = setUpPolly ( 'ltc ' )
9+ t . context . polly = setUpPolly ( 'zec ' )
1010} )
1111
1212test . after ( async t => {
You can’t perform that action at this time.
0 commit comments