Skip to content

Commit b24cbe9

Browse files
committed
feat: generated docstrings with gpt-4o
1 parent 5f19e43 commit b24cbe9

File tree

69 files changed

+1351
-273
lines changed

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

+1351
-273
lines changed

src/arbAggregatorPrepareTransactionRequest.ts

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ export type ArbAggregatorEncodeFunctionDataParameters<
1717
TFunctionName extends ArbAggregatorPrepareTransactionRequestFunctionName,
1818
> = EncodeFunctionDataParameters<ArbAggregatorAbi, TFunctionName>;
1919

20+
/**
21+
* Encodes function data for the ArbAggregator contract function specified by the given function name.
22+
*
23+
* @template TFunctionName - The name of the function to encode data for.
24+
* @param {ArbAggregatorEncodeFunctionDataParameters<TFunctionName>} params - The parameters for encoding function data.
25+
* @param {string} params.functionName - The name of the function to encode data for.
26+
* @param {Array<any>} params.args - The arguments to pass to the function.
27+
* @param {Array<any>} params.abi - The ABI of the contract.
28+
* @returns {string} The encoded function data.
29+
*/
2030
function arbAggregatorEncodeFunctionData<
2131
TFunctionName extends ArbAggregatorPrepareTransactionRequestFunctionName,
2232
>({ functionName, abi, args }: ArbAggregatorEncodeFunctionDataParameters<TFunctionName>) {
@@ -33,6 +43,18 @@ type ArbAggregatorPrepareFunctionDataParameters<
3343
upgradeExecutor: Address | false;
3444
abi: ArbAggregatorAbi;
3545
};
46+
47+
/**
48+
* Prepares function data for the ArbAggregator contract function specified by the given function name.
49+
*
50+
* @template TFunctionName - The name of the function to prepare data for.
51+
* @param {ArbAggregatorPrepareFunctionDataParameters<TFunctionName>} params - The parameters for preparing function data.
52+
* @param {string} params.functionName - The name of the function to prepare data for.
53+
* @param {Array<any>} params.args - The arguments to pass to the function.
54+
* @param {Array<any>} params.abi - The ABI of the contract.
55+
* @param {Address|false} params.upgradeExecutor - The address of the upgrade executor or false if not applicable.
56+
* @returns {Object} The prepared function data including the target address, encoded data, and value.
57+
*/
3658
function arbAggregatorPrepareFunctionData<
3759
TFunctionName extends ArbAggregatorPrepareTransactionRequestFunctionName,
3860
>(params: ArbAggregatorPrepareFunctionDataParameters<TFunctionName>) {
@@ -68,11 +90,32 @@ export type ArbAggregatorPrepareTransactionRequestParameters<
6890
> = Omit<ArbAggregatorPrepareFunctionDataParameters<TFunctionName>, 'abi'> & {
6991
account: Address;
7092
};
93+
7194
/**
72-
* Prepares a transaction request for the ArbAggregator contract function
73-
* specified by the given function name. It generates the necessary data and
74-
* value for the transaction based on the input parameters and prepares the
95+
* Prepares a transaction request for the ArbAggregator contract function specified by the given function name.
96+
* It generates the necessary data and value for the transaction based on the input parameters and prepares the
7597
* transaction request using the provided client and account information.
98+
*
99+
* @template TFunctionName - The name of the function to prepare the transaction request for.
100+
* @template TChain - The type of the chain.
101+
* @param {PublicClient<Transport, TChain>} client - The public client used to prepare the transaction request.
102+
* @param {ArbAggregatorPrepareTransactionRequestParameters<TFunctionName>} params - The parameters for preparing the transaction request.
103+
* @param {string} params.functionName - The name of the function to prepare the transaction request for.
104+
* @param {Array<any>} params.args - The arguments to pass to the function.
105+
* @param {Address|false} params.upgradeExecutor - The address of the upgrade executor or false if not applicable.
106+
* @param {Address} params.account - The account address to use for the transaction.
107+
* @returns {Promise<Object>} The prepared transaction request including the chain ID.
108+
* @throws {Error} If the client.chain is undefined.
109+
*
110+
* @example
111+
* const client = new PublicClient(...);
112+
* const params = {
113+
* functionName: 'someFunction',
114+
* args: [arg1, arg2],
115+
* upgradeExecutor: '0xExecutorAddress',
116+
* account: '0xAccountAddress',
117+
* };
118+
* const request = await arbAggregatorPrepareTransactionRequest(client, params);
76119
*/
77120
export async function arbAggregatorPrepareTransactionRequest<
78121
TFunctionName extends ArbAggregatorPrepareTransactionRequestFunctionName,

src/arbAggregatorReadContract.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ export type ArbAggregatorReadContractReturnType<TFunctionName extends ArbAggrega
1616
/**
1717
* Reads data from the ArbAggregator smart contract and returns the specified
1818
* result.
19+
*
20+
* @template TChain - The type of the blockchain chain.
21+
* @template TFunctionName - The name of the function to read from the contract.
22+
* @param {PublicClient<Transport, TChain>} client - The public client to interact with the blockchain.
23+
* @param {ArbAggregatorReadContractParameters<TFunctionName>} params - The parameters for reading the contract.
24+
* @param {TFunctionName} params.functionName - The name of the function to call on the contract.
25+
* @param {Array<any>} [params.args] - The arguments to pass to the contract function.
26+
* @returns {Promise<ArbAggregatorReadContractReturnType<TFunctionName>>} - The result from the contract function.
27+
* @example
28+
* const client = new PublicClient(...);
29+
* const result = await arbAggregatorReadContract(client, {
30+
* functionName: 'getTotalStaked',
31+
* args: [],
32+
* });
33+
* console.log(result);
1934
*/
2035
export function arbAggregatorReadContract<
2136
TChain extends Chain | undefined,

src/arbGasInfoReadContract.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ export type ArbGasInfoAbi = typeof arbGasInfo.abi;
77
export type ArbGasInfoFunctionName = GetFunctionName<ArbGasInfoAbi>;
88

99
export type ArbGasInfoReadContractParameters<TFunctionName extends ArbGasInfoFunctionName> = {
10+
/**
11+
* The name of the function to be called on the ArbGasInfo contract.
12+
*/
1013
functionName: TFunctionName;
1114
} & GetFunctionArgs<ArbGasInfoAbi, TFunctionName>;
1215

@@ -16,6 +19,16 @@ export type ArbGasInfoReadContractReturnType<TFunctionName extends ArbGasInfoFun
1619
/**
1720
* Reads data from the ArbGasInfo contract on a specified chain and returns the
1821
* result.
22+
*
23+
* @template TChain - The type of the chain, can be a specific chain or undefined.
24+
* @template TFunctionName - The name of the function to be called on the ArbGasInfo contract.
25+
*
26+
* @param {PublicClient<Transport, TChain>} client - The public client to interact with the blockchain.
27+
* @param {ArbGasInfoReadContractParameters<TFunctionName>} params - The parameters for reading the contract.
28+
* @param {string} params.functionName - The name of the function to be called.
29+
* @param {Array<any>} [params.args] - The arguments to be passed to the function.
30+
*
31+
* @returns {Promise<ArbGasInfoReadContractReturnType<TFunctionName>>} - The result of the contract call.
1932
*/
2033
export function arbGasInfoReadContract<
2134
TChain extends Chain | undefined,

src/arbOwnerPrepareTransactionRequest.ts

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ export type ArbOwnerEncodeFunctionDataParameters<
1717
TFunctionName extends ArbOwnerPrepareTransactionRequestFunctionName,
1818
> = EncodeFunctionDataParameters<ArbOwnerAbi, TFunctionName>;
1919

20+
/**
21+
* Encodes function data for the ArbOwner contract.
22+
*
23+
* @template TFunctionName - The name of the function to encode.
24+
* @param {ArbOwnerEncodeFunctionDataParameters<TFunctionName>} params - The parameters for encoding the function data.
25+
* @param {string} params.functionName - The name of the function to encode.
26+
* @param {Array<any>} params.args - The arguments for the function.
27+
* @param {Array<any>} params.abi - The ABI of the contract.
28+
* @returns {string} The encoded function data.
29+
*/
2030
function arbOwnerEncodeFunctionData<
2131
TFunctionName extends ArbOwnerPrepareTransactionRequestFunctionName,
2232
>({ functionName, abi, args }: ArbOwnerEncodeFunctionDataParameters<TFunctionName>) {
@@ -27,12 +37,24 @@ function arbOwnerEncodeFunctionData<
2737
});
2838
}
2939

