Skip to content

Commit 538e9a8

Browse files
committed
add new connection property: identifiers
1 parent 2b735ea commit 538e9a8

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/dev-connection/index.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,4 +351,24 @@ describe('dev-connection', () => {
351351
expect(el.chain.getValue()).to.be.equal(undefined)
352352
})
353353
})
354+
describe('Exposes identifiers', () => {
355+
it('identifiers is undefined by default', () => {
356+
const el = connection()
357+
expect(el.identifiers.getValue()).to.be.equal(undefined)
358+
})
359+
it('identifiers is BehaviorSubject', () => {
360+
const el = connection()
361+
let _count = 0
362+
el.identifiers.subscribe(() => {
363+
_count = _count + 1
364+
})
365+
expect(el.identifiers.getValue()).to.be.equal(undefined)
366+
367+
const ids = { email: 'my@mail.com' }
368+
el.identifiers.next(ids)
369+
370+
expect(el.identifiers.getValue()).to.be.equal(ids)
371+
expect(_count).to.be.equal(2)
372+
})
373+
})
354374
})

src/dev-connection/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const newAccount = () => new BehaviorSubject<UndefinedOr<string>>(undefined)
3030
const newChain = () => new BehaviorSubject<UndefinedOr<number>>(undefined)
3131
const newEip1193Provider = () =>
3232
new BehaviorSubject<UndefinedOr<Eip1193Provider>>(undefined)
33+
const newIdentifiers = () =>
34+
new BehaviorSubject<UndefinedOr<{ email?: string }>>(undefined)
3335

3436
const testEventEmitterable = (
3537
x: any,
@@ -49,6 +51,7 @@ export class Connection extends UllrElement {
4951
private _account!: BehaviorSubject<UndefinedOr<string>>
5052
private _chain!: BehaviorSubject<UndefinedOr<number>>
5153
private _eip1193Provider!: BehaviorSubject<UndefinedOr<Eip1193Provider>>
54+
private _identifiers!: BehaviorSubject<UndefinedOr<{ email?: string }>>
5255
private _signerSubscription!: Subscription
5356
private _providerSubscription!: Subscription
5457
private _chainChangedListener = (chainId: number | string) => {
@@ -87,6 +90,10 @@ export class Connection extends UllrElement {
8790
return this._eip1193Provider
8891
}
8992

93+
get identifiers() {
94+
return this._identifiers
95+
}
96+
9097
async setEip1193Provider(
9198
prov: Eip1193Provider,
9299
providerFactory?: typeof BrowserProvider,
@@ -116,6 +123,7 @@ export class Connection extends UllrElement {
116123
this._account = newAccount()
117124
this._chain = newChain()
118125
this._eip1193Provider = newEip1193Provider()
126+
this._identifiers = newIdentifiers()
119127

120128
this._signerSubscription = this.signer.asObservable().subscribe((x) => {
121129
if (x === undefined) {
@@ -150,5 +158,6 @@ export class Connection extends UllrElement {
150158
this.provider.complete()
151159
this.account.complete()
152160
this.chain.complete()
161+
this.identifiers.complete()
153162
}
154163
}

0 commit comments

Comments
 (0)