Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

main => beta #428

Closed
wants to merge 8 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions example/src/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { sha256 } from '@noble/hashes/sha256'
import { FramesClient } from '@xmtp/frames-client'
import { content, invitation, signature as signatureProto } from '@xmtp/proto'
import { createHmac } from 'crypto'
import { ethers } from 'ethers'
import ReactNativeBlobUtil from 'react-native-blob-util'
import Config from 'react-native-config'
import { TextEncoder, TextDecoder } from 'text-encoding'
Expand Down Expand Up @@ -1678,13 +1677,31 @@ test('can handle complex streaming setup with messages from self', async () => {
return true
})

class ViemSigner {
account: PrivateKeyAccount

constructor(account: PrivateKeyAccount) {
this.account = account
}

async getAddress() {
return this.account.address
}

async signMessage(message: string) {
return this.account.signMessage({ message })
}
}

test('can send and receive consent proofs', async () => {
const alixWallet = await ethers.Wallet.createRandom()
const boWallet = await ethers.Wallet.createRandom()
const bo = await Client.create(boWallet, { env: 'local' })
await delayToPropogate()
const alix = await Client.create(alixWallet, { env: 'local' })
await delayToPropogate()
const alixPrivateKey = generatePrivateKey()
const alixAccount = privateKeyToAccount(alixPrivateKey)
const boPrivateKey = generatePrivateKey()
const boAccount = privateKeyToAccount(boPrivateKey)
const alixSigner = new ViemSigner(alixAccount)
const boSigner = new ViemSigner(boAccount)
const alix = await Client.create(alixSigner, { env: 'local' })
const bo = await Client.create(boSigner, { env: 'local' })

const timestamp = Date.now()
const consentMessage =
Expand All @@ -1694,7 +1711,7 @@ test('can send and receive consent proofs', async () => {
`From Address: ${bo.address}\n` +
'\n' +
'For more info: https://xmtp.org/signatures/'
const sig = await alixWallet.signMessage(consentMessage)
const sig = await alixSigner.signMessage(consentMessage)
const consentProof = invitation.ConsentProofPayload.fromPartial({
payloadVersion:
invitation.ConsentProofPayloadVersion.CONSENT_PROOF_PAYLOAD_VERSION_1,
Expand Down
Loading