Skip to content

Commit efec78c

Browse files
authored
Merge pull request #1298 from permaweb/feat/upload-wallet-messages-to-hb
feat(mu): write wallet messages to hb
2 parents 22a9efe + d6f28c8 commit efec78c

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

servers/mu/src/domain/clients/uploader.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { identity } from 'ramda'
22
import { of, fromPromise, Rejected } from 'hyper-async'
33
import { withTimerMetricsFetch } from '../lib/with-timer-metrics-fetch.js'
44

5-
function uploadDataItemWith ({ UPLOADER_URL, fetch, histogram, logger }) {
5+
function uploadDataItemWith ({ UPLOADER_URL, fetch, histogram, logger, HB_GRAPHQL_URL }) {
66
const dataItemFetch = withTimerMetricsFetch({
77
fetch,
88
timer: histogram,
@@ -36,7 +36,24 @@ function uploadDataItemWith ({ UPLOADER_URL, fetch, histogram, logger }) {
3636
Accept: 'application/json'
3737
},
3838
body
39+
}).then((res) => { return { body, res } })
40+
)
41+
)
42+
.chain(
43+
fromPromise(({ body, res }) =>
44+
dataItemFetch(`${HB_GRAPHQL_URL}/~arweave@2.9-pre/tx?codec-device=ans104@1.0`, {
45+
method: 'POST',
46+
headers: {
47+
'Content-Type': 'application/octet-stream',
48+
Accept: 'application/json'
49+
},
50+
body
3951
})
52+
.then(() => res)
53+
.catch((err) => {
54+
logger.tap({ log: 'Error while communicating with HB uploader:' })(err)
55+
return res
56+
})
4057
)
4158
)
4259
.bimap(logger.tap({ log: 'Error while communicating with uploader:' }), identity)

servers/mu/src/domain/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ export const createApis = async (ctx) => {
312312
isWallet: gatewayClient.isWalletWith({ fetch, histogram, getProcess, ARWEAVE_URL, SU_ROUTER_URL, HB_ROUTER_URL, ENABLE_HB_WALLET_CHECK, logger: sendDataItemLogger }),
313313
isHyperBeamProcess: gatewayClient.isHyperBeamProcessWith({ getProcess, logger: sendDataItemLogger, getIsHyperBeamProcess, setIsHyperBeamProcess }),
314314
logger: sendDataItemLogger,
315-
writeDataItemArweave: uploaderClient.uploadDataItemWith({ UPLOADER_URL, logger: sendDataItemLogger, fetch, histogram }),
315+
writeDataItemArweave: uploaderClient.uploadDataItemWith({ UPLOADER_URL, logger: sendDataItemLogger, fetch, histogram, HB_GRAPHQL_URL }),
316316
spawnPushEnabled: SPAWN_PUSH_ENABLED,
317317
db,
318318
traceDb,
@@ -536,7 +536,7 @@ export const createResultApis = async (ctx) => {
536536
fetchResult: cuClient.resultWith({ fetch: fetchWithCache, histogram, CU_URL, logger: processMsgLogger }),
537537
fetchHyperBeamResult: cuClient.fetchHyperBeamResultWith({ fetch, histogram, logger: processMsgLogger, fetchHBProcesses }),
538538
isWallet: gatewayClient.isWalletWith({ fetch, histogram, getProcess, ARWEAVE_URL, SU_ROUTER_URL, HB_ROUTER_URL, ENABLE_HB_WALLET_CHECK, logger: processMsgLogger, setById, getById }),
539-
writeDataItemArweave: uploaderClient.uploadDataItemWith({ UPLOADER_URL, logger: processMsgLogger, fetch, histogram }),
539+
writeDataItemArweave: uploaderClient.uploadDataItemWith({ UPLOADER_URL, logger: processMsgLogger, fetch, histogram, HB_GRAPHQL_URL }),
540540
isHyperBeamProcess: gatewayClient.isHyperBeamProcessWith({ getProcess, logger: processMsgLogger, getIsHyperBeamProcess, setIsHyperBeamProcess }),
541541
RELAY_MAP,
542542
topUp: RelayClient.topUpWith({

0 commit comments

Comments
 (0)