Skip to content

Commit

Permalink
fix: Kick off build
Browse files Browse the repository at this point in the history
Include keyMaterial
Include lowercase address handling
  • Loading branch information
Alex Risch authored and Alex Risch committed Feb 7, 2024
1 parent 9ed6472 commit 3f67974
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ on:
branches:
- main
- beta
workflow_dispatch:
inputs:
branch:
description: 'Branch name'
required: true
default: 'main'
jobs:
release:
name: Release
Expand Down
33 changes: 33 additions & 0 deletions example/src/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -890,5 +890,38 @@ test('correctly handles lowercase addresses', async () => {
if (!aliceConversation) {
throw new Error('aliceConversation should exist')
}

await bob.contacts.deny([aliceConversation.peerAddress.toLocaleLowerCase()])
await delayToPropogate()
const deniedState = await bob.contacts.isDenied(aliceConversation.peerAddress)
const allowedState = await bob.contacts.isAllowed(
aliceConversation.peerAddress
)
if (!deniedState) {
throw new Error(`contacts denied by bo should be denied not ${deniedState}`)
}

if (allowedState) {
throw new Error(
`contacts denied by bo should be denied not ${allowedState}`
)
}
const deniedLowercaseState = await bob.contacts.isDenied(
aliceConversation.peerAddress.toLocaleLowerCase()
)
const allowedLowercaseState = await bob.contacts.isAllowed(
aliceConversation.peerAddress.toLocaleLowerCase()
)
if (!deniedLowercaseState) {
throw new Error(
`contacts denied by bo should be denied not ${deniedLowercaseState}`
)
}

if (allowedLowercaseState) {
throw new Error(
`contacts denied by bo should be denied not ${allowedLowercaseState}`
)
}
return true
})
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
{
"name": "beta",
"prerelease": true
}
},
"+([0-9])?(.{+([0-9]),x}).x"
]
},
"publishConfig": {
Expand Down
17 changes: 13 additions & 4 deletions src/lib/Contacts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Client } from './Client'
import { ConsentListEntry } from './ConsentListEntry'
import * as XMTPModule from '../index'
import { getAddress } from '../utils/address'

export default class Contacts {
client: Client<any>
Expand All @@ -10,19 +11,27 @@ export default class Contacts {
}

async isAllowed(address: string): Promise<boolean> {
return await XMTPModule.isAllowed(this.client.address, address)
return await XMTPModule.isAllowed(this.client.address, getAddress(address))
}

async isDenied(address: string): Promise<boolean> {
return await XMTPModule.isDenied(this.client.address, address)
return await XMTPModule.isDenied(this.client.address, getAddress(address))
}

async deny(addresses: string[]): Promise<void> {
return await XMTPModule.denyContacts(this.client.address, addresses)
const checkSummedAddresses = addresses.map((address) => getAddress(address))
return await XMTPModule.denyContacts(
this.client.address,
checkSummedAddresses
)
}

async allow(addresses: string[]): Promise<void> {
return await XMTPModule.allowContacts(this.client.address, addresses)
const checkSummedAddresses = addresses.map((address) => getAddress(address))
return await XMTPModule.allowContacts(
this.client.address,
checkSummedAddresses
)
}

async refreshConsentList(): Promise<ConsentListEntry[]> {
Expand Down

0 comments on commit 3f67974

Please sign in to comment.