Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

poc: build for browsers #556

Draft
wants to merge 2 commits into
base: old-dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 36 additions & 9 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,42 @@
module.exports = {
presets: [
'@babel/preset-react',
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
'@babel/preset-typescript',
'@babel/preset-env',
],
plugins: ["@babel/plugin-transform-async-generator-functions"],
plugins: [
"@babel/plugin-transform-async-generator-functions",
],
env: {
node: {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
],
},
browser: {
presets: [
[
'@babel/preset-env',
{
targets: {
browsers: [
"Chrome >= 60",
"Safari >= 10.1",
"iOS >= 10.3",
"Firefox >= 54",
"Edge >= 15"
]
},
},
],
],
},
}
};
103 changes: 0 additions & 103 deletions index.js

This file was deleted.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "@hathor/wallet-lib",
"version": "1.0.0-rc6",
"description": "Library used by Hathor Wallet",
"main": "index.js",
"main": "lib/node/index.js",
"browser": "lib/browser/index.js",
"directories": {
"lib": "lib"
},
Expand All @@ -23,7 +24,9 @@
"scripts": {
"test": "jest --env=node --forceExit",
"test:watch": "jest --watch --env=node",
"build": "babel -d lib --extensions \".ts,.js\" src && tsc",
"build:node": "babel -d lib/node --env-name=node --extensions \".ts,.js\" src && tsc --outDir lib/node",
"build:browser": "babel -d lib/browser --env-name=browser --extensions \".ts,.js\" src && tsc --outDir lib/browser",
"build": "npm run build:node && npm run build:browser",
"tsc": "tsc",
"test_integration": "npm run test_network_up && npm run test_network_integration && npm run test_network_down",
"test_network_up": "docker-compose -f ./__tests__/integration/configuration/docker-compose.yml up -d && mkdir -p tmp && cp ./__tests__/integration/configuration/precalculated-wallets.json ./tmp/wallets.json",
Expand Down
103 changes: 103 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import * as constants from './constants';
import dateFormatter from './utils/date';
import websocket from './websocket';
import * as errors from './errors';
import * as ErrorMessages from './errorMessages';
import walletApi from './api/wallet';
import txApi from './api/txApi';
import txMiningApi from './api/txMining';
import versionApi from './api/version';
import * as axios from './api/axiosInstance';
import metadataApi from './api/metadataApi';
import { Storage } from './storage/storage';
import LevelDBStore from './storage/leveldb/store';
import * as memoryStore from './storage/memory_store';
import network from './network';
import HathorWallet from './new/wallet';
import Connection from './new/connection';
import WalletServiceConnection from './wallet/connection';
import SendTransaction from './new/sendTransaction';
import Address from './models/address';
import Output from './models/output';
import P2PKH from './models/p2pkh';
import P2SH from './models/p2sh';
import P2SHSignature from './models/p2sh_signature';
import ScriptData from './models/script_data';
import Input from './models/input';
import Transaction from './models/transaction';
import CreateTokenTransaction from './models/create_token_transaction';
import Network from './models/network';
import * as addressUtils from './utils/address';
import * as cryptoUtils from './utils/crypto';
import dateUtils from './utils/date';
import tokensUtils from './utils/tokens';
import walletUtils from './utils/wallet';
import helpersUtils from './utils/helpers';
import * as numberUtils from './utils/numbers';
import * as scriptsUtils from './utils/scripts';
import transactionUtils from './utils/transaction';
import * as bufferUtils from './utils/buffer';
import HathorWalletServiceWallet from './wallet/wallet';
import walletServiceApi from './wallet/api/walletApi';
import SendTransactionWalletService from './wallet/sendTransactionWalletService';
import config from './config';
import * as PushNotification from './pushNotification';
import { WalletType } from './types';

import {PartialTx, PartialTxInputData} from './models/partial_tx';
import PartialTxProposal from './wallet/partialTxProposal';
import * as swapService from './wallet/api/swapService';
import { AtomicSwapServiceConnection } from './swapService/swapConnection';

export default {
PartialTx,
PartialTxInputData,
PartialTxProposal,
dateFormatter,
websocket,
walletApi,
txApi,
txMiningApi,
versionApi,
metadataApi,
errors,
ErrorMessages,
constants,
axios,
Storage,
LevelDBStore,
MemoryStore: memoryStore.MemoryStore,
network,
HathorWallet,
Connection,
AtomicSwapServiceConnection,
WalletServiceConnection,
SendTransaction,
Address,
Output,
P2PKH,
P2SH,
P2SHSignature,
ScriptData,
Input,
Transaction,
CreateTokenTransaction,
Network,
addressUtils,
cryptoUtils,
dateUtils,
tokensUtils,
walletUtils,
numberUtils,
helpersUtils,
scriptsUtils,
bufferUtils,
transactionUtils,
HathorWalletServiceWallet,
walletServiceApi,
SendTransactionWalletService,
config,
PushNotification,
swapService,
WalletType,
};