Skip to content

Commit

Permalink
feat: esm
Browse files Browse the repository at this point in the history
  • Loading branch information
AbigailDeng authored and AbigailDeng committed Oct 22, 2024
1 parent 24ea35f commit 2d95df2
Show file tree
Hide file tree
Showing 9 changed files with 252 additions and 248 deletions.
7 changes: 6 additions & 1 deletion build/webpack.esModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ const nodeConfig = {
alias: {},
fallback: {
crypto: 'crypto-browserify',
stream: 'stream-browserify'
stream: 'stream-browserify',
https: false,
http: false,
child_process: false,
fs: false,
url: false
}
}
};
Expand Down
450 changes: 225 additions & 225 deletions jest-report.xml

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aelf-sdk",
"version": "3.4.17-alpha.0",
"version": "3.4.17-alpha.1",
"description": "aelf-sdk js library",
"type": "module",
"main": "dist/aelf.cjs.js",
Expand Down Expand Up @@ -28,12 +28,12 @@
"release": "standard-version -a",
"pre-commit": "lint-staged",
"test": "yarn test:browser && yarn test:node",
"test:browser": "jest --config=jest.browser.config.js",
"test:browser:watch": "jest --config=jest.browser.config.js --watch",
"test:node": "jest --config=jest.node.config.js",
"test:node:watch": "jest --config=jest.node.config.js --watch",
"test:coverage": "jest --config=jest.browser.config.js --coverage",
"test:coverageNode": "jest --config=jest.node.config.js --coverage",
"test:browser": "jest --config=jest.browser.config.cjs",
"test:browser:watch": "jest --config=jest.browser.config.cjs --watch",
"test:node": "jest --config=jest.node.config.cjs",
"test:node:watch": "jest --config=jest.node.config.cjs --watch",
"test:coverage": "jest --config=jest.browser.config.cjs --coverage",
"test:coverageNode": "jest --config=jest.node.config.cjs --coverage",
"prepare": "husky install",
"copy-ts": "cpx \"types/**/*.ts\" dist/"
},
Expand Down Expand Up @@ -87,6 +87,7 @@
"scryptsy": "^2.1.0",
"stream-browserify": "^3.0.0",
"typescript": "^5.0.4",
"xhr2": "^0.2.1",
"xmlhttprequest": "^1.8.0"
},
"lint-staged": {
Expand Down
9 changes: 4 additions & 5 deletions src/util/httpProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* @author atom-yang
*/
import { stringify } from 'query-string';
import NodeFetch, { Headers } from 'node-fetch';
import { XMLHttpRequest as XHR } from 'xmlhttprequest';

const defaultHeaders = {
Accept: 'text/plain;v=1.0',
Expand All @@ -28,11 +30,8 @@ if (process.env.RUNTIME_ENV === 'browser') {
}
} else {
// For node use xmlhttprequest
// eslint-disable-next-line global-require
RequestLibraryXMLOnly = require('xmlhttprequest').XMLHttpRequest;
// eslint-disable-next-line global-require
const NodeFetch = require('node-fetch');
RequestLibrary = NodeFetch.default;
RequestLibraryXMLOnly = XHR;
RequestLibrary = NodeFetch;
NodeHeaders = NodeFetch.Headers;
isFetch = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/util/keccak.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const createKeccakHash = require('keccak');
import createKeccakHash from 'keccak';

const keccak = bits => str => {
let msg;
Expand Down
12 changes: 3 additions & 9 deletions types/wallet/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import HDNode = require('hdkey');
import HDNode from 'hdkey';
import * as Bip39 from 'bip39';
import { ec, curve } from 'elliptic';
import { TRawTransaction, TAddress } from '../util/proto';
Expand Down Expand Up @@ -34,10 +34,7 @@ interface IWallet {
createNewWallet(BIP44Path?: BIP44Path): IWalletInfo;
getWalletByMnemonic(mnemonic: Mnemonic, BIP44Path: BIP44Path): IWalletInfo;
getWalletByPrivateKey(privateKey: PrivateKey): IWalletInfo;
signTransaction(
rawTxn: TRawTransaction,
keyPair: ec.KeyPair
): SignTransaction;
signTransaction(rawTxn: TRawTransaction, keyPair: ec.KeyPair): SignTransaction;
sign(hexString: string, keyPair: ec.KeyPair): Buffer;
}
export declare class Wallet implements IWallet {
Expand All @@ -52,10 +49,7 @@ export declare class Wallet implements IWallet {
createNewWallet(BIP44Path?: BIP44Path): IWalletInfo;
getWalletByMnemonic(mnemonic: Mnemonic, BIP44Path: BIP44Path): IWalletInfo;
getWalletByPrivateKey(privateKey: PrivateKey): IWalletInfo;
signTransaction(
rawTxn: TRawTransaction,
keyPair: ec.KeyPair
): SignTransaction;
signTransaction(rawTxn: TRawTransaction, keyPair: ec.KeyPair): SignTransaction;
sign(hexString: string, keyPair: ec.KeyPair): Buffer;
}
export default Wallet;
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10350,6 +10350,11 @@ ws@^8.11.0:
resolved "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b"
integrity sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==

xhr2@^0.2.1:
version "0.2.1"
resolved "https://registry.npmjs.org/xhr2/-/xhr2-0.2.1.tgz#4e73adc4f9cfec9cbd2157f73efdce3a5f108a93"
integrity sha512-sID0rrVCqkVNUn8t6xuv9+6FViXjUVXq8H5rWOH2rz9fDNQEd4g0EA2XlcEdJXRz5BMEn4O1pJFdT+z4YHhoWw==

xml-name-validator@^3.0.0:
version "3.0.0"
resolved "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"
Expand Down

0 comments on commit 2d95df2

Please sign in to comment.