Skip to content

Commit ee38820

Browse files
author
MattDHill
committedMay 28, 2019
working
1 parent fa1b490 commit ee38820

7 files changed

+342
-253
lines changed
 

‎borkerconfig-sample.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"externalip": "",
33
"rpcuser": "",
44
"rpcpassword": "",
5-
"startBlockSync": 17903
5+
"startBlockSync": 2742726
66
}

‎package-lock.json

+189-57
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
"test": "mocha -r ts-node/register test/**/*.spec.ts"
1818
},
1919
"dependencies": {
20+
"borker-rs-node": "0.1.9",
2021
"cors": "^2.8.5",
21-
"express": "^4.16.4",
22+
"express": "^4.17.1",
2223
"reflect-metadata": "^0.1.13",
2324
"request": "^2.88.0",
2425
"request-promise": "^4.2.4",
@@ -31,15 +32,15 @@
3132
"@types/cors": "^2.8.5",
3233
"@types/express": "^4.16.1",
3334
"@types/mocha": "^5.2.6",
34-
"@types/node": "^12.0.1",
35-
"@types/request-promise": "^4.1.43",
36-
"@types/sinon": "^7.0.11",
35+
"@types/node": "^12.0.2",
36+
"@types/request-promise": "^4.1.44",
37+
"@types/sinon": "^7.0.12",
3738
"@types/sqlite3": "^3.1.5",
3839
"chai": "^4.2.0",
3940
"mocha": "^6.1.4",
4041
"rimraf": "^2.6.3",
4142
"sinon": "^7.3.2",
42-
"ts-node": "^8.1.0",
43+
"ts-node": "^8.2.0",
4344
"typescript": "^3.4.5"
4445
}
4546
}

‎src/scripts/sync.ts

+47-93
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import * as rpc from '../util/rpc-requests'
22
import * as fs from 'fs'
3-
import { getManager, EntityManager, FindManyOptions, Like, Raw } from 'typeorm'
3+
import { getManager, EntityManager, Like } from 'typeorm'
44
import { Post, PostType } from '../db/entities/post'
55
import { User } from '../db/entities/user'
6-
import { BorkerTx, mockTxs1, mockTxs2, mockTxs3, mockTxs4, mockCreated1, mockCreated2, mockSpent1, mockSpent2, mockCreated3, mockCreated4, mockSpent3, mockSpent4, Spent, TransactionType } from '../util/mocks'
76
import { Tag } from '../db/entities/tag'
8-
import { Utxo, UtxoSeed } from '../db/entities/utxo'
7+
import { Utxo } from '../db/entities/utxo'
98
import { eitherPartyBlocked } from '../util/functions'
109
import { OrphanCR } from '../db/entities/orphan-cr'
11-
12-
// let borkerLib: any
10+
import { processBlock, Network, BorkType, BorkTxData, UtxoId, NewUtxo } from 'borker-rs-node'
11+
// import { getMockBorkerTxs, getMockCreated, getMockSpent } from '../util/mocks'
1312

