Skip to content

Commit

Permalink
explain import (#1823)
Browse files Browse the repository at this point in the history
  • Loading branch information
aelmanaa authored Mar 18, 2024
1 parent 2753a4c commit d72e584
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 93 deletions.
26 changes: 3 additions & 23 deletions src/content/ccip/api-reference/ccip-receiver.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,9 @@ date: Last Modified
title: "CCIPReceiver API Reference"
---

import { Aside, CopyText } from "@components"
import { Tabs } from "@components/Tabs"

<Aside type="note" title="Add Chainlink CCIP to your project">
If you need to integrate Chainlink CCIP into your project, install the [@chainlink/contracts-ccip NPM package](https://www.npmjs.com/package/@chainlink/contracts-ccip).

<Tabs sharedStore="package" client:visible>
<Fragment slot="tab.1">npm</Fragment>
<Fragment slot="tab.2">yarn</Fragment>
<Fragment slot="panel.1">
If you use [NPM](https://www.npmjs.com/):
```shell
npm install @chainlink/contracts-ccip --save
```
</Fragment>
<Fragment slot="panel.2">
If you use [Yarn](https://yarnpkg.com/):
```shell
yarn add @chainlink/contracts-ccip
```
</Fragment>
</Tabs>
</Aside>
import CcipCommon from "@features/ccip/CcipCommon.astro"

<CcipCommon callout="importCCIPPackage" />

CCIP receiver contracts inherit from _CCIPReceiver_.

Expand Down
26 changes: 3 additions & 23 deletions src/content/ccip/api-reference/client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,9 @@ date: Last Modified
title: "Client Library API Reference"
---

import { Aside, CopyText } from "@components"
import { Tabs } from "@components/Tabs"

<Aside type="note" title="Add Chainlink CCIP to your project">
If you need to integrate Chainlink CCIP into your project, install the [@chainlink/contracts-ccip NPM package](https://www.npmjs.com/package/@chainlink/contracts-ccip).

<Tabs sharedStore="package" client:visible>
<Fragment slot="tab.1">npm</Fragment>
<Fragment slot="tab.2">yarn</Fragment>
<Fragment slot="panel.1">
If you use [NPM](https://www.npmjs.com/):
```shell
npm install @chainlink/contracts-ccip --save
```
</Fragment>
<Fragment slot="panel.2">
If you use [Yarn](https://yarnpkg.com/):
```shell
yarn add @chainlink/contracts-ccip
```
</Fragment>
</Tabs>
</Aside>
import CcipCommon from "@features/ccip/CcipCommon.astro"

<CcipCommon callout="importCCIPPackage" />

CCIP senders and receivers use the _CCIP Client Library_ to build CCIP messages.

Expand Down
24 changes: 2 additions & 22 deletions src/content/ccip/api-reference/errors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,9 @@ date: Last Modified
title: "Errors API Reference"
---

import { Aside, CopyText } from "@components"
import { Tabs } from "@components/Tabs"
import CcipCommon from "@features/ccip/CcipCommon.astro"

<Aside type="note" title="Add Chainlink CCIP to your project">
If you need to integrate Chainlink CCIP into your project, install the [@chainlink/contracts-ccip NPM package](https://www.npmjs.com/package/@chainlink/contracts-ccip).

<Tabs sharedStore="package" client:visible>
<Fragment slot="tab.1">npm</Fragment>
<Fragment slot="tab.2">yarn</Fragment>
<Fragment slot="panel.1">
If you use [NPM](https://www.npmjs.com/):
```shell
npm install @chainlink/contracts-ccip --save
```
</Fragment>
<Fragment slot="panel.2">
If you use [Yarn](https://yarnpkg.com/):
```shell
yarn add @chainlink/contracts-ccip
```
</Fragment>
</Tabs>
</Aside>
<CcipCommon callout="importCCIPPackage" />

When invoking the `ccipSend` [function](/ccip/api-reference/i-router-client#ccipsend), it is possible to encounter various errors. These might be thrown either by the CCIP router or by one of the downstream contracts called by the CCIP router. Below is a compiled list of potential errors you might encounter. Referencing this list will enable you to capture and handle these exceptions gracefully.

Expand Down
29 changes: 5 additions & 24 deletions src/content/ccip/api-reference/i-router-client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,10 @@ date: Last Modified
title: "IRouterClient API Reference"
---

import { Aside, CopyText } from "@components"
import { Tabs } from "@components/Tabs"

<Aside type="note" title="Add Chainlink CCIP to your project">
If you need to integrate Chainlink CCIP into your project, install the [@chainlink/contracts-ccip NPM package](https://www.npmjs.com/package/@chainlink/contracts-ccip).

<Tabs sharedStore="package" client:visible>
<Fragment slot="tab.1">npm</Fragment>
<Fragment slot="tab.2">yarn</Fragment>
<Fragment slot="panel.1">
If you use [NPM](https://www.npmjs.com/):
```shell
npm install @chainlink/contracts-ccip --save
```
</Fragment>
<Fragment slot="panel.2">
If you use [Yarn](https://yarnpkg.com/):
```shell
yarn add @chainlink/contracts-ccip
```
</Fragment>
</Tabs>
</Aside>
import { Aside } from "@components"
import CcipCommon from "@features/ccip/CcipCommon.astro"

<CcipCommon callout="importCCIPPackage" />

To send messages through CCIP, users must interact with the `IRouterClient` interface.
After you import `IRouterClient.sol`, you can initialize a router client instance:
Expand Down Expand Up @@ -133,7 +114,7 @@ function ccipSend(uint64 destinationChainSelector, struct Client.EVM2AnyMessage
Request a message to be sent to the destination chain.

<Aside type="caution">
If the `msg.value` exceeds the required fee from `getFee`, the over overpayment is accepted with no refund.
If the `msg.value` exceeds the required fee from `getFee`, the overpayment is accepted with no refund.
</Aside>

#### Parameters
Expand Down
2 changes: 2 additions & 0 deletions src/content/ccip/tutorials/cross-chain-tokens.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ You will transfer _0.001 CCIP-BnM_. The CCIP fees for using CCIP will be paid in

## Explanation

<CcipCommon callout="importCCIPPackage" />

The smart contract featured in this tutorial is designed to interact with CCIP to transfer a supported token to an account on a destination chain. The contract code contains supporting comments clarifying the functions, events, and underlying logic. This section further explains initializing the contract and transferring tokens.

### Initializing of the contract
Expand Down
3 changes: 3 additions & 0 deletions src/content/ccip/tutorials/manual-execution.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ whatsnext:
---

import { CodeSample, ClickToZoom, CopyText, Aside } from "@components"
import CcipCommon from "@features/ccip/CcipCommon.astro"

<Aside type="note">
Read the CCIP [manual execution](/ccip/concepts/manual-execution) conceptual page to understand how manual execution
Expand Down Expand Up @@ -223,6 +224,8 @@ You will increase the gas limit and trigger manual execution:

## Explanation

<CcipCommon callout="importCCIPPackage" />

The smart contract used in this tutorial is configured to use CCIP for transferring and receiving tokens with data, similar to the contract in the [_Transfer Tokens with Data_](/ccip/tutorials/programmable-token-transfers) tutorial. For a detailed understanding of the contract code, refer to the [code explanation](/ccip/tutorials/programmable-token-transfers#explanation) section of that tutorial.

A key distinction in this tutorial is the intentional setup of a low gas limit of `20,000` for building the CCIP message. This specific gas limit setting is expected to fail the message delivery on the receiver contract in the destination chain:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ whatsnext:
---

import { CodeSample, ClickToZoom, CopyText, Aside } from "@components"
import CcipCommon from "@features/ccip/CcipCommon.astro"

This tutorial extends the [programmable token transfers example](/ccip/tutorials/programmable-token-transfers). It uses Chainlink CCIP to transfer tokens and arbitrary data between smart contracts on different blockchains, and focuses on defensive coding in the receiver contract. In the event of a specified error during the CCIP message reception, the contract locks the tokens. Locking the tokens allows the owner to recover and redirect them as needed. Defensive coding is crucial as it enables the recovery of locked tokens and ensures the protection of your users' assets.

Expand Down Expand Up @@ -180,6 +181,8 @@ You will transfer _0.001 CCIP-BnM_ and a text. The CCIP fees for using CCIP will

## Explanation

<CcipCommon callout="importCCIPPackage" />

The smart contract featured in this tutorial is designed to interact with CCIP to transfer and receive tokens and data. The contract code is similar to the [_Transfer Tokens with Data_](/ccip/tutorials/programmable-token-transfers) tutorial. Hence, you can refer to its [code explanation](/ccip/tutorials/programmable-token-transfers#explanation). We will only explain the main differences.

### Sending messages
Expand Down
2 changes: 2 additions & 0 deletions src/content/ccip/tutorials/programmable-token-transfers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ You will transfer _0.001 CCIP-BnM_ and a text. The CCIP fees for using CCIP will

## Explanation

<CcipCommon callout="importCCIPPackage" />

The smart contract featured in this tutorial is designed to interact with CCIP to transfer and receive tokens and data. The contract code contains supporting comments clarifying the functions, events, and underlying logic. Here we will further explain initializing the contract and sending data with tokens.

### Initializing the contract
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ whatsnext:
---

import { CodeSample, ClickToZoom, CopyText, Aside } from "@components"
import CcipCommon from "@features/ccip/CcipCommon.astro"

This tutorial will teach you how to use Chainlink CCIP to send arbitrary data between smart contracts on different blockchains and how to track the status of each sent message in the sender contract on the source chain. Tracking the status of sent messages allows your smart contracts to execute actions after the receiver acknowledges it received the message. In this example, the sender contract emits an event after it receives acknowledgment from the receiver.

Expand Down Expand Up @@ -337,6 +338,8 @@ When the _message tracker_ receives the acknowledgment message, the `ccipReceive

## Explanation

<CcipCommon callout="importCCIPPackage" />

The smart contracts featured in this tutorial are designed to interact with CCIP to send and receive messages with an acknowledgment of receipt mechanism. The contract code across both contracts contains supporting comments clarifying the functions, events, and underlying logic.

Refer to the [Send Arbitrary Data](/ccip/tutorials/send-arbitrary-data#explanation) tutorial for more explanation about [initializing the contracts](/ccip/tutorials/send-arbitrary-data#initializing-of-the-contract), [sending data, paying in LINK](/ccip/tutorials/send-arbitrary-data#sending-data-and-pay-in-link), and [receiving data](/ccip/tutorials/send-arbitrary-data#receiving-data).
Expand Down
2 changes: 2 additions & 0 deletions src/content/ccip/tutorials/send-arbitrary-data.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ You will use CCIP to send a text. The CCIP fees for using CCIP will be paid in n

## Explanation

<CcipCommon callout="importCCIPPackage" />

The smart contract featured in this tutorial is designed to interact with CCIP to send and receive messages. The contract code contains supporting comments clarifying the functions, events, and underlying logic. Here we will further explain initializing the contract and sending and receiving data.

### Initializing of the contract
Expand Down
3 changes: 3 additions & 0 deletions src/content/ccip/tutorials/usdc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ title: "Transfer USDC with Data"
---

import { Aside, ClickToZoom, CodeSample, CopyText } from "@components"
import CcipCommon from "@features/ccip/CcipCommon.astro"

USDC is a digital dollar backed 100% and is always redeemable 1:1 for US dollars. The [stablecoin](https://chain.link/education-hub/stablecoins) is issued by [Circle](https://www.circle.com/en/usdc) on multiple blockchain platforms.

Expand Down Expand Up @@ -43,6 +44,8 @@ The following describes the operational process:
In this tutorial, you will send a _string_ text and USDC tokens from a smart contract on _Avalanche Fuji_ to a smart contract on _Polygon Mumbai_. You will pay CCIP fees in LINK.
For simplicity, we will use the same contract example as the [Transfer Tokens with Data](/ccip/tutorials/programmable-token-transfers#tutorial) tutorial but for production code, we recommend to apply defensive coding (read the [Transfer Tokens With Data - Defensive Example](/ccip/tutorials/programmable-token-transfers-defensive) tutorial to learn more).

<CcipCommon callout="importCCIPPackage" />

### Before you begin

1. You should understand how to write, compile, deploy, and fund a smart contract. If you need to brush up on the basics, read this [tutorial](/quickstarts/deploy-your-first-contract), which will guide you through using the [Solidity programming language](https://soliditylang.org/), interacting with the [MetaMask wallet](https://metamask.io) and working within the [Remix Development Environment](https://remix.ethereum.org/).
Expand Down
5 changes: 4 additions & 1 deletion src/features/ccip/CcipCommon.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ const thirdPartyApps = await Astro.glob("./third-party-apps.mdx")
const ThirdPartyAppsComponent = thirdPartyApps[0].Content
const SupportedNetworksConcepts = await Astro.glob("./Supported-networks-concepts.mdx")
const SupportedNetworksConceptsComponent = SupportedNetworksConcepts[0].Content
const ImportCCIPPackage = await Astro.glob("./ImportCCIPPackage.mdx")
const ImportCCIPPackageComponent = ImportCCIPPackage[0].Content
export type Props = {
callout?: "extraArgsCallout" | "thirdPartyApps" | "supportedNetworksConcepts"
callout?: "extraArgsCallout" | "thirdPartyApps" | "supportedNetworksConcepts" | "importCCIPPackage"
}
const { callout } = Astro.props as Props
---

{callout === "extraArgsCallout" && <ExtraArgsCalloutComponent />}
{callout === "thirdPartyApps" && <ThirdPartyAppsComponent />}
{callout === "supportedNetworksConcepts" && <SupportedNetworksConceptsComponent />}
{callout === "importCCIPPackage" && <ImportCCIPPackageComponent />}
41 changes: 41 additions & 0 deletions src/features/ccip/ImportCCIPPackage.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Aside, CopyText } from "@components"
import { Tabs } from "@components/Tabs"

<Aside type="note" title="Integrate Chainlink CCIP into your project">
<Tabs sharedStore="package" client:visible>
<Fragment slot="tab.1">npm</Fragment>
<Fragment slot="tab.2">yarn</Fragment>
<Fragment slot="tab.3">foundry</Fragment>
<Fragment slot="panel.1">

If you use [NPM](https://www.npmjs.com/), install the [@chainlink/contracts-ccip NPM
package](https://www.npmjs.com/package/@chainlink/contracts-ccip) and provide the version number:

```shell
npm install @chainlink/contracts-ccip@1.4.0
```

</Fragment>
<Fragment slot="panel.2">

If you use [Yarn](https://yarnpkg.com/), install the [@chainlink/contracts-ccip NPM
package](https://www.npmjs.com/package/@chainlink/contracts-ccip) and provide the version number:

```shell
yarn add @chainlink/contracts-ccip@1.4.0
```

</Fragment>
<Fragment slot="panel.3">

If you use [Foundry](https://book.getfoundry.sh/), install a specific [CCIP GitHub
release](https://github.com/smartcontractkit/ccip/releases):

```shell
forge install smartcontractkit/ccip@v2.8.0-ccip1.4.3-release
```

</Fragment>

</Tabs>
</Aside>

0 comments on commit d72e584

Please sign in to comment.