Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit b9809a6

Browse files
committed
fix: reduce bundle size 2
1 parent 2525b1b commit b9809a6

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

src/core/runtime/ipld-browser.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict'
2+
const mergeOptions = require('merge-options')
3+
4+
module.exports = (blockService, options = {}) => {
5+
return mergeOptions({
6+
blockService: blockService
7+
}, options)
8+
}

src/core/runtime/ipld-nodejs.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
'use strict'
2+
const mergeOptions = require('merge-options')
3+
4+
// All known (non-default) IPLD formats
5+
const IpldFormats = {
6+
get 'bitcoin-block' () {
7+
return require('ipld-bitcoin')
8+
},
9+
get 'eth-account-snapshot' () {
10+
return require('ipld-ethereum').ethAccountSnapshot
11+
},
12+
get 'eth-block' () {
13+
return require('ipld-ethereum').ethBlock
14+
},
15+
get 'eth-block-list' () {
16+
return require('ipld-ethereum').ethBlockList
17+
},
18+
get 'eth-state-trie' () {
19+
return require('ipld-ethereum').ethStateTrie
20+
},
21+
get 'eth-storage-trie' () {
22+
return require('ipld-ethereum').ethStorageTrie
23+
},
24+
get 'eth-tx' () {
25+
return require('ipld-ethereum').ethTx
26+
},
27+
get 'eth-tx-trie' () {
28+
return require('ipld-ethereum').ethTxTrie
29+
},
30+
get 'git-raw' () {
31+
return require('ipld-git')
32+
},
33+
get 'zcash-block' () {
34+
return require('ipld-zcash')
35+
}
36+
}
37+
38+
module.exports = (blockService, options = {}) => {
39+
return mergeOptions({
40+
blockService: blockService,
41+
loadFormat: (codec, callback) => {
42+
this.log('Loading IPLD format', codec)
43+
if (IpldFormats[codec]) return callback(null, IpldFormats[codec])
44+
callback(new Error(`Missing IPLD format "${codec}"`))
45+
}
46+
}, options)
47+
}

0 commit comments

Comments
 (0)