Skip to content

Commit

Permalink
feat: new partials
Browse files Browse the repository at this point in the history
  • Loading branch information
anegg0 committed Apr 19, 2024
1 parent cb5c933 commit 4ae0328
Show file tree
Hide file tree
Showing 12 changed files with 215 additions and 77 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Approve ERC-20 token

Initiating the deployment of a token bridge for **[Custom Fee Token](/launch-orbit-chain/concepts/custom-gas-token-sdk.md)** on orbit chains begins with ensuring the `TokenBridgeCreator` contract is granted sufficient approvals of the native token. To facilitate this process, the Orbit SDK provides two APIs:

1. **`createTokenBridgeEnoughCustomFeeTokenAllowance`**: This method verifies that the deployer's address has enough allowance to pay for the fees associated with the token bridge deployment.
2. **`createTokenBridgePrepareCustomFeeTokenApprovalTransactionRequest`**: This function assists in generating the raw transaction required to approve the native token for the `TokenBridgeCreator` contract.

The following example demonstrates how to leverage these APIs effectively to check for and, if necessary, grant approval to the `TokenBridgeCreator` contract:

```js
const allowanceParams = {
nativeToken,
owner: rollupOwner.address,
publicClient: parentChainPublicClient,
};
if (!(await createTokenBridgeEnoughCustomFeeTokenAllowance(allowanceParams))) {
const approvalTxRequest = await createTokenBridgePrepareCustomFeeTokenApprovalTransactionRequest(
allowanceParams,
);
}
```

In this scenario, `allowanceParams` includes:
- The native token's details: `nativeToken`.
- The Rollup owner's address: `rollupOwner.address`.
- The parent chain's publicClient: `parentChainPublicClient`.

First, `createTokenBridgeEnoughCustomFeeTokenAllowance` checks if the deployer has been granted enough allowance.

If the allowance is insufficient, `createTokenBridgePrepareCustomFeeTokenApprovalTransactionRequest` is called to create the necessary approval transaction.

Please note that after generating the raw transaction, the deployer must still sign and broadcast it to the network to finalize the approval process.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
n and deployment helpers

The Orbit SDK provides three APIs, `prepareChainConfig`, `createRollupPrepareConfig`, and `createRollupPrepareTransactionRequest` to facilitate the configuration and deployment of Rollup parameters for an Orbit chain. These APIs simplify the process of setting up and deploying the core contracts necessary for an Orbit chain.

| API | Benefit | Description |
| :-------------------------------------- | :----------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------- |
| `prepareChainConfig` | Simplifies the creation of the `chainConfig` parameter object | Takes `config` parameters as arguments and returns a `chainConfig` `JSON` string. |
| `createRollupPrepareConfig` | Simplifies the creation of the `Config` parameter object | Takes a `Config` struct as argument and fills in undefined params with default values. |
| `createRollupPrepareTransactionRequest` | Simplifies the creation of the `RollupDeploymentParams` parameter object | Takes `RollupDeploymentParams` as argument, applies defaults where necessary, and return a complete `RollupDeploymentParams` |
| `createTokenBridgeEnoughCustomFeeTokenAllowance` | Verifies that the deployer's address has enough allowance to pay for the fees associated with the token bridge deployment | |
| `createTokenBridgePrepareCustomFeeTokenApprovalTransactionRequest` | Generates the raw transaction required to approve the native token for the `TokenBridgeCreator` contract. | |
| `createTokenBridgePrepareTransactionRequest` | Generates token bridge deployment transaction request.| |
| `waitForRetryables` | Sends token bridge deployment transaction.| |



This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Get the orbit chain information after deployment

Once you've successfully deployed your Orbit chain, the next step is to retrieve detailed information about the deployment. The Orbit SDK provides a convenient way to do this through the `createRollupPrepareTransactionReceipt` API.

After sending the signed transaction and receiving the transaction receipt, you can use the `createRollupPrepareTransactionReceipt` API to parse this receipt and extract the relevant data. This process will provide comprehensive details about the deployed chain, such as contract addresses, configuration settings, and other information.

Here's an example of how to use the Orbit SDK to get data from a deployed Orbit chain:

```js
import { createRollupPrepareTransactionReceipt } from '@arbitrum/orbit-sdk';

const data = createRollupPrepareTransactionReceipt(txReceipt);
```

In this example, `txReceipt` refers to the transaction receipt you received after deploying the chain. By passing this receipt to the `createRollupPrepareTransactionReceipt` function, you can easily access a wealth of information about your Orbit chain. This feature of the Orbit SDK simplifies the post-deployment process, allowing you to quickly and efficiently gather all necessary details about your chain for further use or reference.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## Prepare `ChainConfig` object parameter

