Skip to content

Commit

Permalink
feat: add SolanaAPI
Browse files Browse the repository at this point in the history
Feature/solana api
  • Loading branch information
sogunshola authored Jan 21, 2022
1 parent 85bba87 commit f870001
Show file tree
Hide file tree
Showing 16 changed files with 29,539 additions and 275 deletions.
6 changes: 4 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ CHANGELOG.md
/dist
/lib
/types/generated
web3api.d.ts
src/MoralisWeb3Api.js
web3Api.d.ts
src/MoralisWeb3Api.js
solanaApi.d.ts
src/MoralisSolanaApi.js
64 changes: 64 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ const PRESETS = {
},
],
],
solanaapi: [
[
'@babel/preset-env',
{
targets: { browsers: '> 0.25%, not dead', node: '8' },
},
],
],
};
const PLUGINS = {
browser: [
Expand Down Expand Up @@ -94,6 +102,13 @@ const PLUGINS = {
'inline-package-json',
'transform-inline-environment-variables',
],
solanaapi: [
transformRuntime,
'@babel/plugin-transform-flow-comments',
'@babel/plugin-proposal-class-properties',
'inline-package-json',
'transform-inline-environment-variables',
],
};

const getDevHeader = () => {
Expand Down Expand Up @@ -183,6 +198,27 @@ gulp.task('compile-web3api', function () {
);
});

gulp.task('compile-solanaapi', function () {
return (
gulp
.src('src/MoralisSolanaApi.js')
.pipe(
babel({
presets: PRESETS[BUILD],
plugins: PLUGINS[BUILD],
})
)
// Second pass to kill BUILD-switched code
.pipe(
babel({
plugins: ['minify-dead-code-elimination'],
})
)
.pipe(rename('index.js'))
.pipe(gulp.dest(path.join('lib', BUILD)))
);
});

gulp.task('browserify', function (cb) {
const stream = browserify({
builtins: ['_process', 'events', 'timers'],
Expand Down Expand Up @@ -242,6 +278,25 @@ gulp.task('browserify-web3api', function (cb) {
.pipe(gulp.dest('./dist'));
});

gulp.task('browserify-solanaapi', function (cb) {
const stream = browserify({
builtins: ['_process', 'events'],
entries: 'lib/solanaapi/index.js',
standalone: 'SolanaApi',
})
.exclude('xmlhttprequest')
.ignore('_process')
.bundle();
stream.on('end', () => {
cb();
});
return stream
.pipe(source('moralis.solanaapi.js'))
.pipe(derequire())
.pipe(insert.prepend(getDevHeader()))
.pipe(gulp.dest('./dist'));
});

gulp.task('minify', function () {
return gulp
.src('dist/moralis.js')
Expand Down Expand Up @@ -269,6 +324,15 @@ gulp.task('minify-web3api', function () {
.pipe(gulp.dest('./dist'));
});

gulp.task('minify-solanaapi', function () {
return gulp
.src('dist/moralis.solanaapi.js')
.pipe(terser())
.pipe(insert.prepend(getFullHeader()))
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest('./dist'));
});

gulp.task('watch', function () {
return (
watch(SRC, { ignoreInitial: false, verbose: true })
Expand Down
Loading

0 comments on commit f870001

Please sign in to comment.