forked from Bitcoin-com/slp-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SLP.ts
60 lines (51 loc) · 1.52 KB
/
SLP.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// imports
import { BITBOX } from "bitbox-sdk"
import Address from "./Address"
import ECPair from "./ECPair"
import HDNode from "./HDNode"
import { IConfig } from "./interfaces/SLPInterfaces"
import { SLPDB } from "./SLPDB"
import { Socket } from "./Socket"
import TokenType1 from "./TokenType1"
import Util from "./Util"
// exports
const REST_URL = "https://rest.bitcoin.com/v2/"
const TREST_URL = "https://trest.bitcoin.com/v2/"
const SLPDB_URL = "https://slpdb.bitcoin.com/"
const TSLPDB_URL = "https://tslpdb.bitcoin.com/"
// consts
const slpjs = require("slpjs")
//const slpjs = require("/home/trout/work/bch/slpjs/lib/slp.js")
// SLP SDK is a superset of BITBOX SDK <3
class SLP extends BITBOX {
slpdbURL: string
Address: any
HDNode: any
SLPDB: SLPDB
TokenType1: TokenType1
Util: any
Utils: any
slpjs: any
constructor(config: IConfig = {}) {
super(config)
let restURL: string
if (config && config.restURL && config.restURL !== "")
restURL = config.restURL
else restURL = REST_URL
if (config && config.slpdbURL && config.slpdbURL !== "")
this.slpdbURL = config.slpdbURL
else this.slpdbURL = SLPDB_URL
this.Address = new Address(restURL)
this.ECPair = new ECPair()
this.HDNode = new HDNode(restURL)
this.SLPDB = new SLPDB(this.slpdbURL)
this.Socket = Socket
this.TokenType1 = new TokenType1(restURL)
this.Util = new Util(restURL)
// Maintain backwards compatibility.
this.Utils = this.Util
// Expose slpjs
this.slpjs = slpjs
}
}
export = SLP