Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #490 from EOSIO/no-default-exports
Browse files Browse the repository at this point in the history
No default exports
  • Loading branch information
c0d3ster authored Feb 5, 2019
2 parents 83491be + 51b49c8 commit 0d537ba
Show file tree
Hide file tree
Showing 13 changed files with 1,677 additions and 785 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"jest": "^23.5.0",
"jest-fetch-mock": "^1.6.5",
"json-loader": "^0.5.7",
"ts-jest": "^23.1.4",
"ts-jest": "23.1.4",
"ts-loader": "^4.3.1",
"tslint": "^5.11.0",
"tslint-eslint-rules": "^5.4.0",
Expand Down
4 changes: 2 additions & 2 deletions src/eosjs-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// copyright defined in eosjs/LICENSE.txt

import { AbiProvider, AuthorityProvider, BinaryAbi, CachedAbi, SignatureProvider } from "./eosjs-api-interfaces";
import JsonRpc from "./eosjs-jsonrpc";
import { JsonRpc } from "./eosjs-jsonrpc";
import { Abi, GetInfoResult, PushTransactionArgs } from "./eosjs-rpc-interfaces";
import * as ser from "./eosjs-serialize";

Expand All @@ -13,7 +13,7 @@ const abiAbi = require('../src/abi.abi.json');
// tslint:disable-next-line
const transactionAbi = require('../src/transaction.abi.json');