30-
type ArbOwnerPrepareFunctionDataParameters<
40+
export type ArbOwnerPrepareFunctionDataParameters<
3141
TFunctionName extends ArbOwnerPrepareTransactionRequestFunctionName,
3242
> = ArbOwnerEncodeFunctionDataParameters<TFunctionName> & {
3343
upgradeExecutor: Address | false;
3444
abi: ArbOwnerAbi;
3545
};
46+
47+
/**
48+
* Prepares function data for the ArbOwner contract, optionally using an upgrade executor.
49+
*
50+
* @template TFunctionName - The name of the function to prepare data for.
51+
* @param {ArbOwnerPrepareFunctionDataParameters<TFunctionName>} params - The parameters for preparing the function data.
52+
* @param {string} params.functionName - The name of the function to prepare data for.
53+
* @param {Array<any>} params.args - The arguments for the function.
54+
* @param {Array<any>} params.abi - The ABI of the contract.
55+
* @param {Address|false} params.upgradeExecutor - The address of the upgrade executor or false if not using an upgrade executor.
56+
* @returns {Object} The prepared function data including the target address, data, and value.
57+
*/
3658
function arbOwnerPrepareFunctionData<
3759
TFunctionName extends ArbOwnerPrepareTransactionRequestFunctionName,
3860
>(params: ArbOwnerPrepareFunctionDataParameters<TFunctionName>) {
@@ -68,8 +90,18 @@ export type ArbOwnerPrepareTransactionRequestParameters<
6890
};
6991

