Skip to content

Commit

Permalink
Merge pull request #234 from xmtp/ar/broadcast-sdk-init
Browse files Browse the repository at this point in the history
feat: broadcast sdk
  • Loading branch information
alexrisch authored May 30, 2024
2 parents 816b187 + 029dab6 commit 0e0ea66
Show file tree
Hide file tree
Showing 13 changed files with 653 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/hungry-hounds-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@xmtp/broadcast-sdk": minor
---

Added Broadcast SDK
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ This repo provides a collection of tools for running high-quality XMTP bots in N
- [Fs Persistence](./packages/fs-persistence/README.md): Provides file system-based data persistence for XMTP clients, enabling data storage and retrieval directly from the file system.
- [Redis Persistence](./packages/redis-persistence/README.md): Implements Redis-based persistence for XMTP clients, supporting efficient data storage and access in a Redis database.
- [CLI Starter](./packages/cli-starter/README.md): It includes a basic setup and examples to get started with building a command-line interface for XMTP.
- [Broadcast Client](./packages/broadcast/README.md): It includes a basic setup and examples to get started with building a command-line interface for XMTP.
21 changes: 21 additions & 0 deletions packages/broadcast/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Broadcast SDK

## Installation
```
yarn add @xmtp/broadcast-sdk
```

## Usage
```ts
import { Client } from "@xmtp/xmtp-js"
import { BroadcastClient } from "@xmtp/broadcast-sdk"
// It is highly recommended to use the GRPC client
const client = await Client.create(wallet)

const broadcastClient = new BroadcastClient({
client,
addresses: ["0x1234", "0x5678"],
cachedCanMessageAddresses: ["0x1234"],
})
broadcastClient.broadcast(['Hello!'])
```
48 changes: 48 additions & 0 deletions packages/broadcast/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "@xmtp/broadcast-sdk",
"version": "0.1.0",
"description": "Helper package for broadcasting XMTP messages to subscribers",
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"engines": {
"node": ">=18"
},
"files": [
"dist"
],
"publishConfig": {
"access": "public",
"provenance": true
},
"scripts": {
"clean": "rm -rf dist",
"build": "yarn clean && rollup -c",
"prepublishOnly": "yarn build",
"test": "vitest run ./src"
},
"author": "XMTP Labs <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/xmtp/xmtp-node-js-tools/issues"
},
"homepage": "https://github.com/xmtp/xmtp-node-js-tools#readme",
"packageManager": "[email protected]",
"devDependencies": {
"@rollup/plugin-typescript": "^11.1.6",
"@xmtp/xmtp-js": "^11.3.12",
"ethers": "^6.10.0",
"rollup": "^4.13.0",
"rollup-plugin-dts": "^6.1.0",
"typescript": "^5.4.5",
"vitest": "^1.0.1"
}
}
43 changes: 43 additions & 0 deletions packages/broadcast/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import typescript from "@rollup/plugin-typescript"
import { defineConfig } from "rollup"
import { dts } from "rollup-plugin-dts"

const external = ["@xmtp/proto", "node:crypto", "@xmtp/xmtp-js", "long"]

const plugins = [
typescript({
declaration: false,
declarationMap: false,
}),
]

export default defineConfig([
{
input: "src/index.ts",
output: {
file: "dist/index.js",
format: "es",
sourcemap: true,
},
plugins,
external,
},
{
input: "src/index.ts",
output: {
file: "dist/index.cjs",
format: "cjs",
sourcemap: true,
},
plugins,
external,
},
{
input: "src/index.ts",
output: {
file: "dist/index.d.ts",
format: "es",
},
plugins: [dts()],
},
])
Loading

0 comments on commit 0e0ea66

Please sign in to comment.