From 3f67974c89e092424fb5bcbd77fc0e2e4bfff696 Mon Sep 17 00:00:00 2001 From: Alex Risch Date: Thu, 1 Feb 2024 17:15:54 -0700 Subject: [PATCH] fix: Kick off build Include keyMaterial Include lowercase address handling --- .github/workflows/release.yml | 6 ++++++ example/src/tests.ts | 33 +++++++++++++++++++++++++++++++++ package.json | 3 ++- src/lib/Contacts.ts | 17 +++++++++++++---- 4 files changed, 54 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 67c15d315..cfc3cb8de 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,12 @@ on: branches: - main - beta + workflow_dispatch: + inputs: + branch: + description: 'Branch name' + required: true + default: 'main' jobs: release: name: Release diff --git a/example/src/tests.ts b/example/src/tests.ts index f173151f3..1dff64244 100644 --- a/example/src/tests.ts +++ b/example/src/tests.ts @@ -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 }) diff --git a/package.json b/package.json index 50138505e..75c275b07 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,8 @@ { "name": "beta", "prerelease": true - } + }, + "+([0-9])?(.{+([0-9]),x}).x" ] }, "publishConfig": { diff --git a/src/lib/Contacts.ts b/src/lib/Contacts.ts index 3ea970f9f..9488fa115 100644 --- a/src/lib/Contacts.ts +++ b/src/lib/Contacts.ts @@ -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 @@ -10,19 +11,27 @@ export default class Contacts { } async isAllowed(address: string): Promise { - return await XMTPModule.isAllowed(this.client.address, address) + return await XMTPModule.isAllowed(this.client.address, getAddress(address)) } async isDenied(address: string): Promise { - return await XMTPModule.isDenied(this.client.address, address) + return await XMTPModule.isDenied(this.client.address, getAddress(address)) } async deny(addresses: string[]): Promise { - 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 { - 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 {