Skip to content

Commit

Permalink
Merge pull request #14 from smartcontractkit/automatic-apiref
Browse files Browse the repository at this point in the history
Automated API Reference Generation and Index File Creation
  • Loading branch information
aelmanaa authored Jul 29, 2024
2 parents fd9ea91 + dad5228 commit d97d6e9
Show file tree
Hide file tree
Showing 38 changed files with 4,783 additions and 175 deletions.
13 changes: 13 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "avoid",
"proseWrap": "always"
}

4 changes: 4 additions & 0 deletions api_reference/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# API Reference

- [javascript](javascript/index.mdx)
- [solidity](solidity/index.mdx)
122 changes: 122 additions & 0 deletions api_reference/javascript/CCIPLocalSimulatorFork.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
## Functions

<dl>
<dt>
<a href="#requestLinkFromTheFaucet">
requestLinkFromTheFaucet(linkAddress, to, amount)
</a>{' '}
⇒ <code>Promise.&lt;string&gt;</code>
</dt>
<dd>
<p>Requests LINK tokens from the faucet and returns the transaction hash</p>
</dd>
<dt>
<a href="#getEvm2EvmMessage">getEvm2EvmMessage(receipt)</a> ⇒{' '}
<code>
<a href="#Evm2EvmMessage">Evm2EvmMessage</a>
</code>{' '}
| <code>null</code>
</dt>
<dd>
<p>
Parses a transaction receipt to extract the sent message Scans through
transaction logs to find a <code>CCIPSendRequested</code> event and then
decodes it to an object
</p>
</dd>
<dt>
<a href="#routeMessage">routeMessage(routerAddress, evm2EvmMessage)</a> ⇒{' '}
<code>Promise.&lt;void&gt;</code>
</dt>
<dd>
<p>
Routes the sent message from the source network on the destination
(current) network
</p>
</dd>
</dl>

## Typedefs

<dl>
<dt>
<a href="#Evm2EvmMessage">Evm2EvmMessage</a> : <code>Object</code>
</dt>
<dd></dd>
</dl>

<a name="requestLinkFromTheFaucet"></a>

## requestLinkFromTheFaucet(linkAddress, to, amount) ⇒ <code>Promise.&lt;string&gt;</code>

Requests LINK tokens from the faucet and returns the transaction hash

**Kind**: global function
**Returns**: <code>Promise.&lt;string&gt;</code> - Promise resolving to the
transaction hash of the fund transfer

| Param | Type | Description |
| ----------- | ------------------- | ------------------------------------------------------- |
| linkAddress | <code>string</code> | The address of the LINK contract on the current network |
| to | <code>string</code> | The address to send LINK to |
| amount | <code>bigint</code> | The amount of LINK to request |

<a name="getEvm2EvmMessage"></a>

## getEvm2EvmMessage(receipt) ⇒ [<code>Evm2EvmMessage</code>](#Evm2EvmMessage) \| <code>null</code>

Parses a transaction receipt to extract the sent message Scans through
transaction logs to find a `CCIPSendRequested` event and then decodes it to an
object

