Skip to content

Commit

Permalink
feat(network): Throw error when can not get networkId instead of usin…
Browse files Browse the repository at this point in the history
…g mainnet by default
  • Loading branch information
nduchak committed Jan 16, 2020
1 parent 199d2b3 commit f1f27f5
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion es/account/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ async function signTransaction (tx, opt = {}) {
* @return {String} NetworkId
*/
function getNetworkId () {
return this.networkId || (this.selectedNode ? this.selectedNode.networkId : false) || DEFAULT_NETWORK_ID
if (!this.networkId && !this.selectedNode.networkId) throw new Error('networkId is not provided')
return this.networkId || this.selectedNode.networkId
}

/**
Expand Down
2 changes: 1 addition & 1 deletion es/ae/aepp.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ import GeneralizeAccount from '../contract/ga'
* @return {Object} Aepp instance
*/
export const Aepp = Ae.compose(ContractAPI, Aens, Oracle, GeneralizeAccount, Rpc)
export const RpcAepp = Ae.compose(Chain, Tx, Oracle, Contract, Aens, AeppRpc)
export const RpcAepp = Ae.compose(AeppRpc, Tx, Oracle, Contract, Aens, Chain)
export default Aepp
2 changes: 1 addition & 1 deletion es/ae/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,6 @@ export const Wallet = Ae.compose(Accounts, Chain, Tx, Contract, GeneralizeAccoun
}
})

export const RpcWallet = Ae.compose(Accounts, Chain, Tx, Contract, Oracle, Aens, GeneralizeAccount, WalletRpc)
export const RpcWallet = Ae.compose(WalletRpc, Tx, Contract, Oracle, Aens, GeneralizeAccount, Chain)

export default Wallet
5 changes: 3 additions & 2 deletions es/node-pool/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @export NodePool
* @example import NodePool from '@aeternity/aepp-sdk/es/node-pool'
*/
import { DEFAULT_NETWORK_ID, getterForCurrentNode, prepareNodeObject } from './helpers'
import { getterForCurrentNode, prepareNodeObject } from './helpers'
import AsyncInit from '../utils/async-init'

/**
Expand Down Expand Up @@ -85,7 +85,8 @@ export const NodePool = AsyncInit.compose({
* nodePool.getNetworkId()
*/
getNetworkId () {
return this.networkId || this.selectedNode.networkId || DEFAULT_NETWORK_ID
if (!this.networkId && !this.selectedNode.networkId) throw new Error('networkId is not provided')
return this.networkId || this.selectedNode.networkId
},
/**
* Check if you have selected node
Expand Down
2 changes: 1 addition & 1 deletion es/utils/aepp-wallet-communication/rpc/aepp-rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const handleMessage = (instance) => async (msg) => {
* @param {Object} connection Wallet connection object
* @return {Object}
*/
export const AeppRpc = Ae.compose(Account, {
export const AeppRpc = Ae.compose({
async init ({ name, onAddressChange = voidFn, onDisconnect = voidFn, onNetworkChange = voidFn, connection }) {
const eventsHandlers = ['onDisconnect', 'onAddressChange', 'onNetworkChange']
this.connection = connection
Expand Down

0 comments on commit f1f27f5

Please sign in to comment.