Skip to content

Commit d5c26ac

Browse files
jhaaaabennycode
andauthored
Add Prettier, Pt. Deux (#382)
* add prettier * rm extra from prettierignore * Add Prettier as dev dependency * Fix markdownlint * Ignore Prettier here * fix prettier issue * prettier and link fixes --------- Co-authored-by: Benny Neugebauer <mail@bennycode.com>
1 parent e381fb0 commit d5c26ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1163
-832
lines changed

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Contains CSS-in-JS template literals that break vocs when formatted
2+
docs/pages/chat-apps/intro/get-started.mdx
3+
# Contains "/xmtp/mls/1/w-$installationId/proto" which Prettier breaks in multiple lines
4+
docs/pages/chat-apps/push-notifs/push-notifs.mdx

.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"singleQuote": true,
3+
"semi": true,
4+
"tabWidth": 2,
5+
"trailingComma": "es5",
6+
"printWidth": 80,
7+
"proseWrap": "preserve"
8+
}

docs/pages/agents/content-types/attachments.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ After importing the package, you can register the codec.
3030
import {
3131
AttachmentCodec,
3232
RemoteAttachmentCodec,
33-
} from "@xmtp/content-type-remote-attachment";
33+
} from '@xmtp/content-type-remote-attachment';
3434
// Create the XMTP client
3535
const xmtp = await Client.create(signer, {
36-
env: "dev",
36+
env: 'dev',
3737
codecs: [new AttachmentCodec(), new RemoteAttachmentCodec()],
3838
});
3939
```
@@ -50,7 +50,7 @@ const data = await new Promise((resolve, reject) => {
5050
if (reader.result instanceof ArrayBuffer) {
5151
resolve(reader.result);
5252
} else {
53-
reject(new Error("Not an ArrayBuffer"));
53+
reject(new Error('Not an ArrayBuffer'));
5454
}
5555
};
5656
reader.readAsArrayBuffer(image);
@@ -88,7 +88,7 @@ const remoteAttachment = {
8888
salt: encryptedEncoded.salt,
8989
nonce: encryptedEncoded.nonce,
9090
secret: encryptedEncoded.secret,
91-
scheme: "https://",
91+
scheme: 'https://',
9292
filename: attachment.filename,
9393
contentLength: attachment.data.byteLength,
9494
};
@@ -107,7 +107,7 @@ await conversation.send(remoteAttachment, {
107107
Now that you can send a remote attachment, you need a way to receive it. For example:
108108

109109
```tsx [Node]
110-
import { ContentTypeRemoteAttachment } from "@xmtp/content-type-remote-attachment";
110+
import { ContentTypeRemoteAttachment } from '@xmtp/content-type-remote-attachment';
111111

112112
if (message.contentType.sameAs(RemoteAttachmentContentType)) {
113113
const attachment = await RemoteAttachmentCodec.load(message.content, client);
@@ -131,7 +131,7 @@ const objectURL = URL.createObjectURL(
131131
})
132132
);
133133

134-
const img = document.createElement("img");
134+
const img = document.createElement('img');
135135
img.src = objectURL;
136136
img.title = attachment.filename;
137137
```

docs/pages/agents/content-types/content-types.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Here is the current standard content type:
2323
An agent built with XMTP uses the `TextCodec` (plain text) standard content type by default. This means that if your agent is sending plain text messages only, you don't need to perform any additional steps related to content types.
2424

2525
```jsx [Node]
26-
await conversation.send("gm");
26+
await conversation.send('gm');
2727
```
2828

2929
## Standards-track content types

docs/pages/agents/content-types/reactions.mdx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@ pnpm add @xmtp/content-type-reaction
3131
After importing the package, you can register the codec.
3232

3333
```jsx [Node]
34-
import {
35-
ReactionCodec,
36-
} from "@xmtp/content-type-reaction";
34+
import { ReactionCodec } from '@xmtp/content-type-reaction';
3735
// Create the XMTP client
3836
const xmtp = await Client.create(signer, {
39-
env: "dev",
37+
env: 'dev',
4038
codecs: [new ReactionCodec()],
4139
});
4240
```
@@ -56,8 +54,8 @@ With XMTP, reactions are represented as objects with the following keys:
5654
```tsx [Node]
5755
const reaction = {
5856
reference: someMessageID,
59-
action: "added",
60-
content: "smile",
57+
action: 'added',
58+
content: 'smile',
6159
};
6260

