This repository was archived by the owner on Dec 21, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +28
-3
lines changed Expand file tree Collapse file tree 4 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -5,12 +5,13 @@ import { BigNumber } from '@ethersproject/bignumber'
55import { getVersionString } from './utils'
66import { ConnectionInfo } from '@ethersproject/web'
77import { EthereumAddress , Todo } from './types'
8+ import { BytesLike } from '@ethersproject/bytes'
89
910export type EthereumConfig = ExternalProvider | JsonRpcFetchFunc
1011
1112export type StrictStreamrClientOptions = {
1213 auth : {
13- privateKey ?: EthereumAddress
14+ privateKey ?: string | BytesLike
1415 ethereum ?: EthereumConfig
1516 apiKey ?: string
1617 username ?: string
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import EventEmitter from 'eventemitter3'
22import { Wallet } from '@ethersproject/wallet'
33import { ExternalProvider , JsonRpcFetchFunc , Web3Provider } from '@ethersproject/providers'
44import { StreamrClient } from './StreamrClient'
5- import { EthereumAddress } from './types '
5+ import { BytesLike } from '@ethersproject/bytes '
66
77enum State {
88 LOGGING_OUT = 'logging out' ,
@@ -12,7 +12,7 @@ enum State {
1212}
1313
1414export interface SessionOptions {
15- privateKey ?: EthereumAddress
15+ privateKey ?: string | BytesLike
1616 ethereum ?: ExternalProvider | JsonRpcFetchFunc
1717 apiKey ?: string
1818 username ?: string
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export * from './types'
2020export { BigNumber } from '@ethersproject/bignumber'
2121export { ConnectionInfo } from '@ethersproject/web'
2222export { Contract } from '@ethersproject/contracts'
23+ export { BytesLike , Bytes } from '@ethersproject/bytes'
2324export { TransactionReceipt , TransactionResponse } from '@ethersproject/providers'
2425
2526export default StreamrClient
Original file line number Diff line number Diff line change 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+ } )
You can’t perform that action at this time.
0 commit comments