Skip to content

Commit 5b9f285

Browse files
committed
refactor: add chain-id input to workflow and update README and index.ts for default handling
1 parent 1f99488 commit 5b9f285

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

.github/workflows/safe-transaction.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ on:
1414
description: 'Target address for the transaction'
1515
required: true
1616
type: string
17+
chain-id:
18+
description: 'Chain ID of the blockchain network (default: 42161 for Arbitrum)'
19+
required: false
20+
default: '42161'
21+
type: string
1722
transaction-value:
1823
description: 'Value to send in the transaction (in wei, default: 0)'
1924
required: false
@@ -76,6 +81,7 @@ jobs:
7681
INPUT_RPC_URL: ${{ inputs.rpc-url }}
7782
INPUT_SAFE_ADDRESS: ${{ inputs.safe-address }}
7883
INPUT_TARGET_ADDRESS: ${{ inputs.transaction-target-address }}
84+
INPUT_CHAIN_ID: ${{ inputs.chain-id }}
7985
INPUT_TRANSACTION_VALUE: ${{ inputs.transaction-value }}
8086
INPUT_TRANSACTION_DATA: ${{ inputs.transaction-data }}
8187
id: safe-transaction

safe-transaction/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This reusable GitHub Actions workflow automates the process of creating and prop
1010
| ------------------------ | ------------------------------------------------------------- | ------------ | ----------------------------------- |
1111
| **proposer-private-key** | Private key of the proposer wallet | Yes | - |
1212
| **rpc-url** | RPC URL for the blockchain network | Yes | - |
13+
| **chain-id** | Chain ID of the blockchain network | No | `42161` (Arbitrum) |
1314
| **safe-address** | Address of the Safe contract | Yes | - |
1415
| **transaction-target-address** | Target address for the transaction | Yes | - |
1516
| **safe-api-key** | Safe API key for transaction service | Yes | - |
@@ -46,6 +47,10 @@ This reusable GitHub Actions workflow automates the process of creating and prop
4647
transaction-target-address:
4748
description: 'Target contract address'
4849
required: true
50+
chain-id:
51+
description: 'Chain ID (e.g., 1 for Ethereum, 42161 for Arbitrum)'
52+
required: false
53+
default: '42161'
4954
transaction-data:
5055
description: 'Transaction data (0x prefixed)'
5156
required: false
@@ -61,6 +66,7 @@ This reusable GitHub Actions workflow automates the process of creating and prop
6166
with:
6267
safe-address: ${{ inputs.safe-address }}
6368
transaction-target-address: ${{ inputs.transaction-target-address }}
69+
chain-id: ${{ inputs.chain-id }}
6470
transaction-data: ${{ inputs.transaction-data }}
6571
```
6672

safe-transaction/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ async function run() {
99
// Get inputs from environment variables
1010
const proposerPrivateKey = process.env.INPUT_PROPOSER_PRIVATE_KEY;
1111
const rpcUrl = process.env.INPUT_RPC_URL;
12+
const chainId = process.env.INPUT_CHAIN_ID || "42161"; // Default to Arbitrum
1213
const safeAddress = process.env.INPUT_SAFE_ADDRESS;
1314
const transactionTargetAddress = process.env.INPUT_TARGET_ADDRESS;
1415
const safeApiKey = process.env.INPUT_SAFE_API_KEY;
@@ -27,6 +28,7 @@ async function run() {
2728
}
2829

2930
core.info(`🚀 Starting Safe transaction proposal...`);
31+
core.info(`🌐 Chain ID: ${chainId}`);
3032
core.info(`📍 Safe Address: ${safeAddress}`);
3133
core.info(`🎯 Target Address: ${transactionTargetAddress}`);
3234

@@ -36,7 +38,7 @@ async function run() {
3638

3739
// Initialize API Kit
3840
const apiKit = new SafeApiKit({
39-
chainId: 42161n, // Arbitrum
41+
chainId: BigInt(chainId),
4042
apiKey: safeApiKey,
4143
});
4244

0 commit comments

Comments
 (0)