Skip to content

Commit

Permalink
v0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
smiled0g committed Jul 10, 2019
1 parent 816ec4f commit 39ec435
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "libra-web",
"version": "0.1.0",
"version": "0.1.2",
"description": "A library for connecting with libra from browser and Node.js",
"main": "build/libra-web/index.js",
"types": "build/libra-web/index.d.ts",
Expand Down
13 changes: 6 additions & 7 deletions packages/libra-web-account/Wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@ import { KeyFactory, Seed } from './KeyFactory'
import { Mnemonic } from './Mnemonic'

export class LibraWallet {
private readonly mnemonic: string[]
private keyFactory: KeyFactory

static create(): LibraWallet {
public static create(): LibraWallet {
return new LibraWallet(new Mnemonic().toString())
}
private readonly mnemonic: string[]
private keyFactory: KeyFactory

constructor(_mnemonic: string) {
if (!_mnemonic) {
constructor(mnemonic: string) {
if (!mnemonic) {
throw new Error(
'Mnemonic is required for initialing LibraWallet. Use LibraWallet.create() for creating a new one.',
)
}

this.mnemonic = _mnemonic.trim().split(' ')
this.mnemonic = mnemonic.trim().split(' ')
const seed = Seed.fromMnemonic(this.mnemonic, 'LIBRA')
this.keyFactory = new KeyFactory(seed)
}
Expand Down
26 changes: 14 additions & 12 deletions packages/libra-web-core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ import axios from 'axios'
import BigNumber from 'bignumber.js'
import { SHA3 } from 'sha3'

import { Account, AccountAddress, AccountState, AccountStates } from '../libra-web-account'
import { CursorBuffer } from '../libra-web-core-utils/common/CursorBuffer'
import PathValues from '../libra-web-core-utils/constants/PathValues'
import {
AccountStateBlob,
AccountStateWithProof,
AdmissionControlClient,
SubmitTransactionRequest,
SubmitTransactionResponse,
GetAccountStateRequest,
GetAccountStateResponse,
RawTransaction,
RequestItem,
ResponseItem,
UpdateToLatestLedgerRequest,
RawTransaction,
SignedTransaction,
SubmitTransactionRequest,
SubmitTransactionResponse,
UpdateToLatestLedgerRequest,
} from '../libra-web-net'
import { CursorBuffer } from '../libra-web-core-utils/common/CursorBuffer'
import PathValues from '../libra-web-core-utils/constants/PathValues'
import { LibraTransaction, LibraTransactionFactory } from '../libra-web-transaction'
import { Account, AccountAddress, AccountState, AccountStates } from '../libra-web-account'

export enum LibraNetwork {
Testnet = 'testnet',
Expand All @@ -41,16 +41,16 @@ const DefaultFaucetServerHost = 'faucet.testnet.libra.org'
const DefaultProxyServer: LibralLibConfig =
process.env.NODE_ENV === 'test'
? {
protocol: 'http',
host: 'localhost',
port: '8080',
network: LibraNetwork.Local,
port: '8080',
protocol: 'http',
}
: {
protocol: 'http',
host: 'ac.testnet.trylibra.org',
port: '80',
network: LibraNetwork.Testnet,
port: '80',
protocol: 'http',
}

export class LibraClient {
Expand Down Expand Up @@ -199,7 +199,9 @@ export class LibraClient {
receipientAddress: AccountAddress | string,
numCoins: number | string | BigNumber,
): Promise<SubmitTransactionResponse> {
if (typeof receipientAddress === 'string') receipientAddress = AccountAddress.fromHex(receipientAddress)
if (typeof receipientAddress === 'string') {
receipientAddress = AccountAddress.fromHex(receipientAddress)
}
const response = await this.execute(
LibraTransactionFactory.createTransfer(
sender.getAddress().toBytes(),
Expand Down
2 changes: 1 addition & 1 deletion packages/libra-web-transaction/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export class LibraTransactionFactory {
receipientAddress: Uint8Array,
numCoins: BigNumber,
gasConstraint: LibraGasConstraint = {
maxGasAmount: new BigNumber('10000'),
gasUnitPrice: new BigNumber('0'),
maxGasAmount: new BigNumber('10000'),
},
expirationTime: string | BigNumber = '1661898073',
sequenceNumber: string | BigNumber = '-1',
Expand Down

0 comments on commit 39ec435

Please sign in to comment.