For an easier config preparation, the Orbit SDK provides the `prepareChainConfig` API, which takes config parameters as arguments and returns a `chainConfig` `JSON` string. Any parameters not provided will default to standard values, which are detailed in the [Orbit SDK repository](https://github.com/OffchainLabs/arbitrum-orbit-sdk/blob/1f251f76a55bc1081f50938b0aa9f7965660ebf7/src/prepareChainConfig.ts#L3-L31).


The `chainConfig` parameter within the `Config` structure is an essential element for tailoring your Orbit chain according to specific needs. This parameter is particularly significant when setting up an AnyTrust Orbit chain, as it includes configurations that distinguish it from a Rollup chain. The key parameter that differentiates an AnyTrust chain in this context is the `DataAvailabilityCommittee`.



Here are the parameters you can use with `prepareChainConfig`:

| Parameter | Description |
| :-------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------- |
| `chainId` | Your Orbit chain's unique identifier. It differentiates your chain from others in the ecosystem. |
| `DataAvailabilityCommittee` | Set to `false`, this boolean makes your chain as a Rollup, set to `true` configures it as an AnyTrust chain. |
| `InitialChainOwner` | Identifies who owns and controls the chain. |
| `MaxCodeSize ` | Sets the maximum size for contract bytecodes on the Orbit chain. e.g. Ethereum mainnet has a limit of 24,576 Bytes. |
| `MaxInitCodeSize` | Similar to `MaxCodeSize`, defines the maximum size for your Orbit chain's **initialization** code. e.g. Ethereum mainnet limit is 49,152 Bytes. |


For an AnyTrust chain, you need to set the `DataAvailabilityCommittee` to **true**. This setting is crucial as it indicates the chain's reliance on a committee for data availability, which is a hallmark of the AnyTrust model.

Here’s an example of how to configure the `chainConfig` for an AnyTrust chain using the Orbit SDK:

```js
import { prepareChainConfig } from '@arbitrum/orbit-sdk';

const chainConfig = prepareChainConfig({
chainId: Some_Chain_ID,
arbitrum: { InitialChainOwner: deployer_address, DataAvailabilityCommittee: true },
});
```

In this example, you set up the chain configuration with a specific `chainId`, the `InitialChainOwner` as the deployer's address, and importantly, you configure the `DataAvailabilityCommittee` as `true`. This configuration ensures that your Orbit chain is set up as an AnyTrust chain, utilizing the unique features and operational model of the AnyTrust system within the Arbitrum Orbit framework.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## Prepare `chainConfig` object parameter

For an easier config preparation, the Orbit SDK provides the `prepareChainConfig` API, which takes config parameters as arguments and returns a `chainConfig` `JSON` string. Any parameters not provided will default to standard values, which are detailed in the [Orbit SDK repository](https://github.com/OffchainLabs/arbitrum-orbit-sdk/blob/1f251f76a55bc1081f50938b0aa9f7965660ebf7/src/prepareChainConfig.ts#L3-L31).

Here are the parameters you can use with `prepareChainConfig`:

| Parameter | Description |
| :-------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------- |
| `chainId` | Your Orbit chain's unique identifier. It differentiates your chain from others in the ecosystem. |
| `DataAvailabilityCommittee` | Set to `false`, this boolean makes your chain as a Rollup, set to `true` configures it as an AnyTrust chain. |
| `InitialChainOwner` | Identifies who owns and controls the chain. |
| `MaxCodeSize ` | Sets the maximum size for contract bytecodes on the Orbit chain. e.g. Ethereum mainnet has a limit of 24,576 Bytes. |
| `MaxInitCodeSize` | Similar to `MaxCodeSize`, defines the maximum size for your Orbit chain's **initialization** code. e.g. Ethereum mainnet limit is 49,152 Bytes. |

Below is an example of how to use `prepareChainConfig` to set up a Rollup chain with a specific `chainId`, an `InitialChainOwner` (named as `deployer_address`):

```js
import { prepareChainConfig } from '@arbitrum/orbit-sdk';

const chainConfig = prepareChainConfig({
chainId: Some_Chain_ID,
arbitrum: { InitialChainOwner: deployer_address, DataAvailabilityCommittee: false },
});
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#### createRollupPrepareConfig API:

This API is designed to take parameters defined in the Config struct and fill in the rest with default values. It outputs a complete Config struct that is ready for use.

For example, to create a Config struct with a specific chain ID (`chainId`), an owner address (`deployer_address`), and a `chainConfig` as described in the [previous section](#chain-config-parameter), you would use the Orbit SDK as follows:

```js
import { createRollupPrepareConfig } from '@arbitrum/orbit-sdk';

const config = createRollupPrepareConfig({
chainId: BigInt(chainId),
owner: deployer.address,
chainConfig,
});
```
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The Arbitrum Orbit SDK lets you programmatically create and manage your own Orbi
- Configuration and deployment of your Orbit chain's core contracts
- Initialization of your chain and management of its configuration post-deployment

## 1. Select a chain type
## Select a chain type

There are three types of Orbit chains. Review the following table to determine which type best fits your needs:

Expand Down
Loading

0 comments on commit 4ae0328

Please sign in to comment.