dracoder-web3-package 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,322 +1,240 @@
1
- 'use strict'
1
+ "use strict";
2
2
 
3
- const Web3 = require('web3');
4
- const axios = require("axios");
5
- const { abiToken } = require('./helpers/factory_data');
3
+ const {Web3} = require("web3");
4
+ const {abiToken} = require("./helpers/factory_data");
6
5
 
7
- let walletConnectionUrl = 'wallet_connection';
8
- let tokenCreationUrl = 'token_creation';
9
- let tokenTransferUrl = 'token_transfer';
10
- let clientTokenTransferUrl = 'client_token_transfer';
11
- let getTokenTransactionUrl = 'get_token_transactions';
12
- let clientTokenOwnersBalanceUrl = 'token_owners_balance';
13
- let balanceUrl = 'balance';
14
- let deleteUrl = 'delete';
15
- let clientServerUrl = "";
16
-
17
- const setClientServerUrl = (url) => {
18
- clientServerUrl = url;
19
- }
20
-
21
- const setEndpointsUrls = ({
22
- walletConnectionCustomUrl = walletConnectionUrl,
23
- tokenCreationCustomUrl = tokenCreationUrl,
24
- tokenTransferCustomUrl = tokenTransferUrl,
25
- clientTokenTransferCustomUrl = clientTokenTransferUrl,
26
- getTokenTransactionCustomUrl = getTokenTransactionUrl,
27
- clientTokenOwnersBalanceCustomUrl = clientTokenOwnersBalanceUrl,
28
- balanceCustomUrl = balanceUrl,
29
- deleteCustomUrl = deleteUrl,
30
- }) => {
31
- walletConnectionUrl = walletConnectionCustomUrl;
32
- tokenCreationUrl = tokenCreationCustomUrl;
33
- tokenTransferUrl = tokenTransferCustomUrl;
34
- clientTokenTransferUrl = clientTokenTransferCustomUrl;
35
- getTokenTransactionUrl = getTokenTransactionCustomUrl;
36
- clientTokenOwnersBalanceUrl = clientTokenOwnersBalanceCustomUrl;
37
- balanceUrl = balanceCustomUrl;
38
- deleteUrl = deleteCustomUrl;
39
- }
40
-
41
- const metamaskConnect = async () => {
42
- // let walletConnectionResponse;
43
-
44
- if (typeof window.ethereum !== 'undefined') {
45
- const [account] = await ethereum.request({method: 'eth_requestAccounts'}).catch(async (error) => {
46
-
47
- throw {
48
- ok: false,
49
- message: 'Something went wrong connecting to Metamask.',
50
- metamaskMessage: error
51
- };
52
- });
53
-
54
- if (!account) {
55
- const message = "There is no account to connect to";
56
-
57
- throw {
58
- ok: false,
59
- message: message
60
- };
61
- }
62
-
63
- return {
64
- ok: true,
65
- message: "Connected successfully.",
66
- account: account
67
- };
68
- }
69
-
70
- const message = "There was a problem connecting to your Metamask wallet. Do you have Metamask installed?";
71
-
72
- // walletConnection({walletAddress: null, response: message, ...extraParameters});
73
-
74
- throw {
75
- ok: false,
76
- message: message
77
- };
78
- }
79
-
80
- const tokenCreate = async ({
81
- nameOfToken,
82
- numberOfToken,
83
- symbolOfToken,
84
- numberOfDecimals,
85
- userWalletAddress,
86
- ...extraParameters
87
- }) => {
88
- if (!userWalletAddress) {
89
- return {
90
- ok: false,
91
- message: "Wallet address is required and needs to be valid."
92
- }
93
- }
94
-
95
- return await axios.post(`${clientServerUrl}/${tokenCreationUrl}`, {
96
- nameOfToken,
97
- numberOfToken,
98
- symbolOfToken,
99
- numberOfDecimals,
100
- userWalletAddress,
101
- ...extraParameters
102
- });
6
+ const METAMASK_NOT_INSTALLED_MESSAGE = {
7
+ ok: false,
8
+ message: "You don't have Metamask installed.",
103
9
  }
104
10
 
105
- const tokenTransfer = async ({
106
- walletAddressToTransferFrom,
107
- walletAddressToTransferTo,
108
- tokenAddress,
109
- amount,
110
- ...extraParameters
111
- }) => {
112
- const {data} = await axios.post(`${clientServerUrl}/${tokenTransferUrl}`, {
113
- walletAddressToTransferFrom: walletAddressToTransferFrom,
114
- walletAddressToTransferTo: walletAddressToTransferTo,
115
- tokenAddress: tokenAddress,
116
- amount: amount,
117
- ...extraParameters
118
- });
119
-
120
- return data;
121
- }
122
-
123
- const clientTokenTransfer = async ({walletAddressToTransferTo, tokenAddress, amount, ...extraParameters}) => {
124
- const response = await metamaskConnect().catch(error => {
125
- throw error;
126
- });
127
- const account = response.account;
128
- let web3;
129
-
130
- try {
131
- web3 = new Web3(window.ethereum);
132
- } catch (error) {
133
- await tokenTransfer({
134
- walletAddressToTransferFrom: null,
135
- walletAddressToTransferTo: null,
136
- tokenAddress: null,
137
- amount: null,
138
- response: error,
139
- ...extraParameters
140
- })
141
- }
142
- if (!web3.utils.isAddress(account)) {
143
- throw new Error('Not valid account');
144
- }
145
- if (!web3.utils.isAddress(tokenAddress)) {
146
- throw new Error('Is not a Token Address');
147
- }
148
- if (!web3.utils.isAddress(walletAddressToTransferTo)) {
149
- throw new Error('Is not a Wallet Address to transfer to');
150
- }
151
- if (amount <= 0) {
152
- throw new Error('Amount must be greater than 0.');
153
- }
154
-
155
- const MyTokenContractInstance = new web3.eth.Contract(abiToken, tokenAddress);
156
- const decimals = await MyTokenContractInstance.methods.decimals().call();
157
- const amountToTransfer = (amount * Number(`1e${decimals}`)).toString();
158
-
159
- const pendingTokenTransfer = MyTokenContractInstance
160
- .methods
161
- .transfer(walletAddressToTransferTo, amountToTransfer)
11
+ const Metamask = window.ethereum
162
12
 
163
- return {account, pendingTokenTransfer};
13
+ const checkIfMetamaskIsAvailable = () => {
14
+ return typeof Metamask !== "undefined"
164
15
  }
165
16
 
166
- const tokenTransferWithTokenAddressOnly = async ({tokenAddress, ...extraParameters}) => {
167
- if (!tokenAddress) {
168
- throw new Error('Is not a Token Address');
169
- }
170
-
171
- return await axios.post(`${clientServerUrl}/${clientTokenTransferUrl}`, {
172
- tokenAddress: tokenAddress,
173
- ...extraParameters
17
+ const getMetamaskAccount = async () => {
18
+ const [account] = await Metamask
19
+ .request({method: "eth_requestAccounts"})
20
+ .catch(async (error) => {
21
+ throw {
22
+ ok: false,
23
+ message: "Something went wrong connecting to Metamask.",
24
+ metamaskMessage: error,
25
+ };
174
26
  });
175
- }
176
-
177
- const getTokenOwnersBalance = async ({tokenAddress, ...extraParams}) => {
178
- if (!tokenAddress) {
179
- throw new Error('Is not a Token Address');
180
- }
181
-
182
- return await axios.post(`${clientServerUrl}/${clientTokenOwnersBalanceUrl}`, {
183
- tokenAddress: tokenAddress,
184
- ...extraParams
27
+ if (!account) {
28
+ throw {
29
+ ok: false,
30
+ message: "There is no account to connect to",
31
+ };
32
+ }
33
+ return {
34
+ ok: true,
35
+ message: "Connected successfully.",
36
+ account: account,
37
+ };
38
+ };
39
+
40
+ const clientTokenTransfer = async ({
41
+ walletAddressToTransferTo,
42
+ tokenAddress,
43
+ amount,
44
+ }) => {
45
+ if (!checkIfMetamaskIsAvailable()) {
46
+ return METAMASK_NOT_INSTALLED_MESSAGE
47
+ }
48
+ const response = await getMetamaskAccount().catch((error) => {
49
+ throw error;
50
+ });
51
+ const account = response.account;
52
+ let web3;
53
+
54
+ try {
55
+ web3 = new Web3(Metamask);
56
+ } catch (error) {
57
+ throw error;
58
+ }
59
+
60
+ if (!web3.utils.isAddress(account)) {
61
+ throw new Error("Not valid account");
62
+ }
63
+ if (!web3.utils.isAddress(tokenAddress)) {
64
+ throw new Error("Is not a Token Address");
65
+ }
66
+ if (!web3.utils.isAddress(walletAddressToTransferTo)) {
67
+ throw new Error("Is not a Wallet Address to transfer to");
68
+ }
69
+ if (amount <= 0) {
70
+ throw new Error("Amount must be greater than 0.");
71
+ }
72
+
73
+ const MyTokenContractInstance = new web3.eth.Contract(abiToken, tokenAddress);
74
+ const decimals = await MyTokenContractInstance.methods.decimals().call();
75
+ const amountToTransfer = (amount * Number(`1e${decimals}`)).toString();
76
+
77
+ const pendingTokenTransfer = MyTokenContractInstance.methods.transfer(
78
+ walletAddressToTransferTo,
79
+ amountToTransfer
80
+ );
81
+
82
+ try {
83
+ const transactionReceipt = await pendingTokenTransfer.send({
84
+ from: account,
185
85
  });
186
- }
187
86
 
188
- const sendTokenToWallet = async ({tokenAddress, ...extraParameters}) => {
189
- await metamaskConnect().catch(error => {
190
- throw error
87
+ return {
88
+ ok: true,
89
+ message: "Transfer successful",
90
+ transactionHash: transactionReceipt.transactionHash,
91
+ };
92
+ } catch (error) {
93
+ throw {
94
+ ok: false,
95
+ message: "Transfer failed",
96
+ error: error,
97
+ };
98
+ }
99
+ };
100
+
101
+ const sendTokenToWallet = async ({tokenAddress}) => {
102
+ if (!checkIfMetamaskIsAvailable()) {
103
+ return METAMASK_NOT_INSTALLED_MESSAGE
104
+ }
105
+
106
+ await getMetamaskAccount().catch((error) => {
107
+ throw error;
108
+ });
109
+
110
+ let web3 = new Web3(Metamask);
111
+ let tokenAdded = false;
112
+
113
+ const MyTokenContractInstance = new web3.eth.Contract(
114
+ abiToken,
115
+ tokenAddress
116
+ );
117
+
118
+ try {
119
+ const symbol = await MyTokenContractInstance.methods.symbol().call();
120
+ const decimals = web3.utils.toNumber(await MyTokenContractInstance.methods.decimals().call())
121
+ const response = await Metamask.request({
122
+ method: 'wallet_watchAsset',
123
+ params: {
124
+ type: 'ERC20',
125
+ options: {
126
+ address: tokenAddress,
127
+ symbol: symbol,
128
+ decimals: decimals,
129
+ },
130
+ },
191
131
  });
132
+ tokenAdded = !!response;
133
+ } catch (error) {
134
+ return error
135
+ }
136
+ return tokenAdded;
192
137
 
193
- let web3 = new Web3(window.ethereum);
194
- let tokenAdded = false;
195
-
196
- if (typeof window.ethereum !== 'undefined') {
197
- const MyTokenContractInstance = new web3.eth.Contract(abiToken, tokenAddress);
198
-
199
- const symbol = await MyTokenContractInstance.methods.symbol().call();
200
- const decimals = await MyTokenContractInstance.methods.decimals().call();
201
- const response = await ethereum
202
- .request({
203
- method: 'wallet_watchAsset',
204
- params: {
205
- type: 'ERC20',
206
- options: {
207
- address: tokenAddress,
208
- symbol: symbol,
209
- decimals: decimals,
210
- },
211
- },
212
- });
213
-
214
- tokenAdded = !!response;
215
- }
216
-
217
- return tokenAdded;
218
- }
138
+ };
219
139
 
220
140
  const isMetamaskInstalled = () => {
221
- if (typeof window.ethereum == 'undefined') {
222
- return {
223
- ok: false,
224
- message: "You don't have Metamask installed."
225
- }
226
- }
141
+ if (!checkIfMetamaskIsAvailable()) {
142
+ return METAMASK_NOT_INSTALLED_MESSAGE
143
+ }
144
+ return {
145
+ ok: true,
146
+ message: "Metamask is installed",
147
+ };
227
148
 
228
- return {
229
- ok: true,
230
- message: "Metamask is installed"
231
- }
232
- }
149
+ };
233
150
 
234
151
  const checkWalletFormat = (account) => {
235
- let web3;
236
-
237
- try {
238
- web3 = new Web3(window.ethereum);
239
- } catch (error) {
240
- return {
241
- ok: false,
242
- message: "Web3 can not be loaded. Metamask must be installed",
243
- error: error
244
- }
245
- }
246
-
247
- if (!web3.utils.isAddress(account)) {
248
- return {
249
- ok: false,
250
- message: "Wrong address format"
251
- }
252
- }
253
-
152
+ let web3;
153
+ if (!checkIfMetamaskIsAvailable()) {
154
+ return METAMASK_NOT_INSTALLED_MESSAGE
155
+ }
156
+ try {
157
+ web3 = new Web3(Metamask);
158
+ } catch (error) {
254
159
  return {
255
- ok: true,
256
- message: "Proper address format"
257
- }
258
- }
160
+ ok: false,
161
+ message: "Web3 can not be loaded. Metamask must be installed",
162
+ error: error,
163
+ };
164
+ }
259
165
 
260
- const selectOrAddPolygonMainNetwork = async ({...extraParameters}) => {
261
- await metamaskConnect().catch(error => {
262
- throw error
166
+ if (!web3.utils.isAddress(account)) {
167
+ return {
168
+ ok: false,
169
+ message: "Wrong address format",
170
+ };
171
+ }
172
+
173
+ return {
174
+ ok: true,
175
+ message: "Proper address format",
176
+ };
177
+ };
178
+
179
+ const selectOrAddPolygonMainNetwork = async () => {
180
+ if (!checkIfMetamaskIsAvailable()) {
181
+ return METAMASK_NOT_INSTALLED_MESSAGE
182
+ }
183
+ await getMetamaskAccount().catch((error) => {
184
+ throw error;
185
+ });
186
+ try {
187
+ await Metamask.request({
188
+ method: "wallet_switchEthereumChain",
189
+ params: [{chainId: "0x89"}],
263
190
  });
264
- if (typeof window.ethereum !== 'undefined') {
265
- try {
266
- await ethereum
267
- .request({
268
- method: 'wallet_switchEthereumChain',
269
- params: [{chainId: '0x89'}],
270
- });
271
- } catch (switchError) {
272
- if (switchError.code === 4902) {
273
- // This error code indicates that the chain has not been added to MetaMask.
274
- const params = [{
275
- chainId: '0x89',
276
- chainName: 'Matic Mainnet',
277
- nativeCurrency: {
278
- name: 'MATIC',
279
- symbol: 'MATIC',
280
- decimals: 18
281
- },
282
- rpcUrls: ['https://polygon-rpc.com/', 'https://rpc-mainnet.maticvigil.com/'],
283
- blockExplorerUrls: ['https://polygonscan.com/']
284
- }];
285
- try {
286
- const response = await ethereum
287
- .request({
288
- method: 'wallet_addEthereumChain',
289
- params: params
290
- });
291
- return {
292
- ok: true,
293
- message: "Matic Mainnet added successfully",
294
- response: response
295
- }
296
- } catch (error) {
297
- return {
298
- ok: false,
299
- message: "Matic Mainnet can not be added",
300
- response: error
301
- }
302
- }
303
- }
304
- }
191
+ return {
192
+ ok: true,
193
+ message: "Already on polygon main network",
194
+ };
195
+ } catch (switchError) {
196
+ if (switchError.code === 4902) {
197
+ const params = [
198
+ {
199
+ chainId: "0x89",
200
+ chainName: "Matic MainNet",
201
+ nativeCurrency: {
202
+ name: "MATIC",
203
+ symbol: "MATIC",
204
+ decimals: 18,
205
+ },
206
+ rpcUrls: [
207
+ "https://polygon-rpc.com/",
208
+ "https://rpc-mainnet.maticvigil.com/",
209
+ ],
210
+ blockExplorerUrls: ["https://polygonscan.com/"],
211
+ },
212
+ ];
213
+ try {
214
+ const response = await Metamask.request({
215
+ method: "wallet_addEthereumChain",
216
+ params: params,
217
+ });
218
+ return {
219
+ ok: true,
220
+ message: "Matic MainNet added successfully",
221
+ response: response,
222
+ };
223
+ } catch (error) {
224
+ return {
225
+ ok: false,
226
+ message: "Matic MainNet can not be added",
227
+ response: error,
228
+ };
229
+ }
305
230
  }
306
-
307
- }
231
+ }
232
+ };
308
233
 
309
234
  module.exports = {
310
- setClientServerUrl,
311
- setEndpointsUrls,
312
- metamaskConnect,
313
- tokenCreate,
314
- tokenTransfer,
315
- clientTokenTransfer,
316
- tokenTransferWithTokenAddressOnly,
317
- getTokenOwnersBalance,
318
- sendTokenToWallet,
319
- isMetamaskInstalled,
320
- checkWalletFormat,
321
- selectOrAddPolygonMainNetwork
322
- }
235
+ clientTokenTransfer,
236
+ sendTokenToWallet,
237
+ isMetamaskInstalled,
238
+ checkWalletFormat,
239
+ selectOrAddPolygonMainNetwork,
240
+ };
package/package.json CHANGED
@@ -1,21 +1,29 @@
1
1
  {
2
2
  "name": "dracoder-web3-package",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "Dracoder package used for web3 provider integration.",
5
5
  "main": "index.js",
6
6
  "keywords": [
7
- "rocketchain",
7
+ "dracoder",
8
8
  "web3",
9
9
  "api",
10
10
  "metamask"
11
11
  ],
12
12
  "scripts": {
13
- "test": "echo \"Error: no test specified\" && exit 1"
13
+ "build": "webpack",
14
+ "start": "webpack && node test/app.js"
14
15
  },
15
16
  "author": "Dracoder S.L.",
16
17
  "license": "MIT",
17
18
  "dependencies": {
18
- "axios": "^1.6.7",
19
19
  "web3": "^4.4.0"
20
+ },
21
+ "devDependencies": {
22
+ "@babel/core": "^7.15.0",
23
+ "@babel/preset-env": "^7.15.0",
24
+ "babel-loader": "^8.2.2",
25
+ "express": "^4.18.2",
26
+ "webpack": "^5.51.1",
27
+ "webpack-cli": "^4.8.0"
20
28
  }
21
29
  }
package/test/app.js ADDED
@@ -0,0 +1,16 @@
1
+ const express = require('express');
2
+ const {join} = require("path");
3
+
4
+ const port = 3000;
5
+ const app = express();
6
+
7
+ app.use('/static', express.static(join(__dirname+'/../lib/')));
8
+
9
+ app.use(express.urlencoded({ extended: false }));
10
+ app.use(express.json());
11
+
12
+ app.get('/', (req, res) => {
13
+ res.sendFile(join(__dirname+'/test.html'))
14
+ });
15
+
16
+ app.listen(port, () => console.log(`Servidor iniciado en el puerto ${port}`));
package/test/test.html ADDED
@@ -0,0 +1,106 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <title>Test</title>
7
+ </head>
8
+
9
+ <body>
10
+
11
+ <h1>Test web3 integration functionalities</h1>
12
+ <div id="check-metamask-installed-functionality">
13
+ <h3>Check if metamask is installed</h3>
14
+ <button onclick="checkIfMetamaskIsInstalled()">Check</button>
15
+ <pre>Click "Check" button</pre>
16
+ </div>
17
+
18
+ <div id="check-add-polygon-network">
19
+ <h3>Check if can add polygon network</h3>
20
+ <button onclick="checkIfCanAddPolygon()">Check</button>
21
+ <pre>Click "Check" button</pre>
22
+ </div>
23
+
24
+ <div id="check-wallet-format">
25
+ <h3>Check wallet format</h3>
26
+ <input id="inputCheckWalletFormat" style="width: 25rem" type="text"
27
+ value="0x104d7e4b44F64c633Be6B099995eecb0Ac344611"/>
28
+ <button onclick="checkWalletFormat()">Check</button>
29
+ <pre>Click "Check" button</pre>
30
+ </div>
31
+
32
+ <div id="check-add-token-to-metamask">
33
+ <h3>Check add token to metamask</h3>
34
+ <input id="inputCheckAddTokenToMetamask" style="width: 25rem" type="text"
35
+ value="0xF516d5b66a954ae85aC08b33729dFe9BCF380207"/>
36
+ <button onclick="checkAddTokenToMetamask()">Check</button>
37
+ <pre>Click "Check" button</pre>
38
+ </div>
39
+
40
+ <div id="transfer-token">
41
+ <h3>Transfer Token</h3>
42
+ <input id="inputTokenAddress" style="width: 25rem" type="text" disabled
43
+ value="0xFdD0631B7B4a24efE135fDC816C3951cE2dB8854"/>
44
+ <input id="inputRecipientAddress" style="width: 25rem" type="text" value="0x104d7e4b44F64c633Be6B099995eecb0Ac344611" placeholder="Recipient Address"/>
45
+ <input id="inputAmount" style="width: 25rem" type="number" value="1" disabled/>
46
+ <button onclick="transferToken()">Send</button>
47
+ <pre id="transferTokenResult">Click "Send" button</pre>
48
+ </div>
49
+
50
+ <script src="/static/dracoderWeb3Integration.js"></script>
51
+ <script>
52
+ function checkIfMetamaskIsInstalled() {
53
+ const spanToPrintMessage = document.querySelector('#check-metamask-installed-functionality>pre')
54
+ spanToPrintMessage.innerHTML = JSON.stringify(dracoderWeb3Integration.isMetamaskInstalled())
55
+ }
56
+
57
+ async function checkIfCanAddPolygon() {
58
+ const spanToPrintMessage = document.querySelector('#check-add-polygon-network>pre')
59
+ try {
60
+ const response = await dracoderWeb3Integration.selectOrAddPolygonMainNetwork({})
61
+ spanToPrintMessage.innerHTML = JSON.stringify(response)
62
+ } catch (e) {
63
+ spanToPrintMessage.innerHTML = JSON.stringify(e)
64
+ }
65
+ }
66
+
67
+ function checkWalletFormat() {
68
+ const input = document.querySelector('#check-wallet-format>input')
69
+ const spanToPrintMessage = document.querySelector('#check-wallet-format>pre')
70
+ spanToPrintMessage.innerHTML = JSON.stringify(dracoderWeb3Integration.checkWalletFormat(input.value))
71
+ }
72
+
73
+ async function checkAddTokenToMetamask() {
74
+ const inputTokenAddress = document.querySelector('#inputCheckAddTokenToMetamask').value
75
+
76
+ const spanToPrintMessage = document.querySelector('#check-add-token-to-metamask>pre')
77
+ try {
78
+ const result = await dracoderWeb3Integration.sendTokenToWallet({tokenAddress: inputTokenAddress})
79
+ spanToPrintMessage.innerHTML = JSON.stringify(result)
80
+ } catch (error) {
81
+ spanToPrintMessage.innerHTML = JSON.stringify(error)
82
+ }
83
+ }
84
+
85
+ function transferToken() {
86
+ const inputRecipientAddress = document.getElementById("inputRecipientAddress").value;
87
+ const inputAmount = document.getElementById("inputAmount").value;
88
+ const transferTokenResult = document.getElementById("transferTokenResult");
89
+
90
+ dracoderWeb3Integration
91
+ .clientTokenTransfer({
92
+ walletAddressToTransferTo: inputRecipientAddress,
93
+ tokenAddress: "0xFdD0631B7B4a24efE135fDC816C3951cE2dB8854",
94
+ amount: inputAmount,
95
+ })
96
+ .then((response) => {
97
+ transferTokenResult.innerHTML = JSON.stringify(response);
98
+ })
99
+ .catch((error) => {
100
+ transferTokenResult.innerHTML = JSON.stringify(error);
101
+ });
102
+ }
103
+ </script>
104
+ </body>
105
+
106
+ </html>
@@ -0,0 +1,29 @@
1
+ const path = require("path");
2
+
3
+ module.exports = {
4
+ entry: "./index.js",
5
+ output: {
6
+ path: path.resolve(__dirname, "lib"),
7
+ filename: "dracoderWeb3Integration.js",
8
+ library: {
9
+ name: "dracoderWeb3Integration",
10
+ type: "umd",
11
+ },
12
+ globalObject: "this",
13
+ },
14
+ mode: "development",
15
+ module: {
16
+ rules: [
17
+ {
18
+ test: /\.m?js$/,
19
+ exclude: /node_modules/,
20
+ use: {
21
+ loader: "babel-loader",
22
+ options: {
23
+ presets: ["@babel/preset-env"],
24
+ },
25
+ },
26
+ },
27
+ ],
28
+ },
29
+ };