**Kind**: global function
**Returns**: [<code>Evm2EvmMessage</code>](#Evm2EvmMessage) \|
<code>null</code> - Returns either the sent message or null if provided receipt
does not contain `CCIPSendRequested` log

| Param | Type | Description |
| ------- | ------------------- | ------------------------------------------------ |
| receipt | <code>object</code> | The transaction receipt from the `ccipSend` call |

<a name="routeMessage"></a>

## routeMessage(routerAddress, evm2EvmMessage) ⇒ <code>Promise.&lt;void&gt;</code>

Routes the sent message from the source network on the destination (current)
network

**Kind**: global function
**Returns**: <code>Promise.&lt;void&gt;</code> - Either resolves with no value
if the message is successfully routed, or reverts
**Throws**:

- <code>Error</code> Fails if no off-ramp matches the message's source chain
selector or if calling `router.getOffRamps()`

| Param | Type | Description |
| -------------- | ---------------------------------------------- | --------------------------------- |
| routerAddress | <code>string</code> | Address of the destination Router |
| evm2EvmMessage | [<code>Evm2EvmMessage</code>](#Evm2EvmMessage) | Sent cross-chain message |

<a name="Evm2EvmMessage"></a>

## Evm2EvmMessage : <code>Object</code>

**Kind**: global typedef
**Properties**

| Name | Type |
| ------------------- | ----------------------------------------------------------- |
| sourceChainSelector | <code>bigint</code> |
| sender | <code>string</code> |
| receiver | <code>string</code> |
| sequenceNumber | <code>bigint</code> |
| gasLimit | <code>bigint</code> |
| strict | <code>boolean</code> |
| nonce | <code>bigint</code> |
| feeToken | <code>string</code> |
| feeTokenAmount | <code>bigint</code> |
| data | <code>string</code> |
| tokenAmounts | <code>Array.&lt;\{token: string, amount: bigint}&gt;</code> |
| sourceTokenData | <code>Array.&lt;string&gt;</code> |
| messageId | <code>string</code> |
3 changes: 3 additions & 0 deletions api_reference/javascript/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Javascript API Reference

- [CCIPLocalSimulatorFork](CCIPLocalSimulatorFork.mdx)
44 changes: 44 additions & 0 deletions api_reference/solidity/ccip/BurnMintERC677Helper.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Solidity API

## BurnMintERC677Helper

This contract extends the functionality of the BurnMintERC677 token contract to
include a `drip` function that mints one full token to a specified address.

_Inherits from the BurnMintERC677 contract and sets the token name, symbol,
decimals, and initial supply in the constructor._

### constructor

```solidity
constructor(string name, string symbol) public
```

Constructor to initialize the BurnMintERC677Helper contract with a name and
symbol.

_Calls the parent constructor of BurnMintERC677 with fixed decimals (18) and
initial supply (0)._

#### Parameters

| Name | Type | Description |
| ------ | ------ | -------------------------- |
| name | string | - The name of the token. |
| symbol | string | - The symbol of the token. |

### drip

```solidity
function drip(address to) external
```

Mints one full token (1e18) to the specified address.

_Calls the internal `_mint` function from the BurnMintERC677 contract._

#### Parameters

| Name | Type | Description |
| ---- | ------- | ------------------------------------------ |
| to | address | - The address to receive the minted token. |
172 changes: 172 additions & 0 deletions api_reference/solidity/ccip/CCIPLocalSimulator.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# Solidity API

## CCIPLocalSimulator

This contract simulates local CCIP (Cross-Chain Interoperability Protocol)
operations for testing and development purposes.

_This contract includes methods to manage supported tokens and configurations
for local simulations._

### CHAIN_SELECTOR

```solidity
uint64 CHAIN_SELECTOR
```

The unique CCIP Chain Selector constant

### i_wrappedNative

```solidity
contract WETH9 i_wrappedNative
```

The wrapped native token instance

### i_linkToken

```solidity
contract LinkToken i_linkToken
```

The LINK token instance

### i_ccipBnM

```solidity
contract BurnMintERC677Helper i_ccipBnM
```

The BurnMintERC677Helper instance for CCIP-BnM token

### i_ccipLnM

```solidity
contract BurnMintERC677Helper i_ccipLnM
```

The BurnMintERC677Helper instance for CCIP-LnM token

### i_mockRouter

```solidity
contract MockCCIPRouter i_mockRouter
```

The mock CCIP router instance

### s_supportedTokens

```solidity
address[] s_supportedTokens
```

The list of supported token addresses

### constructor

```solidity
constructor() public
```

Constructor to initialize the contract and pre-deployed token instances

### supportNewToken

```solidity
function supportNewToken(address tokenAddress) external
```

Allows user to support any new token, besides CCIP BnM and CCIP LnM, for
cross-chain transfers.

#### Parameters

| Name | Type | Description |
| ------------ | ------- | ------------------------------------------------------------------ |
| tokenAddress | address | - The address of the token to add to the list of supported tokens. |

### isChainSupported

```solidity
function isChainSupported(uint64 chainSelector) public pure returns (bool supported)
```

Checks whether the provided `chainSelector` is supported by the simulator.

#### Parameters

| Name | Type | Description |
| ------------- | ------ | --------------------------------- |
| chainSelector | uint64 | - The unique CCIP Chain Selector. |

#### Return Values

| Name | Type | Description |
| --------- | ---- | ---------------------------------------------------------------- |
| supported | bool | - Returns true if `chainSelector` is supported by the simulator. |

### getSupportedTokens

```solidity
function getSupportedTokens(uint64 chainSelector) external view returns (address[] tokens)
```

Gets a list of token addresses that are supported for cross-chain transfers by
the simulator.

#### Parameters

| Name | Type | Description |
| ------------- | ------ | --------------------------------- |
| chainSelector | uint64 | - The unique CCIP Chain Selector. |

#### Return Values

| Name | Type | Description |
| ------ | --------- | -------------------------------------------------------------------------------------------------- |
| tokens | address[] | - Returns a list of token addresses that are supported for cross-chain transfers by the simulator. |

### requestLinkFromFaucet

```solidity
function requestLinkFromFaucet(address to, uint256 amount) external returns (bool success)
```

Requests LINK tokens from the faucet. The provided amount of tokens are
transferred to provided destination address.

#### Parameters

| Name | Type | Description |
| ------ | ------- | -------------------------------------------------- |
| to | address | - The address to which LINK tokens are to be sent. |
| amount | uint256 | - The amount of LINK tokens to send. |

#### Return Values

| Name | Type | Description |
| ------- | ---- | ----------------------------------------------------------------------------- |
| success | bool | - Returns `true` if the transfer of tokens was successful, otherwise `false`. |

### configuration

```solidity
function configuration() public view returns (uint64 chainSelector_, contract IRouterClient sourceRouter_, contract IRouterClient destinationRouter_, contract WETH9 wrappedNative_, contract LinkToken linkToken_, contract BurnMintERC677Helper ccipBnM_, contract BurnMintERC677Helper ccipLnM_)
```

Returns configuration details for pre-deployed contracts and services needed for
local CCIP simulations.

#### Return Values

| Name | Type | Description |
| ------------------- | ----------------------------- | ----------------------------------------------------------- |
| chainSelector\_ | uint64 | - The unique CCIP Chain Selector. |
| sourceRouter\_ | contract IRouterClient | - The source chain Router contract. |
| destinationRouter\_ | contract IRouterClient | - The destination chain Router contract. |
| wrappedNative\_ | contract WETH9 | - The wrapped native token which can be used for CCIP fees. |
| linkToken\_ | contract LinkToken | - The LINK token. |
| ccipBnM\_ | contract BurnMintERC677Helper | - The ccipBnM token. |
| ccipLnM\_ | contract BurnMintERC677Helper | - The ccipLnM token. |
Loading

0 comments on commit d97d6e9

Please sign in to comment.