6361
await conversation.send(reaction, {

docs/pages/agents/content-types/replies.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ pnpm add @xmtp/content-type-reply
3131
After importing the package, you can register the codec.
3232

3333
```js [Node]
34-
import { ReplyCodec } from "@xmtp/content-type-reply";
34+
import { ReplyCodec } from '@xmtp/content-type-reply';
3535
// Create the XMTP client
3636
const xmtp = await Client.create(signer, {
37-
env: "dev",
37+
env: 'dev',
3838
codecs: [new ReplyCodec()],
3939
});
4040
```
@@ -48,14 +48,14 @@ Once you've created a reply, you can send it. Replies are represented as objects
4848
- `content`: String representation of the reply
4949

5050
```ts [Node]
51-
import { ContentTypeText } from "@xmtp/content-type-text";
52-
import { ContentTypeReply } from "@xmtp/content-type-reply";
53-
import type { Reply } from "@xmtp/content-type-reply";
51+
import { ContentTypeText } from '@xmtp/content-type-text';
52+
import { ContentTypeReply } from '@xmtp/content-type-reply';
53+
import type { Reply } from '@xmtp/content-type-reply';
5454

5555
const reply: Reply = {
5656
reference: someMessageID,
5757
contentType: ContentTypeText,
58-
content: "I concur",
58+
content: 'I concur',
5959
};
6060

6161
await conversation.send(reply, {

docs/pages/agents/content-types/transaction-refs.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ After importing the package, you can register the codec.
3636
import {
3737
ContentTypeTransactionReference,
3838
TransactionReferenceCodec,
39-
} from "@xmtp/content-type-transaction-reference";
39+
} from '@xmtp/content-type-transaction-reference';
4040
// Create the XMTP client
4141
const xmtp = await Client.create(signer, {
42-
env: "dev",
42+
env: 'dev',
4343
codecs: [new TransactionReferenceCodec()],
4444
});
4545
```

docs/pages/agents/content-types/transactions.mdx

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,10 @@ pnpm i @xmtp/content-type-wallet-send-calls
3333
After importing the package, you can register the codec.
3434

3535
```js [Node]
36-
import {
37-
WalletSendCallsCodec,
38-
} from "@xmtp/content-type-wallet-send-calls";
36+
import { WalletSendCallsCodec } from '@xmtp/content-type-wallet-send-calls';
3937
// Create the XMTP client
4038
const xmtp = await Client.create(signer, {
41-
env: "dev",
39+
env: 'dev',
4240
codecs: [new WalletSendCallsCodec()],
4341
});
4442
```
@@ -49,33 +47,33 @@ With XMTP, a transaction request is represented using `wallet_sendCalls` with ad
4947

5048
```ts [Node]
5149
const walletSendCalls: WalletSendCallsParams = {
52-
version: "1.0",
53-
from: "0x123...abc",
54-
chainId: "0x2105",
50+
version: '1.0',
51+
from: '0x123...abc',
52+
chainId: '0x2105',
5553
calls: [
5654
{
57-
to: "0x456...def",
58-
value: "0x5AF3107A4000",
55+
to: '0x456...def',
56+
value: '0x5AF3107A4000',
5957
metadata: {
60-
description: "Send 0.0001 ETH on base to 0x456...def",
61-
transactionType: "transfer",
62-
currency: "ETH",
58+
description: 'Send 0.0001 ETH on base to 0x456...def',
59+
transactionType: 'transfer',
60+
currency: 'ETH',
6361
amount: 100000000000000,
6462
decimals: 18,
65-
toAddress: "0x456...def",
63+
toAddress: '0x456...def',
6664
},
6765
},
6866
{
69-
to: "0x789...cba",
70-
data: "0xdead...beef",
67+
to: '0x789...cba',
68+
data: '0xdead...beef',
7169
metadata: {
72-
description: "Lend 10 USDC on base with Morpho @ 8.5% APY",
73-
transactionType: "lend",
74-
currency: "USDC",
70+
description: 'Lend 10 USDC on base with Morpho @ 8.5% APY',
71+
transactionType: 'lend',
72+
currency: 'USDC',
7573
amount: 10000000,
7674
decimals: 6,
77-
platform: "morpho",
78-
apy: "8.5",
75+
platform: 'morpho',
76+
apy: '8.5',
7977
},
8078
},
8179
],

docs/pages/agents/core-messaging/agent-installations.mdx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ Your agent can have **up to 10 active installations** before you need to revoke
1515
For example, if you deploy your agent across these network environments, you will have 3 inboxes, each with 1 installation:
1616

1717
- Local development: `local` network
18-
- Railway: `dev` network
18+
- Railway: `dev` network
1919
- Production server: `production` network
2020

2121
<div>
22-
<img src="https://raw.githubusercontent.com/xmtp/docs-xmtp-org/refs/heads/main/docs/pages/img/agent-install-sep.png" width="500px" alt="Diagram showing agent deployments across different network environments (local, dev, production) creating separate inboxes with one installation each" />
22+
<img
23+
src="https://raw.githubusercontent.com/xmtp/docs-xmtp-org/refs/heads/main/docs/pages/img/agent-install-sep.png"
24+
width="500px"
25+
alt="Diagram showing agent deployments across different network environments (local, dev, production) creating separate inboxes with one installation each"
26+
/>
2327
</div>
2428

2529
If you deploy your agent to this same network environment, you have 1 inbox with 3 installations:
@@ -29,7 +33,11 @@ If you deploy your agent to this same network environment, you have 1 inbox with
2933
- Production server: `production` network
3034

3135
<div>
32-
<img src="https://raw.githubusercontent.com/xmtp/docs-xmtp-org/refs/heads/main/docs/pages/img/agent-install.png" width="500px" alt="Diagram showing agent deployments to the same production network environment creating one inbox with three installations" />
36+
<img
37+
src="https://raw.githubusercontent.com/xmtp/docs-xmtp-org/refs/heads/main/docs/pages/img/agent-install.png"
38+
width="500px"
39+
alt="Diagram showing agent deployments to the same production network environment creating one inbox with three installations"
40+
/>
3341
</div>
3442

3543
Here are some best practices for agent installation management:

docs/pages/agents/core-messaging/create-a-client.mdx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@ If you want to inspect the database visually, you can use [DB Browser for SQLite
6767
To call `Client.create()`, you must pass in a required `signer` and can also pass in any of the optional parameters covered in [Configure an XMTP client](#configure-an-xmtp-client).
6868

6969
```tsx [Node]
70-
import { Client, type Signer } from "@xmtp/node-sdk";
71-
import { getRandomValues } from "node:crypto";
70+
import { Client, type Signer } from '@xmtp/node-sdk';
71+
import { getRandomValues } from 'node:crypto';
7272

7373
// create a signer
74-
const signer: Signer = { /* ... */ };
74+
const signer: Signer = {
75+
/* ... */
76+
};
7577

7678
/**
7779
* The database encryption key is optional but strongly recommended for
@@ -89,7 +91,7 @@ const client = await Client.create(
8991
dbEncryptionKey,
9092
// Optional: Use a function to dynamically set the database path based on inbox ID
9193
// dbPath: (inboxId) => `./agent-databases/xmtp-${inboxId}.db3`,
92-
},
94+
}
9395
);
9496
```
9597

@@ -98,26 +100,26 @@ const client = await Client.create(
98100
You can configure an XMTP client with these options passed to `Client.create`:
99101

100102
```tsx [Node]
101-
import type { ContentCodec } from "@xmtp/content-type-primitives";
102-
import type { LogLevel } from "@xmtp/node-bindings";
103+
import type { ContentCodec } from '@xmtp/content-type-primitives';
104+
import type { LogLevel } from '@xmtp/node-bindings';
103105

104106
type ClientOptions = {
105107
/**
106108
* Specify which XMTP environment to connect to. (default: `dev`)
107109
*/
108-
env?: "local" | "dev" | "production";
110+
env?: 'local' | 'dev' | 'production';
109111
/**
110112
* Add a client app version identifier that's included with API requests.
111113
* Production apps are strongly encouraged to set this value.
112114
*
113115
* You can use the following format: `appVersion: 'AGENT_NAME/AGENT_VERSION'`.
114116
* For example, `appVersion: 'alix/2.x'`
115117
*
116-
* If you have an agent and an app, it's best to distinguish them from each other by
118+
* If you have an agent and an app, it's best to distinguish them from each other by
117119
* adding `-agent` and `-app` to the names. For example:
118120
* - Agent: `appVersion: 'alix-agent/2.x'`
119121
* - App: `appVersion: 'alix-app/3.x'`
120-
*
122+
*
121123
* Setting this value provides telemetry that shows which agents are using the
122124
* XMTP client SDK. This information can help XMTP core developers provide you with agent
123125
* support, especially around communicating important SDK updates, including

0 commit comments

Comments
 (0)