export default class Api {
export class Api {
/** Issues RPC calls */
public rpc: JsonRpc;

Expand Down
4 changes: 2 additions & 2 deletions src/eosjs-jsonrpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { AbiProvider, AuthorityProvider, AuthorityProviderArgs, BinaryAbi } from "./eosjs-api-interfaces";
import { base64ToBinary, convertLegacyPublicKeys } from "./eosjs-numeric";
import { GetAbiResult, GetBlockResult, GetCodeResult, GetInfoResult, GetRawCodeAndAbiResult, PushTransactionArgs } from "./eosjs-rpc-interfaces"; // tslint:disable-line
import RpcError from "./eosjs-rpcerror";
import { RpcError } from "./eosjs-rpcerror";

function arrayToHex(data: Uint8Array) {
let result = "";
Expand All @@ -17,7 +17,7 @@ function arrayToHex(data: Uint8Array) {
}

/** Make RPC calls */
export default class JsonRpc implements AuthorityProvider, AbiProvider {
export class JsonRpc implements AuthorityProvider, AbiProvider {
public endpoint: string;
public fetchBuiltin: (input?: Request | string, init?: RequestInit) => Promise<Response>;

Expand Down
2 changes: 1 addition & 1 deletion src/eosjs-jssig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { SignatureProvider, SignatureProviderArgs } from "./eosjs-api-interfaces
import { convertLegacyPublicKey } from "./eosjs-numeric";

/** Signs transactions using in-process private keys */
export default class JsSignatureProvider implements SignatureProvider {
export class JsSignatureProvider implements SignatureProvider {
/** map public to private keys */
public keys = new Map<string, string>();

Expand Down
2 changes: 1 addition & 1 deletion src/eosjs-rpcerror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// copyright defined in eosjs/LICENSE.txt

/** Holds detailed error information */
export default class RpcError extends Error {
export class RpcError extends Error {
/** Detailed error information */
public json: any;

Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Api from "./eosjs-api";
import { Api } from "./eosjs-api";
import * as ApiInterfaces from "./eosjs-api-interfaces";
import JsonRpc from "./eosjs-jsonrpc";
import { JsonRpc } from "./eosjs-jsonrpc";
import * as RpcInterfaces from "./eosjs-rpc-interfaces";
import RpcError from "./eosjs-rpcerror";
import { RpcError } from "./eosjs-rpcerror";
import * as Serialize from "./eosjs-serialize";

export { Api, ApiInterfaces, JsonRpc, RpcInterfaces, RpcError, Serialize };
6 changes: 3 additions & 3 deletions src/rpc-web.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import JsonRpc from "./eosjs-jsonrpc";
import RpcError from "./eosjs-rpcerror";
import { JsonRpc } from "./eosjs-jsonrpc";
import { RpcError } from "./eosjs-rpcerror";

export { JsonRpc as default, RpcError };
export { JsonRpc, RpcError };
6 changes: 3 additions & 3 deletions src/tests/eosjs-api.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TextDecoder, TextEncoder } from "text-encoding";
import Api from "../eosjs-api";
import JsonRpc from "../eosjs-jsonrpc";
import JsSignatureProvider from "../eosjs-jssig";
import { Api } from "../eosjs-api";
import { JsonRpc } from "../eosjs-jsonrpc";
import { JsSignatureProvider } from "../eosjs-jssig";

const transaction = {
expiration: "2018-09-04T18:42:49",
Expand Down
4 changes: 2 additions & 2 deletions src/tests/eosjs-jsonrpc.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import JsonRpc from "../eosjs-jsonrpc";
import RpcError from "../eosjs-rpcerror";
import { JsonRpc } from "../eosjs-jsonrpc";
import { RpcError } from "../eosjs-rpcerror";

describe("JSON RPC", () => {
const endpoint = "http://localhost";
Expand Down
2 changes: 1 addition & 1 deletion src/tests/eosjs-jssig.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ecc from "eosjs-ecc";
import JsSignatureProvider from "../eosjs-jssig";
import { JsSignatureProvider } from "../eosjs-jssig";

describe("JsSignatureProvider", () => {
const privateKeys = ["key1", "key2", "key3"];
Expand Down
2 changes: 1 addition & 1 deletion src/tests/setupJest.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
global.fetch = require("jest-fetch-mock");
global.fetch = require("jest-fetch-mock");
44 changes: 25 additions & 19 deletions src/tests/web.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
<pre style='width: 100%; height: 100%; margin:0px; '></pre>

<script src='../../dist-web/eosjs-api-debug.js'></script>
<script src='../../dist-web/eosjs-jsonrpc-debug.js'></script>
<script src='../../dist-web/eosjs-jssig-debug.js'></script>
<script src='../../dist-web/eosjs-api.js'></script>
<script src='../../dist-web/eosjs-jsonrpc.js'></script>
<script src='../../dist-web/eosjs-jssig.js'></script>
<script>
let pre = document.getElementsByTagName('pre')[0];
const defaultPrivateKey = '5JtUScZK2XEp3g9gh7F8bwtPTRAkASmNrrftmx4AxDKD5K4zDnr'; // useraaaaaaaa
const privateKey = '5JuH9fCXmU3xbj8nRmhPZaVrxxXrdPaRmZLW1cznNTmTQR2Kg5Z'; // replace with "bob" account private key
/* new accounts for testing can be created by unlocking a cleos wallet then calling:
* 1) cleos create key --to-console (copy this privateKey & publicKey)
* 2) cleos wallet import
* 3) cleos create account bob publicKey
* 4) cleos create account alice publicKey
*/

const rpc = new eosjs_jsonrpc.default('http://localhost:8888');
const signatureProvider = new eosjs_jssig.default([defaultPrivateKey]);
const api = new eosjs_api.default({ rpc, signatureProvider });
const rpc = new eosjs_jsonrpc.JsonRpc('http://localhost:8888');
const signatureProvider = new eosjs_jssig.JsSignatureProvider([privateKey]);
const api = new eosjs_api.Api({ rpc, signatureProvider });

function waitTwoSeconds() {
return new Promise(resolve => setTimeout(resolve, 2000));
Expand All @@ -22,12 +28,12 @@
account: 'eosio.token',
name: 'transfer',
authorization: [{
actor: 'useraaaaaaaa',
actor: 'bob',
permission: 'active',
}],
data: {
from: 'useraaaaaaaa',
to: 'useraaaaaaab',
from: 'bob',
to: 'alice',
quantity: '0.0001 SYS',
memo: '',
},
Expand All @@ -44,12 +50,12 @@
account: 'eosio.token',
name: 'transfer',
authorization: [{
actor: 'useraaaaaaaa',
actor: 'bob',
permission: 'active',
}],
data: {
from: 'useraaaaaaaa',
to: 'useraaaaaaab',
from: 'bob',
to: 'alice',
quantity: '0.0001 SYS',
memo: '',
},
Expand Down Expand Up @@ -80,12 +86,12 @@
account: 'eosio.token',
name: 'transfer',
authorization: [{
actor: 'useraaaaaaaa',
actor: 'bob',
permission: 'active',
}],
data: {
from: 'useraaaaaaaa',
to: 'useraaaaaaab',
from: 'bob',
to: 'alice',
quantity: '0.0001 SYS',
memo: '',
},
Expand All @@ -106,12 +112,12 @@
account: 'eosio.token',
name: 'transfer',
authorization: [{
actor: 'useraaaaaaaa',
actor: 'bob',
permission: 'active',
}],
data: {
from: 'useraaaaaaaa',
to: 'useraaaaaaab',
from: 'bob',
to: 'alice',
quantity: '0.0001 SYS',
memo: '',
},
Expand Down
Loading

0 comments on commit 0d537ba

Please sign in to comment.