From 93141e82af23b7e2e0b9506123c0644d0f435792 Mon Sep 17 00:00:00 2001 From: fabri Date: Wed, 17 Jan 2024 10:54:33 -0300 Subject: [PATCH 1/5] transaction --- docs/build/messages/transaction.mdx | 199 ++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 docs/build/messages/transaction.mdx diff --git a/docs/build/messages/transaction.mdx b/docs/build/messages/transaction.mdx new file mode 100644 index 000000000..44eb0ff24 --- /dev/null +++ b/docs/build/messages/transaction.mdx @@ -0,0 +1,199 @@ +--- +sidebar_label: Transaction Reference +sidebar_position: 9 +description: Learn how to implement a transaction reference content type +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; + +# Transaction reference content type + +![Status](https://img.shields.io/badge/Content_type_status-Standards--track-yellow) ![Status](https://img.shields.io/badge/Reference_implementation_status-Beta-yellow) + +This package provides an XMTP content type to support on-chain transaction references. It is a reference to an on-chain transaction sent as a message. This content type facilitates sharing transaction hashes or IDs, thereby providing a direct link to on-chain activities. Transaction references serve to display transaction details, facilitating the sharing of on-chain activities, such as token transfers, between users. + +:::tip Open for feedback + +You're welcome to provide feedback by commenting on the [Proposal for transaction reference content type](https://github.com/orgs/xmtp/discussions/37) XIP idea. + +::: + +## Configure the content type + + + + +In the JavaScript SDK, you need to import this package first. + +```bash +npm i @xmtp/content-type-transaction-reference +``` + +After importing the package, you can register the codec. + +```jsx +import { + ContentTypeTransactionReference, + TransactionReferenceCodec, +} from "@xmtp/content-type-transaction-reference"; +// Create the XMTP client +const xmtp = await Client.create(signer, { env: "dev" }); +xmtp.registerCodec(new TransactionReferenceCodec()); +``` + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +## Send a transaction reference + +With XMTP, a transaction reference is represented as an object with the following keys: + + + + +With XMTP, a transaction reference is represented as an object with the following keys: + +```tsx +const transactionReference: TransactionReference = { + /** + * Optional namespace for the networkId + */ + namespace: "eip155"; + /** + * The networkId for the transaction, in decimal or hexidecimal format + */ + networkId: 1; + /** + * The transaction hash + */ + reference: "0x123...abc"; + /** + * Optional metadata object + */ + metadata: { + transactionType: "transfer", + currency: "USDC", + amount: 100000, // In integer format, this represents 1 USDC (100000/10^6) + decimals: 6, // Specifies that the currency uses 6 decimal places + fromAddress: "0x456...def", + toAddress: "0x789...ghi" + }; +}; +``` + +Once you have a transaction reference, you can send it as part of your conversation: + +```jsx +await conversation.messages.send(transactionReference, { + contentType: ContentTypeTransactionReference, +}); +``` + + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +## Receive a transaction reference + +To receive and process a transaction reference: + + + + +```tsx +// Assume `loadLastMessage` is a thing you have +const message: DecodedMessage = await loadLastMessage(); + +if (!message.contentType.sameAs(ContentTypeTransactionReference)) { + // Handle non-transaction reference message + return; +} + +const transactionRef: TransactionReference = message.content; +// Process the transaction reference here +``` + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +## Display the transaction reference + +Displaying a transaction reference typically involves rendering details such as the transaction hash, network ID, and any relevant metadata. The exact UI representation can vary based on your application's design, you might want to fetch on-chain data before showing them to the user. + +_To handle unsupported content types, refer to the [fallback](/docs/build/messages/#handle-an-unsupported-content-type-error) section._ From ecf70578d721d2cb3dadb58666d53f51ce485520 Mon Sep 17 00:00:00 2001 From: fabri Date: Wed, 17 Jan 2024 10:55:47 -0300 Subject: [PATCH 2/5] transaction --- docs/build/messages/transaction.mdx | 199 ---------------------------- 1 file changed, 199 deletions(-) delete mode 100644 docs/build/messages/transaction.mdx diff --git a/docs/build/messages/transaction.mdx b/docs/build/messages/transaction.mdx deleted file mode 100644 index 44eb0ff24..000000000 --- a/docs/build/messages/transaction.mdx +++ /dev/null @@ -1,199 +0,0 @@ ---- -sidebar_label: Transaction Reference -sidebar_position: 9 -description: Learn how to implement a transaction reference content type ---- - -import Tabs from "@theme/Tabs"; -import TabItem from "@theme/TabItem"; - -# Transaction reference content type - -![Status](https://img.shields.io/badge/Content_type_status-Standards--track-yellow) ![Status](https://img.shields.io/badge/Reference_implementation_status-Beta-yellow) - -This package provides an XMTP content type to support on-chain transaction references. It is a reference to an on-chain transaction sent as a message. This content type facilitates sharing transaction hashes or IDs, thereby providing a direct link to on-chain activities. Transaction references serve to display transaction details, facilitating the sharing of on-chain activities, such as token transfers, between users. - -:::tip Open for feedback - -You're welcome to provide feedback by commenting on the [Proposal for transaction reference content type](https://github.com/orgs/xmtp/discussions/37) XIP idea. - -::: - -## Configure the content type - - - - -In the JavaScript SDK, you need to import this package first. - -```bash -npm i @xmtp/content-type-transaction-reference -``` - -After importing the package, you can register the codec. - -```jsx -import { - ContentTypeTransactionReference, - TransactionReferenceCodec, -} from "@xmtp/content-type-transaction-reference"; -// Create the XMTP client -const xmtp = await Client.create(signer, { env: "dev" }); -xmtp.registerCodec(new TransactionReferenceCodec()); -``` - - - - -Code sample coming soon - - - - -Code sample coming soon - - - - -Code sample coming soon - - - - -Code sample coming soon - - - - -Code sample coming soon - - - - -## Send a transaction reference - -With XMTP, a transaction reference is represented as an object with the following keys: - - - - -With XMTP, a transaction reference is represented as an object with the following keys: - -```tsx -const transactionReference: TransactionReference = { - /** - * Optional namespace for the networkId - */ - namespace: "eip155"; - /** - * The networkId for the transaction, in decimal or hexidecimal format - */ - networkId: 1; - /** - * The transaction hash - */ - reference: "0x123...abc"; - /** - * Optional metadata object - */ - metadata: { - transactionType: "transfer", - currency: "USDC", - amount: 100000, // In integer format, this represents 1 USDC (100000/10^6) - decimals: 6, // Specifies that the currency uses 6 decimal places - fromAddress: "0x456...def", - toAddress: "0x789...ghi" - }; -}; -``` - -Once you have a transaction reference, you can send it as part of your conversation: - -```jsx -await conversation.messages.send(transactionReference, { - contentType: ContentTypeTransactionReference, -}); -``` - - - - - -Code sample coming soon - - - - -Code sample coming soon - - - - -Code sample coming soon - - - - -Code sample coming soon - - - - -Code sample coming soon - - - - -## Receive a transaction reference - -To receive and process a transaction reference: - - - - -```tsx -// Assume `loadLastMessage` is a thing you have -const message: DecodedMessage = await loadLastMessage(); - -if (!message.contentType.sameAs(ContentTypeTransactionReference)) { - // Handle non-transaction reference message - return; -} - -const transactionRef: TransactionReference = message.content; -// Process the transaction reference here -``` - - - - -Code sample coming soon - - - - -Code sample coming soon - - - - -Code sample coming soon - - - - -Code sample coming soon - - - - -Code sample coming soon - - - - -## Display the transaction reference - -Displaying a transaction reference typically involves rendering details such as the transaction hash, network ID, and any relevant metadata. The exact UI representation can vary based on your application's design, you might want to fetch on-chain data before showing them to the user. - -_To handle unsupported content types, refer to the [fallback](/docs/build/messages/#handle-an-unsupported-content-type-error) section._ From 78fbdcad93ac73053466187a6bf0ecd8f9d2530a Mon Sep 17 00:00:00 2001 From: fabri Date: Wed, 17 Jan 2024 10:57:22 -0300 Subject: [PATCH 3/5] transaction --- docs/build/messages/transaction.mdx | 199 ++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 docs/build/messages/transaction.mdx diff --git a/docs/build/messages/transaction.mdx b/docs/build/messages/transaction.mdx new file mode 100644 index 000000000..44eb0ff24 --- /dev/null +++ b/docs/build/messages/transaction.mdx @@ -0,0 +1,199 @@ +--- +sidebar_label: Transaction Reference +sidebar_position: 9 +description: Learn how to implement a transaction reference content type +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; + +# Transaction reference content type + +![Status](https://img.shields.io/badge/Content_type_status-Standards--track-yellow) ![Status](https://img.shields.io/badge/Reference_implementation_status-Beta-yellow) + +This package provides an XMTP content type to support on-chain transaction references. It is a reference to an on-chain transaction sent as a message. This content type facilitates sharing transaction hashes or IDs, thereby providing a direct link to on-chain activities. Transaction references serve to display transaction details, facilitating the sharing of on-chain activities, such as token transfers, between users. + +:::tip Open for feedback + +You're welcome to provide feedback by commenting on the [Proposal for transaction reference content type](https://github.com/orgs/xmtp/discussions/37) XIP idea. + +::: + +## Configure the content type + + + + +In the JavaScript SDK, you need to import this package first. + +```bash +npm i @xmtp/content-type-transaction-reference +``` + +After importing the package, you can register the codec. + +```jsx +import { + ContentTypeTransactionReference, + TransactionReferenceCodec, +} from "@xmtp/content-type-transaction-reference"; +// Create the XMTP client +const xmtp = await Client.create(signer, { env: "dev" }); +xmtp.registerCodec(new TransactionReferenceCodec()); +``` + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +## Send a transaction reference + +With XMTP, a transaction reference is represented as an object with the following keys: + + + + +With XMTP, a transaction reference is represented as an object with the following keys: + +```tsx +const transactionReference: TransactionReference = { + /** + * Optional namespace for the networkId + */ + namespace: "eip155"; + /** + * The networkId for the transaction, in decimal or hexidecimal format + */ + networkId: 1; + /** + * The transaction hash + */ + reference: "0x123...abc"; + /** + * Optional metadata object + */ + metadata: { + transactionType: "transfer", + currency: "USDC", + amount: 100000, // In integer format, this represents 1 USDC (100000/10^6) + decimals: 6, // Specifies that the currency uses 6 decimal places + fromAddress: "0x456...def", + toAddress: "0x789...ghi" + }; +}; +``` + +Once you have a transaction reference, you can send it as part of your conversation: + +```jsx +await conversation.messages.send(transactionReference, { + contentType: ContentTypeTransactionReference, +}); +``` + + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +## Receive a transaction reference + +To receive and process a transaction reference: + + + + +```tsx +// Assume `loadLastMessage` is a thing you have +const message: DecodedMessage = await loadLastMessage(); + +if (!message.contentType.sameAs(ContentTypeTransactionReference)) { + // Handle non-transaction reference message + return; +} + +const transactionRef: TransactionReference = message.content; +// Process the transaction reference here +``` + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +Code sample coming soon + + + + +## Display the transaction reference + +Displaying a transaction reference typically involves rendering details such as the transaction hash, network ID, and any relevant metadata. The exact UI representation can vary based on your application's design, you might want to fetch on-chain data before showing them to the user. + +_To handle unsupported content types, refer to the [fallback](/docs/build/messages/#handle-an-unsupported-content-type-error) section._ From 52624b8b6669b0a6ba6eeffba5390d665de1ee8d Mon Sep 17 00:00:00 2001 From: fabri Date: Wed, 17 Jan 2024 11:07:32 -0300 Subject: [PATCH 4/5] deploy --- docs/build/messages/transaction.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/build/messages/transaction.mdx b/docs/build/messages/transaction.mdx index 44eb0ff24..f39bae122 100644 --- a/docs/build/messages/transaction.mdx +++ b/docs/build/messages/transaction.mdx @@ -192,8 +192,8 @@ Code sample coming soon +_To handle unsupported content types, refer to the [fallback](/docs/build/messages/#handle-an-unsupported-content-type-error) section._ + ## Display the transaction reference Displaying a transaction reference typically involves rendering details such as the transaction hash, network ID, and any relevant metadata. The exact UI representation can vary based on your application's design, you might want to fetch on-chain data before showing them to the user. - -_To handle unsupported content types, refer to the [fallback](/docs/build/messages/#handle-an-unsupported-content-type-error) section._ From aaa1da3aa4d22fa0040ec65c390779bd92ceb746 Mon Sep 17 00:00:00 2001 From: Jennifer Hasegawa <5481259+jhaaaa@users.noreply.github.com> Date: Tue, 30 Jan 2024 15:07:20 -0800 Subject: [PATCH 5/5] jha: just a few style and copy edits --- docs/build/messages/remote-attachment.mdx | 2 +- docs/build/messages/transaction.mdx | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/build/messages/remote-attachment.mdx b/docs/build/messages/remote-attachment.mdx index a718643d5..d494251d9 100644 --- a/docs/build/messages/remote-attachment.mdx +++ b/docs/build/messages/remote-attachment.mdx @@ -1,5 +1,5 @@ --- -sidebar_label: Remote Attachment +sidebar_label: Remote attachment sidebar_position: 6 description: Learn how to use the attachment and remote attachment content types to support attachments in your app built with XMTP --- diff --git a/docs/build/messages/transaction.mdx b/docs/build/messages/transaction.mdx index f39bae122..f8bc408e4 100644 --- a/docs/build/messages/transaction.mdx +++ b/docs/build/messages/transaction.mdx @@ -1,21 +1,21 @@ --- -sidebar_label: Transaction Reference +sidebar_label: Transaction reference sidebar_position: 9 -description: Learn how to implement a transaction reference content type +description: Learn how to implement an on-chain transaction reference content type --- import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; -# Transaction reference content type +# Support on-chain transaction references in your app built with XMTP -![Status](https://img.shields.io/badge/Content_type_status-Standards--track-yellow) ![Status](https://img.shields.io/badge/Reference_implementation_status-Beta-yellow) +![Status](https://img.shields.io/badge/Content_type_status-Standards--track-yellow) ![Status](https://img.shields.io/badge/Reference_implementation_status-Alpha-orange) This package provides an XMTP content type to support on-chain transaction references. It is a reference to an on-chain transaction sent as a message. This content type facilitates sharing transaction hashes or IDs, thereby providing a direct link to on-chain activities. Transaction references serve to display transaction details, facilitating the sharing of on-chain activities, such as token transfers, between users. :::tip Open for feedback -You're welcome to provide feedback by commenting on the [Proposal for transaction reference content type](https://github.com/orgs/xmtp/discussions/37) XIP idea. +You're welcome to provide feedback by commenting on [XIP-21: On-chain transaction reference content type](https://community.xmtp.org/t/xip-21-on-chain-transaction-reference-content-type/532). ::: @@ -196,4 +196,4 @@ _To handle unsupported content types, refer to the [fallback](/docs/build/messag ## Display the transaction reference -Displaying a transaction reference typically involves rendering details such as the transaction hash, network ID, and any relevant metadata. The exact UI representation can vary based on your application's design, you might want to fetch on-chain data before showing them to the user. +Displaying a transaction reference typically involves rendering details such as the transaction hash, network ID, and any relevant metadata. Because the exact UI representation can vary based on your app's design, you might want to fetch on-chain data before showing it to the user.