-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into thlorenz/feat/manage-candy-machine
* main: feat: add candy machine gpa builders (#95) v0.8.0 Use Rollup and Babel to create builds (#93)
- Loading branch information
Showing
32 changed files
with
1,984 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"bugfixes": true | ||
} | ||
], | ||
["@babel/preset-typescript"] | ||
], | ||
"plugins": [ | ||
[ | ||
"module-resolver", | ||
{ | ||
"root": ["./src"], | ||
"alias": { | ||
"@": "./src" | ||
} | ||
} | ||
] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
import babel from '@rollup/plugin-babel'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import json from '@rollup/plugin-json'; | ||
import nodePolyfills from 'rollup-plugin-polyfill-node'; | ||
import nodeResolve from '@rollup/plugin-node-resolve'; | ||
import replace from '@rollup/plugin-replace'; | ||
import { terser } from 'rollup-plugin-terser'; | ||
import generatePackageJson from 'rollup-plugin-generate-package-json'; | ||
import pkg from './package.json'; | ||
|
||
const builds = [ | ||
{ | ||
dir: 'dist/esm', | ||
format: 'es', | ||
}, | ||
{ | ||
dir: 'dist/cjs', | ||
format: 'cjs', | ||
}, | ||
{ | ||
dir: 'dist/esm-browser', | ||
format: 'es', | ||
browser: true, | ||
}, | ||
{ | ||
dir: 'dist/cjs-browser', | ||
format: 'cjs', | ||
browser: true, | ||
}, | ||
{ | ||
file: 'dist/iife/index.js', | ||
format: 'iife', | ||
name: 'MetaplexSDK', | ||
browser: true, | ||
bundle: true, | ||
}, | ||
{ | ||
file: 'dist/iife/index.min.js', | ||
format: 'iife', | ||
name: 'MetaplexSDK', | ||
browser: true, | ||
bundle: true, | ||
minified: true, | ||
}, | ||
]; | ||
|
||
const extensions = ['.js', '.ts']; | ||
const allDependencies = Object.keys(pkg.dependencies); | ||
const dependenciesToExcludeInBundle = ['@aws-sdk/client-s3']; | ||
const dependenciesToDedupes = [ | ||
'@solana/spl-token', | ||
'@solana/wallet-adapter-base', | ||
'@solana/web3.js', | ||
'abort-controller', | ||
'bignumber.js', | ||
'bn.js', | ||
'bs58', | ||
'buffer', | ||
'cross-fetch', | ||
'debug', | ||
'eventemitter3', | ||
'mime', | ||
'tweetnacl', | ||
]; | ||
|
||
const globals = { | ||
'@aws-sdk/client-s3': 'AwsS3Client', | ||
'@bundlr-network/client': 'BundlrNetworkClient', | ||
'@metaplex-foundation/beet': 'MetaplexBeet', | ||
'@metaplex-foundation/beet-solana': 'MetaplexBeetSolana', | ||
'@metaplex-foundation/mpl-candy-machine': 'MetaplexMplCandyMachine', | ||
'@metaplex-foundation/mpl-token-metadata': 'MetaplexMplTokenMetadata', | ||
'@solana/spl-token': 'SolanaSplToken', | ||
'@solana/wallet-adapter-base': 'SolanaWalletAdapterBase', | ||
'@solana/web3.js': 'SolanaWeb3', | ||
'abort-controller': 'AbortController', | ||
'bignumber.js': 'BigNumber', | ||
'bn.js': 'BN', | ||
bs58: 'Bs58', | ||
buffer: 'Buffer', | ||
'cross-fetch': 'CrossFetch', | ||
debug: 'Debug', | ||
eventemitter3: 'EventEmitter3', | ||
'lodash.clonedeep': 'LodashClonedeep', | ||
mime: 'Mime', | ||
tweetnacl: 'Tweetnacl', | ||
}; | ||
|
||
const createConfig = (build) => { | ||
const { file, dir, format, name, browser = false, bundle = false, minified = false } = build; | ||
|
||
const external = allDependencies.filter((dependency) => { | ||
return !bundle || dependenciesToExcludeInBundle.includes(dependency); | ||
}); | ||
|
||
return { | ||
input: ['src/index.ts'], | ||
output: { | ||
dir, | ||
file, | ||
format, | ||
name, | ||
exports: 'named', | ||
preserveModules: !bundle, | ||
sourcemap: true, | ||
globals, | ||
}, | ||
external, | ||
treeshake: { | ||
moduleSideEffects: false, | ||
}, | ||
plugins: [ | ||
commonjs(), | ||
nodeResolve({ | ||
browser, | ||
dedupe: dependenciesToDedupes, | ||
extensions, | ||
preferBuiltins: !browser, | ||
}), | ||
babel({ | ||
exclude: '**/node_modules/**', | ||
extensions, | ||
babelHelpers: 'bundled', | ||
}), | ||
replace({ | ||
preventAssignment: true, | ||
values: { | ||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), | ||
'process.env.BROWSER': JSON.stringify(browser), | ||
}, | ||
}), | ||
...(bundle ? [json(), nodePolyfills()] : []), | ||
...(minified ? [terser()] : []), | ||
...(!bundle && dir | ||
? [ | ||
generatePackageJson({ | ||
baseContents: { | ||
type: format === 'cjs' ? 'commonjs' : 'module', | ||
}, | ||
}), | ||
] | ||
: []), | ||
], | ||
onwarn: function (warning, rollupWarn) { | ||
rollupWarn(warning); | ||
if (!bundle && warning.code === 'CIRCULAR_DEPENDENCY') { | ||
const msg = 'Please eliminate the circular dependencies listed above and retry the build'; | ||
throw new Error(msg); | ||
} | ||
}, | ||
}; | ||
}; | ||
|
||
export default builds.map((build) => createConfig(build)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
src/plugins/bundlrStorage/planUploadMetadataUsingBundlrOperationHandler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
import { TOKEN_PROGRAM_ID } from '@solana/spl-token'; | ||
import { TokenProgramGpaBuilder } from './gpaBuilders'; | ||
import { MintGpaBuilder, TokenGpaBuilder } from './gpaBuilders'; | ||
import { Metaplex } from '@/Metaplex'; | ||
|
||
export const TokenProgram = { | ||
publicKey: TOKEN_PROGRAM_ID, | ||
|
||
accounts(metaplex: Metaplex) { | ||
return new TokenProgramGpaBuilder(metaplex, this.publicKey); | ||
}, | ||
|
||
mintAccounts(metaplex: Metaplex) { | ||
return this.accounts(metaplex).mintAccounts(); | ||
return new MintGpaBuilder(metaplex, this.publicKey); | ||
}, | ||
|
||
tokenAccounts(metaplex: Metaplex) { | ||
return this.accounts(metaplex).tokenAccounts(); | ||
return new TokenGpaBuilder(metaplex, this.publicKey); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.