7092
/**
71-
* Prepares a transaction request for executing a function on the ArbOwner
72-
* contract.
93+
* Prepares a transaction request for executing a function on the ArbOwner contract.
94+
*
95+
* @template TFunctionName - The name of the function to execute.
96+
* @template TChain - The type of the chain.
97+
* @param {PublicClient<Transport, TChain>} client - The public client to use for the transaction.
98+
* @param {ArbOwnerPrepareTransactionRequestParameters<TFunctionName>} params - The parameters for preparing the transaction request.
99+
* @param {string} params.functionName - The name of the function to execute.
100+
* @param {Array<any>} params.args - The arguments for the function.
101+
* @param {Address|false} params.upgradeExecutor - The address of the upgrade executor or false if not using an upgrade executor.
102+
* @param {Address} params.account - The address of the account to use for the transaction.
103+
* @returns {Promise<Object>} The prepared transaction request including the chain ID.
104+
* @throws Will throw an error if the client chain is undefined.
73105
*/
74106
export async function arbOwnerPrepareTransactionRequest<
75107
TFunctionName extends ArbOwnerPrepareTransactionRequestFunctionName,

src/arbOwnerReadContract.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,28 @@ export type ArbOwnerPublicAbi = typeof arbOwnerPublic.abi;
77
export type ArbOwnerPublicFunctionName = GetFunctionName<ArbOwnerPublicAbi>;
88

99
export type ArbOwnerReadContractParameters<TFunctionName extends ArbOwnerPublicFunctionName> = {
10+
/**
11+
* The name of the function to call on the contract.
12+
*/
1013
functionName: TFunctionName;
1114
} & GetFunctionArgs<ArbOwnerPublicAbi, TFunctionName>;
1215

1316
export type ArbOwnerReadContractReturnType<TFunctionName extends ArbOwnerPublicFunctionName> =
1417
ReadContractReturnType<ArbOwnerPublicAbi, TFunctionName>;
1518