1413
const config = JSON.parse(fs.readFileSync('borkerconfig.json', 'utf8'))
1514
let blockHeight: number
@@ -40,10 +39,10 @@ async function processBlocks () {
4039

4140
const block = await rpc.getBlock(blockHash)
4241

43-
// const { borkerTxs: BorkerTx[], created: UtxoSeed[], spent: Spent[] } = borkerLib.process_block(block)
44-
const borkerTxs: BorkerTx[] = getBorkerTxs()
45-
const created: UtxoSeed[] = getCreated()
46-
const spent: Spent[] = getSpent()
42+
const { borkerTxs, created, spent } = processBlock(block, Network.Dogecoin)
43+
// const borkerTxs = getMockBorkerTxs(blockHeight)
44+
// const created = getMockCreated(blockHeight)
45+
// const spent = getMockSpent(blockHeight)
4746

4847
await getManager().transaction(async manager => {
4948
await Promise.all([
@@ -56,52 +55,7 @@ async function processBlocks () {
5655
await processBlocks()
5756
}
5857

59-
// TODO delete this function once borkerLib is available
60-
function getBorkerTxs () {
61-
if (blockHeight === 17903) {
62-
return mockTxs1
63-
} else if (blockHeight === 17904) {
64-
return mockTxs2
65-
} else if (blockHeight === 17905) {
66-
return mockTxs3
67-
} else if (blockHeight === 17906) {
68-
return mockTxs4
69-
} else {
70-
return []
71-
}
72-
}
73-
74-
// TODO delete this function once borkerLib is available
75-
function getCreated () {
76-
if (blockHeight === 17903) {
77-
return mockCreated1
78-
} else if (blockHeight === 17904) {
79-
return mockCreated2
80-
} else if (blockHeight === 17905) {
81-
return mockCreated3
82-
} else if (blockHeight === 17906) {
83-
return mockCreated4
84-
} else {
85-
return []
86-
}
87-
}
88-
89-
// TODO delete this function once borkerLib is available
90-
function getSpent () {
91-
if (blockHeight === 17903) {
92-
return mockSpent1
93-
} else if (blockHeight === 17904) {
94-
return mockSpent2
95-
} else if (blockHeight === 17905) {
96-
return mockSpent3
97-
} else if (blockHeight === 17906) {
98-
return mockSpent4
99-
} else {
100-
return []
101-
}
102-
}
103-
104-
async function processUtxos(manager: EntityManager, created: Utxo[], spent: Spent[]) {
58+
async function processUtxos(manager: EntityManager, created: NewUtxo[], spent: UtxoId[]) {
10559
// insert created utxos
10660
if (created.length) {
10761
await manager.createQueryBuilder()
@@ -117,7 +71,7 @@ async function processUtxos(manager: EntityManager, created: Utxo[], spent: Spen
11771
}
11872
}
11973

120-
async function processBorkerTxs(manager: EntityManager, borkerTxs: BorkerTx[]) {
74+
async function processBorkerTxs(manager: EntityManager, borkerTxs: BorkTxData[]) {
12175

12276
for (let tx of borkerTxs) {
12377

@@ -138,59 +92,59 @@ async function processBorkerTxs(manager: EntityManager, borkerTxs: BorkerTx[]) {
13892

13993
switch (type) {
14094
// if set_name, set_bio, set_avatar
141-
case TransactionType.setName:
142-
case TransactionType.setBio:
143-
case TransactionType.setAvatar:
95+
case BorkType.SetName:
96+
case BorkType.SetBio:
97+
case BorkType.SetAvatar:
14498
await handleProfileUpdate(manager, type, senderAddress, content)
14599
break
146100
// if bork, comment, rebork, extension
147-
case TransactionType.bork:
148-
case TransactionType.comment:
149-
case TransactionType.rebork:
150-
case TransactionType.extension:
101+
case BorkType.Bork:
102+
case BorkType.Comment:
103+
case BorkType.Rebork:
104+
case BorkType.Extension:
151105
await handleBCRE(manager, tx)
152106
break
153107
// like
154-
case TransactionType.like:
108+
case BorkType.Like:
155109
await handleLike(manager, referenceId, senderAddress, recipientAddress)
156110
break
157111
// flag, unflag, unlike
158-
case TransactionType.unlike:
159-
case TransactionType.flag:
160-
case TransactionType.unflag:
112+
case BorkType.Unlike:
113+
case BorkType.Flag:
114+
case BorkType.Unflag:
161115
await handleFUU(manager, type, senderAddress, content)
162116
break
163-
case TransactionType.follow:
164-
case TransactionType.unfollow:
165-
case TransactionType.block:
166-
case TransactionType.unblock:
117+
case BorkType.Follow:
118+
case BorkType.Unfollow:
119+
case BorkType.Block:
120+
case BorkType.Unblock:
167121
await handleFUBU(manager, type, senderAddress, content)
168122
break
169-
case TransactionType.delete:
123+
case BorkType.Delete:
170124
await manager.update(Post, { sender: { address: senderAddress }, txid: content }, { content: null, deletedAt: new Date(time) })
171125
break
172126
}
173127
}
174128
}
175129

176-
async function handleProfileUpdate(manager: EntityManager, type: TransactionType, senderAddress: string, content: string) {
130+
async function handleProfileUpdate(manager: EntityManager, type: BorkType, senderAddress: string, content: string) {
177131
let params: Partial<User>
178132

179133
switch (type) {
180-
case TransactionType.setName:
134+
case BorkType.SetName:
181135
params = { name: content }
182136
break
183-
case TransactionType.setBio:
137+
case BorkType.SetBio:
184138
params = { bio: content }
185139
break
186-
case TransactionType.setAvatar:
140+
case BorkType.SetAvatar:
187141
params = { avatarLink: content }
188142
break
189143
}
190144
await manager.update(User, senderAddress, params)
191145
}
192146

193-
async function handleBCRE (manager: EntityManager, tx: BorkerTx): Promise<void> {
147+
async function handleBCRE (manager: EntityManager, tx: BorkTxData): Promise<void> {
194148

195149
const { txid, time, nonce, index, type, content, referenceId, senderAddress, mentions } = tx
196150

@@ -218,7 +172,7 @@ async function handleBCRE (manager: EntityManager, tx: BorkerTx): Promise<void>
218172
.where('parent_txid IS NULL')
219173
.andWhere('nonce = :nonce', { nonce })
220174
.andWhere('sender_address = :senderAddress', { senderAddress })
221-
.andWhere('type = :type', { type: TransactionType.extension })
175+
.andWhere('type = :type', { type: BorkType.Extension })
222176
.andWhere('created_at > :cutoff', { cutoff: getCutoff(new Date(time)) })
223177
.execute(),
224178
// update CR orphaned posts
@@ -234,9 +188,9 @@ async function handleBCRE (manager: EntityManager, tx: BorkerTx): Promise<void>
234188
// attach mentions
235189
attachMentions(manager, txid, mentions),
236190
// if comment or rebork
237-
(type === TransactionType.comment || type === TransactionType.rebork) && handleCR(manager, tx),
191+
(type === BorkType.Comment || type === BorkType.Rebork) && handleCR(manager, tx),
238192
// if extension
239-
type === TransactionType.extension && handleExtension(manager, tx),
193+
type === BorkType.Extension && handleExtension(manager, tx),
240194
])
241195

242196
// delete duplicate orphaned extension posts
@@ -254,7 +208,7 @@ async function handleBCRE (manager: EntityManager, tx: BorkerTx): Promise<void>
254208
)`, { txid })
255209
}
256210

257-
async function handleCR (manager: EntityManager, tx: BorkerTx): Promise<void> {
211+
async function handleCR (manager: EntityManager, tx: BorkTxData): Promise<void> {
258212

259213
const { txid, time, referenceId, senderAddress, recipientAddress } = tx
260214

@@ -287,7 +241,7 @@ async function handleCR (manager: EntityManager, tx: BorkerTx): Promise<void> {
287241
}
288242
}
289243

290-
async function handleExtension (manager: EntityManager, tx: BorkerTx): Promise<void> {
244+
async function handleExtension (manager: EntityManager, tx: BorkTxData): Promise<void> {
291245

292246
const { txid, time, nonce, index, senderAddress } = tx
293247

@@ -297,13 +251,13 @@ async function handleExtension (manager: EntityManager, tx: BorkerTx): Promise<v
297251
.from(Post, 'posts')
298252
.where('nonce = :nonce', { nonce })
299253
.andWhere('sender_address = :senderAddress', { senderAddress })
300-
.andWhere('type != :type', { type: TransactionType.extension })
254+
.andWhere('type != :type', { type: BorkType.Extension })
301255
.andWhere(`created_at > :cutoff`, { cutoff: getCutoff(new Date(time)) })
302256
.andWhere(qb => {
303257
const subQuery = qb.subQuery()
304258
.select('parent_txid')
305259
.from(Post, 'posts2')
306-
.where('type = :type', { type: TransactionType.extension })
260+
.where('type = :type', { type: BorkType.Extension })
307261
.andWhere('"index" = :index', { index })
308262
.andWhere('parent_txid IS NOT NULL')
309263
.getQuery()
@@ -341,13 +295,13 @@ async function handleLike (manager: EntityManager, referenceId: string, senderAd
341295
.execute()
342296
}
343297

344-
async function handleFUU (manager: EntityManager, type: TransactionType, senderAddress: string, content: string): Promise<void> {
298+
async function handleFUU (manager: EntityManager, type: BorkType, senderAddress: string, content: string): Promise<void> {
345299
// find the post from the content of the tx
346300
const parent = await manager.findOne(Post, content)
347301
if (!parent) { return }
348302

349303
switch (type) {
350-
case TransactionType.flag:
304+
case BorkType.Flag:
351305
// if either party is blocked, they cannot flag
352306
if (await eitherPartyBlocked(parent.senderAddress, senderAddress)) { return }
353307
await manager.createQueryBuilder()
@@ -360,13 +314,13 @@ async function handleFUU (manager: EntityManager, type: TransactionType, senderA
360314
.onConflict('DO NOTHING')
361315
.execute()
362316
break
363-
case TransactionType.unflag:
317+
case BorkType.Unflag:
364318
await manager.createQueryBuilder()
365319
.relation(User, 'flags')
366320
.of(senderAddress)
367321
.remove(parent.txid)
368322
break
369-
case TransactionType.unlike:
323+
case BorkType.Unlike:
370324
await manager.createQueryBuilder()
371325
.relation(User, 'likes')
372326
.of(senderAddress)
@@ -375,14 +329,14 @@ async function handleFUU (manager: EntityManager, type: TransactionType, senderA
375329
}
376330
}
377331

378-
async function handleFUBU (manager: EntityManager, type: TransactionType, senderAddress: string, recipientAddress: string): Promise<void> {
332+
async function handleFUBU (manager: EntityManager, type: BorkType, senderAddress: string, recipientAddress: string): Promise<void> {
379333
// get the user from the content of the post
380334
const recipient = await manager.findOne(User, recipientAddress)
381335
if (!recipient) { return }
382336

383337
switch (type) {
384338
// follow
385-
case TransactionType.follow:
339+
case BorkType.Follow:
386340
await manager.createQueryBuilder()
387341
.insert()
388342
.into('follows')
@@ -394,14 +348,14 @@ async function handleFUBU (manager: EntityManager, type: TransactionType, sender
394348
.execute()
395349
break
396350
// unfollow
397-
case TransactionType.unfollow:
351+
case BorkType.Unfollow:
398352
await manager.createQueryBuilder()
399353
.relation(User, 'following')
400354
.of(senderAddress)
401355
.remove(recipientAddress)
402356
break
403357
// block
404-
case TransactionType.block:
358+
case BorkType.Block:
405359
await manager.createQueryBuilder()
406360
.insert()
407361
.into('blocks')
@@ -413,7 +367,7 @@ async function handleFUBU (manager: EntityManager, type: TransactionType, sender
413367
.execute()
414368
break
415369
// unblock
416-
case TransactionType.unblock:
370+
case BorkType.Unblock:
417371
await manager.createQueryBuilder()
418372
.relation(User, 'blocking')
419373
.of(senderAddress)

‎src/util/mocks.ts

+95-90
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,52 @@
1-
import { UtxoSeed } from '../db/entities/utxo'
1+
import { BorkType, BorkTxData, UtxoId, NewUtxo } from 'borker-rs-node'
22

3-
export enum TransactionType {
4-
setName = 'set_name',
5-
setBio = 'set_bio',
6-
setAvatar = 'set_avatar',
7-
bork = 'bork',
8-
comment = 'comment',
9-
rebork = 'rebork',
10-
extension = 'extension',
11-
delete = 'delete',
12-
like = 'like',
13-
unlike = 'unlike',
14-
flag = 'flag',
15-
unflag = 'unflag',
16-
follow = 'follow',
17-
unfollow = 'unfollow',
18-
block = 'block',
19-
unblock = 'unblock',
3+
export function getMockBorkerTxs (blockHeight: number) {
4+
if (blockHeight === 17903) {
5+
return mockTxs1
6+
} else if (blockHeight === 17904) {
7+
return mockTxs2
8+
} else if (blockHeight === 17905) {
9+
return mockTxs3
10+
} else if (blockHeight === 17906) {
11+
return mockTxs4
12+
} else {
13+
return []
14+
}
2015
}
2116

22-
export interface BorkerTx {
23-
time: number
24-
txid: string
25-
type: TransactionType
26-
nonce: number | null
27-
index: number | null
28-
content: string | null
29-
referenceId: string | null
30-
senderAddress: string
31-
recipientAddress: string | null
32-
mentions: string[]
17+
export function getMockCreated (blockHeight: number) {
18+
if (blockHeight === 17903) {
19+
return mockCreated1
20+
} else if (blockHeight === 17904) {
21+
return mockCreated2
22+
} else if (blockHeight === 17905) {
23+
return mockCreated3
24+
} else if (blockHeight === 17906) {
25+
return mockCreated4
26+
} else {
27+
return []
28+
}
3329
}
3430

35-
export interface Spent {
36-
txid: string
37-
index: number
31+
export function getMockSpent (blockHeight: number) {
32+
if (blockHeight === 17903) {
33+
return mockSpent1
34+
} else if (blockHeight === 17904) {
35+
return mockSpent2
36+
} else if (blockHeight === 17905) {
37+
return mockSpent3
38+
} else if (blockHeight === 17906) {
39+
return mockSpent4
40+
} else {
41+
return []
42+
}
3843
}
3944

40-
export const mockTxs1: BorkerTx[] = [
45+
export const mockTxs1: BorkTxData[] = [
4146
{
42-
time: 1412177231000,
47+
time: '2019-05-28T00:51:39Z',
4348
txid: '39128e8edacce1ada4e1df9aa5fc91431302ef951df06a78e13f4fbc3759e752',
44-
type: TransactionType.setName,
49+
type: BorkType.SetName,
4550
nonce: null,
4651
index: null,
4752
content: 'MattHill',
@@ -51,9 +56,9 @@ export const mockTxs1: BorkerTx[] = [
5156
mentions: [],
5257
},
5358
{
54-
time: 1422182926000,
59+
time: '2019-05-28T00:51:39Z',
5560
txid: '8b5ab18a8593ba3f1abae61c07bf02169487c58b0e244922b6c4578eaf6e0d35',
56-
type: TransactionType.bork,
61+
type: BorkType.Bork,
5762
nonce: 14,
5863
index: 0,
5964
content: 'I like to bork. I like to bork',
@@ -63,9 +68,9 @@ export const mockTxs1: BorkerTx[] = [
6368
mentions: [],
6469
},
6570
{
66-
time: 1422184977000,
71+
time: '2019-05-28T00:51:39Z',
6772
txid: '774bef2197e6394112e1ee18246f1a0137ddb19a4d2d4464c1e25217977a0460',
68-
type: TransactionType.rebork,
73+
type: BorkType.Rebork,
6974
nonce: 10,
7075
index: 0,
7176
content: null,
@@ -75,9 +80,9 @@ export const mockTxs1: BorkerTx[] = [
7580
mentions: [],
7681
},
7782
{
78-
time: 1423181711000,
83+
time: '2019-05-28T00:51:39Z',
7984
txid: '43873bcc83d6d811df6bff1909a5cd3fc98eb84bbaded5a44443fc86f9ef0e3b',
80-
type: TransactionType.bork,
85+
type: BorkType.Bork,
8186
nonce: 0,
8287
index: 0,
8388
content: 'Bork some more. Bork some more. #Tomorrow',
@@ -88,9 +93,9 @@ export const mockTxs1: BorkerTx[] = [
8893
},
8994
// this extension will be orphaned and then cleaned up later
9095
{
91-
time: 1424967192200,
96+
time: '2019-05-28T00:51:39Z',
9297
txid: '89520b2306424bb8704ac63adbb03311f5d3fd4bd2deb72dbe40bfbfc219a5ba',
93-
type: TransactionType.extension,
98+
type: BorkType.Extension,
9499
nonce: 156,
95100
index: 1,
96101
content: 'extension that was orphaned for a while',
@@ -101,11 +106,11 @@ export const mockTxs1: BorkerTx[] = [
101106
},
102107
]
103108

104-
export const mockTxs2: BorkerTx[] = [
109+
export const mockTxs2: BorkTxData[] = [
105110
{
106-
time: 1424167335000,
111+
time: '2019-05-28T00:51:39Z',
107112
txid: '069aa2f138cbdc6ebd379b1e6d1cb7f86c8770ad58be27006671d528a75ba0e3',
108-
type: TransactionType.bork,
113+
type: BorkType.Bork,
109114
nonce: 222,
110115
index: 0,
111116
content: 'Borking like there aint no #tomorrow',
@@ -115,9 +120,9 @@ export const mockTxs2: BorkerTx[] = [
115120
mentions: [],
116121
},
117122
{
118-
time: 1424169440000,
123+
time: '2019-05-28T00:51:39Z',
119124
txid: '41266e19b39dbba35128f3af72299b4636cb9250d81741b5db1987716043a7af',
120-
type: TransactionType.rebork,
125+
type: BorkType.Rebork,
121126
nonce: 25,
122127
index: 0,
123128
content: 'This is a rebork with a comment...',
@@ -127,9 +132,9 @@ export const mockTxs2: BorkerTx[] = [
127132
mentions: [],
128133
},
129134
{
130-
time: 1424561124000,
135+
time: '2019-05-28T00:51:39Z',
131136
txid: '99f14aa1ac661f932113cbb92cfa7ee1cfc649cbc416f7c6aa43b13ce301d3a4',
132-
type: TransactionType.comment,
137+
type: BorkType.Comment,
133138
nonce: 100,
134139
index: 0,
135140
content: 'And some more!',
@@ -139,9 +144,9 @@ export const mockTxs2: BorkerTx[] = [
139144
mentions: [],
140145
},
141146
{
142-
time: 1424967992000,
147+
time: '2019-05-28T00:51:39Z',
143148
txid: '164af924f859c9936f3bda737a986a1a85b3708c9b2fd150b36b964b11c858a6',
144-
type: TransactionType.bork,
149+
type: BorkType.Bork,
145150
nonce: 211,
146151
index: 0,
147152
content: 'This is a long bork that will take up two whole transactions. I will write',
@@ -151,9 +156,9 @@ export const mockTxs2: BorkerTx[] = [
151156
mentions: [],
152157
},
153158
{
154-
time: 1424967992200,
159+
time: '2019-05-28T00:51:39Z',
155160
txid: 'e3b3a8bf7e3796d908b731c0d16baba0f1e161b97d917e00cde81ff0f1452fd1',
156-
type: TransactionType.extension,
161+
type: BorkType.Extension,
157162
nonce: 211,
158163
index: 1,
159164
content: 'just a little more. See, I told you. Bork on.',
@@ -163,9 +168,9 @@ export const mockTxs2: BorkerTx[] = [
163168
mentions: ['DSJdZogGLmREMZTyJGSzSs2RL9UJjeqKd7'],
164169
},
165170
{
166-
time: 1425188584000,
171+
time: '2019-05-28T00:51:39Z',
167172
txid: '3ffa42642f6dfd718562b8a6d04c403b20b59fe873eadd1960e402769cee1318',
168-
type: TransactionType.follow,
173+
type: BorkType.Follow,
169174
nonce: null,
170175
index: null,
171176
content: 'DSJdZogGLmREMZTyJGSzSs2RL9UJjeqKd7',
@@ -176,11 +181,11 @@ export const mockTxs2: BorkerTx[] = [
176181
},
177182
]
178183

179-
export const mockTxs3: BorkerTx[] = [
184+
export const mockTxs3: BorkTxData[] = [
180185
{
181-
time: 1425287522000,
186+
time: '2019-05-28T00:51:39Z',
182187
txid: '4cb6f18366e4a32ff69e681d192aec89a4d8721af544725fe6a02ecde4311605',
183-
type: TransactionType.setName,
188+
type: BorkType.SetName,
184189
nonce: null,
185190
index: null,
186191
content: 'aiden_mcclelland',
@@ -190,9 +195,9 @@ export const mockTxs3: BorkerTx[] = [
190195
mentions: [],
191196
},
192197
{
193-
time: 1424967392200,
198+
time: '2019-05-28T00:51:39Z',
194199
txid: 'a21f4c7f2aa418aea0a72e34aa753d5aa0bd77918053da3fe06ecb54145657f2',
195-
type: TransactionType.comment,
200+
type: BorkType.Comment,
196201
nonce: 156,
197202
index: 0,
198203
content: 'Wow that was so borking cool. Now I will create an',
@@ -202,9 +207,9 @@ export const mockTxs3: BorkerTx[] = [
202207
mentions: [],
203208
},
204209
{
205-
time: 1425399510000,
210+
time: '2019-05-28T00:51:39Z',
206211
txid: '8a3e0fe9ebc5e2fec31b12e7880f0dc184b56fd2d0541fcc3e6c0a1530826913',
207-
type: TransactionType.setBio,
212+
type: BorkType.SetBio,
208213
nonce: null,
209214
index: null,
210215
content: 'I am a Bork Master',
@@ -214,9 +219,9 @@ export const mockTxs3: BorkerTx[] = [
214219
mentions: [],
215220
},
216221
{
217-
time: 1426287533000,
222+
time: '2019-05-28T00:51:39Z',
218223
txid: 'c7c4e2977cc67cc16ee8fec757a61219deddcc8edfb6e20ab818af29f4be9373',
219-
type: TransactionType.follow,
224+
type: BorkType.Follow,
220225
nonce: null,
221226
index: null,
222227
content: 'D65dwxsVdaCFHUGqAVWKgdddsa9ADxXcGk',
@@ -227,11 +232,11 @@ export const mockTxs3: BorkerTx[] = [
227232
},
228233
]
229234

230-
export const mockTxs4: BorkerTx[] = [
235+
export const mockTxs4: BorkTxData[] = [
231236
{
232-
time: 1425287522000,
237+
time: '2019-05-28T00:51:39Z',
233238
txid: '0b692b4e683a3ea47f0b3b6a6f30e8cca6efcc78f1c2eb6e35430af9b9415eb5',
234-
type: TransactionType.setBio,
239+
type: BorkType.SetBio,
235240
nonce: null,
236241
index: null,
237242
content: 'I am the unknown Borker who shall someday be known',
@@ -241,9 +246,9 @@ export const mockTxs4: BorkerTx[] = [
241246
mentions: [],
242247
},
243248
{
244-
time: 1426287533000,
249+
time: '2019-05-28T00:51:39Z',
245250
txid: '3a7f46861703322b75fed4594cd94eb9c04c5a6edb0c1e4ecd1eb91ba2fc4304',
246-
type: TransactionType.block,
251+
type: BorkType.Block,
247252
nonce: null,
248253
index: null,
249254
content: 'DG7z89QMNB7xJr7Z44TwZPd8BUFSBoamW7',
@@ -253,9 +258,9 @@ export const mockTxs4: BorkerTx[] = [
253258
mentions: [],
254259
},
255260
{
256-
time: 1425399510000,
261+
time: '2019-05-28T00:51:39Z',
257262
txid: '20d721480d0450a1b9666618ee618bfbacde74a4bade40908063c6c344bc7214',
258-
type: TransactionType.unfollow,
263+
type: BorkType.Unfollow,
259264
nonce: null,
260265
index: null,
261266
content: 'D65dwxsVdaCFHUGqAVWKgdddsa9ADxXcGk',
@@ -265,9 +270,9 @@ export const mockTxs4: BorkerTx[] = [
265270
mentions: [],
266271
},
267272
{
268-
time: 1426287533000,
273+
time: '2019-05-28T00:51:39Z',
269274
txid: '2d9509c33a8e93152a42f2aa048404b304ba858dc0ad8f305ba16223781d46fc',
270-
type: TransactionType.like,
275+
type: BorkType.Like,
271276
nonce: null,
272277
index: null,
273278
content: null,
@@ -277,9 +282,9 @@ export const mockTxs4: BorkerTx[] = [
277282
mentions: [],
278283
},
279284
{
280-
time: 1426287533000,
285+
time: '2019-05-28T00:51:39Z',
281286
txid: 'f93162e896c44fae41c75b66f2c1aa2eeb6e7de54a21b89075f99a90f582434e',
282-
type: TransactionType.like,
287+
type: BorkType.Like,
283288
nonce: null,
284289
index: null,
285290
content: null,
@@ -290,9 +295,9 @@ export const mockTxs4: BorkerTx[] = [
290295
},
291296
// this comment will be left orphaned
292297
{
293-
time: 1426287533000,
298+
time: '2019-05-28T00:51:39Z',
294299
txid: '2312757481a28100402f71e788d2922f9aae766af10dda0b28dfd7dd858e15a1',
295-
type: TransactionType.comment,
300+
type: BorkType.Comment,
296301
nonce: 14,
297302
index: 0,
298303
content: 'a poor orphaned comment',
@@ -302,9 +307,9 @@ export const mockTxs4: BorkerTx[] = [
302307
mentions: [],
303308
},
304309
{
305-
time: 1426287677000,
310+
time: '2019-05-28T00:51:39Z',
306311
txid: '59a6a9cd14fb864a048b87ef006d168c345943edc1bc54e462694ac42c90cd04',
307-
type: TransactionType.flag,
312+
type: BorkType.Flag,
308313
nonce: null,
309314
index: null,
310315
content: 'a21f4c7f2aa418aea0a72e34aa753d5aa0bd77918053da3fe06ecb54145657f2',
@@ -315,9 +320,9 @@ export const mockTxs4: BorkerTx[] = [
315320
},
316321
// this flag will not save because sender is blocked
317322
{
318-
time: 1426287677000,
323+
time: '2019-05-28T00:51:39Z',
319324
txid: '59a6a9cd14fb864a048b87ef006d168c345943edc1bc54e462694ac42c90cd04',
320-
type: TransactionType.flag,
325+
type: BorkType.Flag,
321326
nonce: null,
322327
index: null,
323328
content: 'a21f4c7f2aa418aea0a72e34aa753d5aa0bd77918053da3fe06ecb54145657f2',
@@ -328,7 +333,7 @@ export const mockTxs4: BorkerTx[] = [
328333
},
329334
]
330335

331-
export const mockCreated1: UtxoSeed[] = [
336+
export const mockCreated1: NewUtxo[] = [
332337
{
333338
txid: '89da78a5802eb72ba3ae4e12654b10b0223221f7f76ac915f5636394a8c463e7',
334339
address: 'D65dwxsVdaCFHUGqAVWKgdddsa9ADxXcGk',
@@ -360,7 +365,7 @@ export const mockCreated1: UtxoSeed[] = [
360365
},
361366
]
362367

363-
export const mockCreated2: UtxoSeed[] = [
368+
export const mockCreated2: NewUtxo[] = [
364369
{
365370
txid: '41266e19b39dbba35128f3af72299b4636cb9250d81741b5db1987716043a7af',
366371
address: 'DSJdZogGLmREMZTyJGSzSs2RL9UJjeqKd7',
@@ -385,7 +390,7 @@ export const mockCreated2: UtxoSeed[] = [
385390
},
386391
]
387392

388-
export const mockCreated3: UtxoSeed[] = [
393+
export const mockCreated3: NewUtxo[] = [
389394
{
390395
txid: 'a21f4c7f2aa418aea0a72e34aa753d5aa0bd77918053da3fe06ecb54145657f2',
391396
address: 'D65dwxsVdaCFHUGqAVWKgdddsa9ADxXcGk',
@@ -395,7 +400,7 @@ export const mockCreated3: UtxoSeed[] = [
395400
},
396401
]
397402

398-
export const mockCreated4: UtxoSeed[] = [
403+
export const mockCreated4: NewUtxo[] = [
399404
{
400405
txid: '2d9509c33a8e93152a42f2aa048404b304ba858dc0ad8f305ba16223781d46fc',
401406
address: 'D65dwxsVdaCFHUGqAVWKgdddsa9ADxXcGk',
@@ -412,16 +417,16 @@ export const mockCreated4: UtxoSeed[] = [
412417
},
413418
]
414419

415-
export const mockSpent1: Spent[] = []
420+
export const mockSpent1: UtxoId[] = []
416421

417-
export const mockSpent2: Spent[] = [
422+
export const mockSpent2: UtxoId[] = [
418423
{
419424
txid: '89da78a5802eb72ba3ae4e12654b10b0223221f7f76ac915f5636394a8c463e7',
420425
index: 0,
421426
},
422427
]
423428

424-
export const mockSpent3: Spent[] = [
429+
export const mockSpent3: UtxoId[] = [
425430
{
426431
txid: '774bef2197e6394112e1ee18246f1a0137ddb19a4d2d4464c1e25217977a0460',
427432
index: 1,
@@ -436,7 +441,7 @@ export const mockSpent3: Spent[] = [
436441
},
437442
]
438443

439-
export const mockSpent4: Spent[] = [
444+
export const mockSpent4: UtxoId[] = [
440445
{
441446
txid: '',
442447
index: 0,

‎src/util/rpc-requests.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ export interface Response {
88
}
99

1010
export async function getBlockHash (blockHeight: number): Promise<string> {
11-
if (blockHeight <= 17906) {
12-
return blockHeight.toString()
13-
// return request('getblockhash', `${blockHeight}`, [blockHeight])
14-
}
11+
// return blockHeight.toString()
12+
return request('getblockhash', `${blockHeight}`, [blockHeight])
1513
}
1614

1715
export async function getBlock (blockHash: string): Promise<string> {
18-
return blockHash
19-
// return request('getblock', `${blockHash}`, [blockHash, false])
16+
// return blockHash
17+
return request('getblock', `${blockHash}`, [blockHash, false])
2018
}
2119

2220
export async function broadcast (txHex: string): Promise<string> {

‎tslint.json

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"single"
1010
],
1111
"no-unused-variable": true,
12-
"no-duplicate-imports": true,
1312
"no-trailing-whitespace": true,
1413
"whitespace": [
1514
true,

0 commit comments

Comments
 (0)
Please sign in to comment.