Skip to content

Commit

Permalink
feat(State Channels): Remove endpoint param (#391)
Browse files Browse the repository at this point in the history
* feat(State Channels): Remove endpoint param

BREAKING CHANGE: Endpoint param is removed and no longer defaults to "/channel". This means that
"/channel" (or other path) must be appendend to url para

* Fix channel test
  • Loading branch information
mpowaga authored and nduchak committed May 14, 2019
1 parent 83f5279 commit 8d9ea7e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions es/channel/internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ const rpcCallbacks = new WeakMap()
const pingTimeoutId = new WeakMap()
const pongTimeoutId = new WeakMap()

function channelURL (url, params, endpoint = 'channel') {
function channelURL (url, params) {
const paramString = R.join('&', R.values(R.mapObjIndexed((value, key) =>
`${pascalToSnake(key)}=${encodeURIComponent(value)}`, params)))

return `${url}/${endpoint}?${paramString}`
return `${url}?${paramString}`
}

function emit (channel, ...args) {
Expand Down Expand Up @@ -198,10 +198,10 @@ function WebSocket (url, callbacks) {
}

async function initialize (channel, channelOptions) {
const optionsKeys = ['sign', 'endpoint', 'url']
const optionsKeys = ['sign', 'url']
const params = R.pickBy(key => !optionsKeys.includes(key), channelOptions)
const { endpoint, url } = channelOptions
const wsUrl = channelURL(url, { ...params, protocol: 'json-rpc' }, endpoint)
const { url } = channelOptions
const wsUrl = channelURL(url, { ...params, protocol: 'json-rpc' })

options.set(channel, channelOptions)
fsm.set(channel, { handler: awaitingConnection })
Expand Down
2 changes: 1 addition & 1 deletion test/integration/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { unpackTx, buildTx } from '../../es/tx/builder'
import { decode } from '../../es/tx/builder/helpers'
import Channel from '../../es/channel'

const wsUrl = process.env.WS_URL || 'ws://node:3014'
const wsUrl = process.env.WS_URL || 'ws://node:3014/channel'

plan('10000000000000000')

Expand Down

0 comments on commit 8d9ea7e

Please sign in to comment.