16-
/** Reads data from a contract owned by an arbitrary owner. */
19+
/**
20+
* Reads data from a contract owned by an arbitrary owner.
21+
*
22+
* @template TChain - The type of the blockchain chain.
23+
* @template TFunctionName - The name of the function to call on the contract.
24+
*
25+
* @param {PublicClient<Transport, TChain>} client - The public client to use for reading the contract.
26+
* @param {ArbOwnerReadContractParameters<TFunctionName>} params - The parameters for reading the contract.
27+
* @param {TFunctionName} params.functionName - The name of the function to call on the contract.
28+
* @param {Array} [params.args] - The arguments to pass to the function.
29+
*
30+
* @returns {Promise<ArbOwnerReadContractReturnType<TFunctionName>>} - The result of reading the contract.
31+
*/
1732
export function arbOwnerReadContract<
1833
TChain extends Chain | undefined,
1934
TFunctionName extends ArbOwnerPublicFunctionName,

src/constants.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
import { parseEther } from 'viem';
22

33
/**
4-
* createRollupDefaultRetryablesFees represents the default retryables fees for
5-
* rollup transactions and returns an Ether value.
4+
* Represents the default retryables fees for rollup transactions.
5+
*
6+
* This constant returns an Ether value representing the default fees
7+
* for retryable transactions in rollups.
8+
*
9+
* @constant {bigint} createRollupDefaultRetryablesFees
610
*/
711
export const createRollupDefaultRetryablesFees = parseEther('0.125');
812

913
/**
10-
* createTokenBridgeDefaultRetryablesFees returns the default fees for retryable
11-
* transactions in the TokenBridge, represented as an Ether value.
14+
* Represents the default fees for retryable transactions in the TokenBridge.
15+
*
16+
* This constant returns an Ether value representing the default fees
17+
* for retryable transactions in the TokenBridge.
18+
*
19+
* @constant {bigint} createTokenBridgeDefaultRetryablesFees
1220
*/
1321
export const createTokenBridgeDefaultRetryablesFees = parseEther('0.02');

src/contracts.ts

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,63 @@ import {
1111
} from './generated';
1212
import { sequencerInboxABI, rollupAdminLogicABI } from './abi';
1313

14-
/** erc20 returns a {@link Foo}. */
14+
/**
15+
* ERC-20 token contract configuration.
16+
* @property {Array} abi - The ABI of the ERC-20 token contract.
17+
*/
1518
export const erc20 = {
1619
abi: erc20ABI,
1720
};
1821

19-
/** arbOwner configures the Arbitrum owner with the specified address. */
22+
/**
23+
* Arbitrum owner configuration.
24+
* @property {Object} arbOwnerConfig - The configuration object for the Arbitrum owner.
25+
* @property {string} address - The address of the Arbitrum owner.
26+
*/
2027
export const arbOwner = {
2128
...arbOwnerConfig,
2229
address: Object.values(arbOwnerConfig.address)[0],
2330
} as const;
2431

2532
/**
26-
* arbGasInfo provides information about the gas configuration for the Arbitrum
27-
* network.
33+
* Gas information configuration for the Arbitrum network.
34+
* @property {Object} arbGasInfoConfig - The configuration object for Arbitrum gas information.
35+
* @property {string} address - The address for gas information.
2836
*/
2937
export const arbGasInfo = {
3038
...arbGasInfoConfig,
3139
address: Object.values(arbGasInfoConfig.address)[0],
3240
} as const;
3341

34-
/** arbOwnerPublic configuration for the Arbitrum owner's public address. */
42+
/**
43+
* Public configuration for the Arbitrum owner's address.
44+
* @property {Object} arbOwnerPublicConfig - The configuration object for the Arbitrum owner's public address.
45+
* @property {string} address - The public address of the Arbitrum owner.
46+
*/
3547
export const arbOwnerPublic = {
3648
...arbOwnerPublicConfig,
3749
address: Object.values(arbOwnerPublicConfig.address)[0],
3850
} as const;
3951

40-
/** arbAggregator retrieves data from a specified source. */
52+
/**
53+
* Aggregator configuration for retrieving data from a specified source.
54+
* @property {Object} arbAggregatorConfig - The configuration object for the Arbitrum aggregator.
55+
* @property {string} address - The address of the aggregator.
56+
*/
4157
export const arbAggregator = {
4258
...arbAggregatorConfig,
4359
address: Object.values(arbAggregatorConfig.address)[0],
4460
} as const;
4561

