File tree Expand file tree Collapse file tree 1 file changed +27
-3
lines changed
Expand file tree Collapse file tree 1 file changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ let ProjectId = "";
1010let ProjectSecret = "" ;
1111
1212let EstuaryInstance ;
13+ let NumbersProtocolInstance ;
1314
1415export async function initInfura ( projectId , projectSecret ) {
1516 ProjectId = projectId ;
@@ -67,11 +68,11 @@ export async function w3sIpfsCat(cid) {
6768}
6869
6970export async function ipfsAddBytes ( bytes ) {
70- return await infuraIpfsAddBytes ( bytes ) ;
71+ return await numbersProtocolIpfsAddBytes ( bytes ) ;
7172}
7273
7374export async function ipfsCat ( cid ) {
74- return await w3sIpfsCat ( cid ) ;
75+ return await numbersProtocolIpfsCat ( cid ) ;
7576}
7677
7778export async function cidToJsonString ( cid ) {
@@ -107,4 +108,27 @@ export async function estuaryAdd(bytes) {
107108 } catch ( error ) {
108109 console . error ( error ) ;
109110 }
110- }
111+ }
112+
113+ export async function initNumbersProtocol ( apiKey ) {
114+ NumbersProtocolInstance = new Estuary ( apiKey ) ;
115+ }
116+
117+ export async function numbersProtocolIpfsAddBytes ( bytes ) {
118+ let cid ;
119+ try {
120+ cid = await NumbersProtocolInstance . addFromBuffer ( bytes ) ;
121+ return cid ;
122+ } catch ( error ) {
123+ console . error ( error ) ;
124+ }
125+ }
126+
127+ export async function numbersProtocolIpfsCat ( cid ) {
128+ const url = `https://${ cid } .ipfs.numbersprotocol.io` ;
129+ const requestConfig = {
130+ timeout : { request : 30000 } ,
131+ }
132+ const r = await got . get ( url , requestConfig ) ;
133+ return r . rawBody ;
134+ }
You can’t perform that action at this time.
0 commit comments