-
Notifications
You must be signed in to change notification settings - Fork 1
/
zil-pay.js
52 lines (46 loc) · 1.47 KB
/
zil-pay.js
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
/*
* Project: ZilPay-wallet
* Author: Rinat(lich666dead)
* -----
* Modified By: the developer formerly known as Rinat(lich666dead) at <lich666black@gmail.com>
* -----
* Copyright (c) 2019 ZilPay
*/
import * as zilUtils from '@zilliqa-js/util'
import { Blockchain } from '@zilliqa-js/blockchain'
import { TransactionFactory } from '@zilliqa-js/account'
import { Contracts } from '@zilliqa-js/contract'
import {
fromBech32Address,
toBech32Address,
isValidChecksumAddress,
toChecksumAddress
} from '@zilliqa-js/crypto'
import HTTPProvider from './provider'
import Wallet from './wallet'
/**
* ZipPay Object which will be create in some tab.
* @param {Object} subjectStream Listener instance.
* @param {Object} stream Stream instance.
*/
export class ZilPay {
constructor(subjectStream, stream) {
if (!subjectStream || !stream) {
throw new Error('subjectStream and stream is necessary params.')
}
// Create instance Proxy provider.
this.provider = new HTTPProvider(subjectStream, stream)
// Redefined Wallet to work with user interface.
this.wallet = new Wallet(subjectStream, stream)
this.blockchain = new Blockchain(this.provider, this.wallet)
this.contracts = new Contracts(this.provider, this.wallet)
this.transactions = new TransactionFactory(this.provider, this.wallet)
this.utils = zilUtils
this.crypto = {
fromBech32Address,
toBech32Address,
isValidChecksumAddress,
toChecksumAddress
}
}
}