-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #234 from xmtp/ar/broadcast-sdk-init
feat: broadcast sdk
- Loading branch information
Showing
13 changed files
with
653 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@xmtp/broadcast-sdk": minor | ||
--- | ||
|
||
Added Broadcast SDK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!']) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()], | ||
}, | ||
]) |
Oops, something went wrong.