46-
/** rollupCreator returns a {@link rollupCreatorConfig}. */
62+
/**
63+
* Rollup creator configuration.
64+
* @property {Object} rollupCreatorConfig - The configuration object for the rollup creator.
65+
*/
4766
export const rollupCreator = rollupCreatorConfig;
4867

4968
/**
50-
* upgradeExecutor provides functions to execute upgrades, execute calls, check
51-
* roles, grant roles, and revoke roles.
69+
* Executor for upgrades, calls, and role management.
70+
* @property {Array} abi - The ABI for the upgrade executor contract.
5271
*/
5372
export const upgradeExecutor = {
5473
abi: parseAbi([
@@ -106,19 +125,6 @@ const tokenBridgeCreatorABI = [
106125
anonymous: false,
107126
inputs: [
108127
{ indexed: true, internalType: 'address', name: 'inbox', type: 'address' },
109-
{
110-
components: [
111-
{ internalType: 'address', name: 'router', type: 'address' },
112-
{ internalType: 'address', name: 'standardGateway', type: 'address' },
113-
{ internalType: 'address', name: 'customGateway', type: 'address' },
114-
{ internalType: 'address', name: 'wethGateway', type: 'address' },
115-
{ internalType: 'address', name: 'weth', type: 'address' },
116-
],
117-
indexed: false,
118-
internalType: 'struct L1DeploymentAddresses',
119-
name: 'l1',
120-
type: 'tuple',
121-
},
122128
{
123129
components: [
124130
{ internalType: 'address', name: 'router', type: 'address' },
@@ -213,20 +219,28 @@ const tokenBridgeCreatorABI = [
213219
] as const;
214220

215221
/**
216-
* tokenBridgeCreator configures and deploys a token bridge between Layer 1 and
217-
* Layer 2 Ethereum networks.
222+
* Token bridge creator configuration and ABI.
223+
* @property {Object} tokenBridgeCreatorConfig - The configuration object for the token bridge creator.
224+
* @property {Array} abi - The ABI for the token bridge creator contract.
218225
*/
219226
export const tokenBridgeCreator = {
220227
...tokenBridgeCreatorConfig,
221228
abi: tokenBridgeCreatorABI,
222229
} as const;
223230

224-
/** sequencerInbox returns a {@link sequencerInboxABI}. */
231+
/**
232+
* Sequencer inbox contract configuration.
233+
* @property {Array} abi - The ABI of the sequencer inbox contract.
234+
*/
225235
export const sequencerInbox = {
226236
abi: sequencerInboxABI,
227237
};
228238

229-
/** rollupAdminLogic represents the ABI for the Rollup Admin Logic contract. */
239+
/**
240+
* Rollup Admin Logic contract configuration.
241+
* @property {Array} abi - The ABI of the Rollup Admin Logic contract.
242+
*/
230243
export const rollupAdminLogic = {
231244
abi: rollupAdminLogicABI,
232245
};
246+

src/createRollup.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ type EnsureCustomGasTokenAllowanceGrantedToRollupCreatorParams = {
2929
*
3030
* If not, perform an approval transaction to grant the custom fee token
3131
* spend allowance to the Rollup Creator address.
32+
*
33+
* @param {EnsureCustomGasTokenAllowanceGrantedToRollupCreatorParams} params - The parameters required to ensure custom gas token allowance
34+
* @param {Address} params.nativeToken - The native token address
35+
* @param {ParentChainPublicClient} params.parentChainPublicClient - The parent chain public client
36+
* @param {PrivateKeyAccount} params.account - The rollup owner private key account
3237
*/
3338
async function ensureCustomGasTokenAllowanceGrantedToRollupCreator({
3439
nativeToken,
@@ -80,7 +85,7 @@ export type CreateRollupFunctionParams = {
8085
/**
8186
* @param {Object} createRollupResults - results of the createRollup function
8287
* @param {Object} createRollupResults.transaction - the transaction for deploying the core contracts
83-
* @param {Object} createRollupResults.txReceipt - the transaction receipt
88+
* @param {Object} createRollupResults.transactionReceipt - the transaction receipt
8489
* @param {Object} createRollupResults.coreContracts - the core contracts
8590
*/
8691
export type CreateRollupResults = {

0 commit comments

Comments
 (0)