Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.

Commit 585edf1

Browse files
authored
privateKey type: EthereumAddress -> string|BytesLike (#215)
1 parent 32224af commit 585edf1

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

src/Config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import { BigNumber } from '@ethersproject/bignumber'
55
import { getVersionString } from './utils'
66
import { ConnectionInfo } from '@ethersproject/web'
77
import { EthereumAddress, Todo } from './types'
8+
import { BytesLike } from '@ethersproject/bytes'
89

910
export type EthereumConfig = ExternalProvider|JsonRpcFetchFunc
1011

1112
export type StrictStreamrClientOptions = {
1213
auth: {
13-
privateKey?: EthereumAddress
14+
privateKey?: string|BytesLike
1415
ethereum?: EthereumConfig
1516
apiKey?: string
1617
username?: string

src/Session.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import EventEmitter from 'eventemitter3'
22
import { Wallet } from '@ethersproject/wallet'
33
import { ExternalProvider, JsonRpcFetchFunc, Web3Provider } from '@ethersproject/providers'
44
import { StreamrClient } from './StreamrClient'
5-
import { EthereumAddress } from './types'
5+
import { BytesLike } from '@ethersproject/bytes'
66

77
enum State {
88
LOGGING_OUT = 'logging out',
@@ -12,7 +12,7 @@ enum State {
1212
}
1313

1414
export interface SessionOptions {
15-
privateKey?: EthereumAddress
15+
privateKey?: string|BytesLike
1616
ethereum?: ExternalProvider|JsonRpcFetchFunc
1717
apiKey?: string
1818
username?: string

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export * from './types'
2020
export { BigNumber } from '@ethersproject/bignumber'
2121
export { ConnectionInfo } from '@ethersproject/web'
2222
export { Contract } from '@ethersproject/contracts'
23+
export { BytesLike, Bytes } from '@ethersproject/bytes'
2324
export { TransactionReceipt, TransactionResponse } from '@ethersproject/providers'
2425

2526
export default StreamrClient

test/unit/Config.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { arrayify, BytesLike } from '@ethersproject/bytes'
2+
import { StreamrClient } from '../../src/StreamrClient'
3+
4+
const createClient = (privateKey: string|BytesLike) => {
5+
return new StreamrClient({
6+
auth: {
7+
privateKey
8+
}
9+
})
10+
}
11+
12+
describe('Config', () => {
13+
describe('private key', () => {
14+
it('string', () => {
15+
const client = createClient('0x0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF')
16+
expect(client.getAddress()).toBe('0xFCAd0B19bB29D4674531d6f115237E16AfCE377c')
17+
})
18+
it('byteslike', () => {
19+
const client = createClient(arrayify('0x0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF'))
20+
expect(client.getAddress()).toBe('0xFCAd0B19bB29D4674531d6f115237E16AfCE377c')
21+
})
22+
})
23+
})

0 commit comments

Comments
 (0)