Skip to content

Commit

Permalink
feat!: rename and expose Account module
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-liu committed Jan 1, 2022
1 parent d8d739f commit 08361a5
Show file tree
Hide file tree
Showing 23 changed files with 9,405 additions and 9,422 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.3.16",
"version": "2.3.17-alpha.1",
"packages": [
"src/*"
],
Expand Down
20 changes: 0 additions & 20 deletions src/HTTP/tsconfig.json

This file was deleted.

20 changes: 0 additions & 20 deletions src/IPC/tsconfig.json

This file was deleted.

20 changes: 0 additions & 20 deletions src/WS/tsconfig.json

This file was deleted.

20 changes: 0 additions & 20 deletions src/abi/tsconfig.json

This file was deleted.

10 changes: 5 additions & 5 deletions src/accountBlock/transaction.ts → src/accountBlock/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getCreateContractData, getCallContractData } from './utils';
import { Hex, Address, TokenId, BigInt, Base64, Int32, Uint8, Uint32, Uint256, Bytes32, ProviderType } from './type';


class TransactionClass {
class AccountClass {
readonly address: Address
private provider: ProviderType
private privateKey: Hex
Expand All @@ -26,12 +26,12 @@ class TransactionClass {
this.address = address;
}

setProvider(provider: ProviderType): TransactionClass {
setProvider(provider: ProviderType): AccountClass {
this.provider = provider;
return this;
}

setPrivateKey(privateKey: Hex): TransactionClass {
setPrivateKey(privateKey: Hex): AccountClass {
const err = checkParams({ privateKey }, ['privateKey'], [{
name: 'privateKey',
func: isHexString
Expand Down Expand Up @@ -839,5 +839,5 @@ class TransactionClass {
}
}

export const Transaction = TransactionClass;
export default TransactionClass;
export const Account = AccountClass;
export default AccountClass;
10 changes: 5 additions & 5 deletions src/accountBlock/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { checkParams, isObject } from '~@vite/vitejs-utils';

import _AccountBlock from './accountBlock';
import _Transaction from './transaction';
import _Account from './account';
import { ReceiveAccountBlockTask as _ReceiveAccountBlockTask } from './receiveAccountBlockTask';
import * as _utils from './utils';

export const AccountBlock = _AccountBlock;
export const Transaction = _Transaction;
export const Account = _Account;
export const ReceiveAccountBlockTask = _ReceiveAccountBlockTask;
export const utils = _utils;

Expand All @@ -22,10 +22,10 @@ export function createAccountBlock(methodName: string, params: any) {
throw err;
}

const tx = new _Transaction(params.address);
if (!tx[methodName]) {
const a = new _Account(params.address);
if (!a[methodName]) {
throw new Error(`Don\'t support transaction type ${ methodName }`);
}

return tx[methodName](params);
return a[methodName](params);
}
12 changes: 6 additions & 6 deletions src/accountBlock/receiveAccountBlockTask.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isValidAddress } from '~@vite/vitejs-wallet/address';
import { checkParams, isHexString } from '~@vite/vitejs-utils';

import Transaction from './transaction';
import Account from './account';

import { Address, Hex, ProviderType, AccountBlockBlock } from './type';

Expand All @@ -11,7 +11,7 @@ export class ReceiveAccountBlockTask {
private provider: ProviderType
private sign: Function | undefined | null
private privateKey: Hex | undefined | null
private _transaction: Transaction
private _account: Account
private _timer: any
private successCB: Function
private errorCB: Function
Expand Down Expand Up @@ -42,11 +42,11 @@ export class ReceiveAccountBlockTask {
this.sign = sign;
this.privateKey = privateKey;

this._transaction = new Transaction(address);
this._transaction.setProvider(provider);
this._account = new Account(address);
this._account.setProvider(provider);

if (privateKey) {
this._transaction.setPrivateKey(privateKey);
this._account.setPrivateKey(privateKey);
}

this._timer = null;
Expand Down Expand Up @@ -171,7 +171,7 @@ export class ReceiveAccountBlockTask {
}

private async receiveAccountBlockByPrevious({ sendBlockHash, previousAccountBlock }) {
const accountBlock = this._transaction.receive({ sendBlockHash });
const accountBlock = this._account.receive({ sendBlockHash });

if (this.privateKey) {
if (!previousAccountBlock) {
Expand Down
20 changes: 0 additions & 20 deletions src/accountBlock/tsconfig.json

This file was deleted.

20 changes: 0 additions & 20 deletions src/communication/tsconfig.json

This file was deleted.

20 changes: 0 additions & 20 deletions src/constant/tsconfig.json

This file was deleted.

20 changes: 0 additions & 20 deletions src/error/tsconfig.json

This file was deleted.

2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as _error from './error/index';
import * as _keystore from './keystore/index';
import * as _utils from './utils/index';
import * as _constant from './constant/index';
import * as _account from './accountBlock/account';
import * as _accountBlock from './accountBlock/index';
import _viteAPI from './viteAPI/index';
import _wallet from './wallet/index';
Expand All @@ -19,6 +20,7 @@ export const constant = _constant;

// Change a lot
export const accountBlock = _accountBlock;
export const account = _account;

// Add
export const ViteAPI = _viteAPI;
Expand Down
20 changes: 0 additions & 20 deletions src/keystore/tsconfig.json

This file was deleted.

20 changes: 0 additions & 20 deletions src/utils/tsconfig.json

This file was deleted.

20 changes: 0 additions & 20 deletions src/viteAPI/tsconfig.json

This file was deleted.

20 changes: 0 additions & 20 deletions src/vitejs/tsconfig.json

This file was deleted.

20 changes: 0 additions & 20 deletions src/wallet/tsconfig.json

This file was deleted.

0 comments on commit 08361a5

Please sign in to comment.