|
| 1 | +import { ec } from 'elliptic'; |
1 | 2 | import * as fs from 'fs'; |
2 | | -import * as BitPaySDK from '../index'; |
3 | 3 | import * as readline from 'readline'; |
| 4 | +import * as BitPaySDK from '../index'; |
4 | 5 |
|
5 | 6 | const keyUtils = new BitPaySDK.KeyUtils(); |
6 | 7 | let configFilePath = process.cwd(); |
7 | | -let keyPair; |
8 | | -let ecKey; |
9 | | -let environment; |
| 8 | +let keyPair: ec.KeyPair; |
| 9 | +let ecKey: ec.KeyPair; |
| 10 | +let environment: string; |
10 | 11 | // eslint-disable-next-line @typescript-eslint/no-unused-vars |
11 | 12 | let storeFile = true; |
12 | | -let apiUrl; |
13 | | -let merchantToken; |
14 | | -let merchantPairCode; |
15 | | -let payoutToken; |
16 | | -let payoutPairCode; |
| 13 | +let apiUrl: string; |
| 14 | +let merchantToken: string; |
| 15 | +let merchantPairCode: string; |
| 16 | +let payoutToken: string; |
| 17 | +let payoutPairCode: string; |
17 | 18 | let keyPath = ''; |
18 | 19 | let keyPlain = ''; |
19 | 20 |
|
@@ -48,7 +49,7 @@ const selectEnv = async () => { |
48 | 49 | console.log(e); |
49 | 50 | } |
50 | 51 | }; |
51 | | -const setEnv = async (env) => { |
| 52 | +const setEnv = async (env: string) => { |
52 | 53 | if (env == 'Test') { |
53 | 54 | apiUrl = 'https://test.bitpay.com'; |
54 | 55 | return; |
@@ -84,7 +85,7 @@ const createNewKey = async () => { |
84 | 85 | console.log(e); |
85 | 86 | } |
86 | 87 | }; |
87 | | -const loadKey = async (privateKey) => { |
| 88 | +const loadKey = async (privateKey: string) => { |
88 | 89 | try { |
89 | 90 | if (fs.existsSync(privateKey)) { |
90 | 91 | console.log('Loading private key... \n'); |
@@ -205,11 +206,11 @@ const selectTokens = async () => { |
205 | 206 | console.log(e); |
206 | 207 | } |
207 | 208 | }; |
208 | | -const requestTokens = async (option) => { |
| 209 | +const requestTokens = async (option: string) => { |
209 | 210 | async function requestMerchantToken(options: { |
210 | 211 | headers: { 'Content-type': string; 'x-accept-version': string }; |
211 | 212 | method: string; |
212 | | - body: { id: string }; |
| 213 | + body: { id: string; facade?: string }; |
213 | 214 | url: string; |
214 | 215 | }) { |
215 | 216 | console.log('Requesting Merchant token... \n'); |
@@ -237,7 +238,7 @@ const requestTokens = async (option) => { |
237 | 238 | async function requestPayoutToken(options: { |
238 | 239 | headers: { 'Content-type': string; 'x-accept-version': string }; |
239 | 240 | method: string; |
240 | | - body: { id: string }; |
| 241 | + body: { id: string; facade?: string }; |
241 | 242 | url: string; |
242 | 243 | }) { |
243 | 244 | console.log('Requesting Payout token... \n'); |
@@ -345,7 +346,7 @@ const updateConfigFile = async () => { |
345 | 346 | process.exit(); |
346 | 347 | }; |
347 | 348 |
|
348 | | -function sleep(ms) { |
| 349 | +function sleep(ms: number) { |
349 | 350 | return new Promise((resolve) => { |
350 | 351 | setTimeout(resolve, ms); |
351 | 352 | }); |
|
0 commit comments