Skip to content

Commit d5348b4

Browse files
committed
refactor: rename target-address to transaction-target-address in README, workflow, and source code for consistency
1 parent 76f06e4 commit d5348b4

File tree

3 files changed

+26
-36
lines changed

3 files changed

+26
-36
lines changed

safe-transaction/.github/workflows/safe-transaction.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
description: 'Address of the Safe contract'
1616
required: true
1717
type: string
18-
target-address:
18+
transaction-target-address:
1919
description: 'Target address for the transaction'
2020
required: true
2121
type: string
@@ -38,11 +38,6 @@ on:
3838
required: false
3939
default: '0x'
4040
type: string
41-
operation:
42-
description: 'Operation type (0 for Call, 1 for DelegateCall)'
43-
required: false
44-
default: '0'
45-
type: string
4641
outputs:
4742
safe-tx-hash:
4843
description: 'Hash of the Safe transaction'
@@ -80,10 +75,9 @@ jobs:
8075
INPUT_PROPOSER_PRIVATE_KEY: ${{ inputs.proposer-private-key }}
8176
INPUT_RPC_URL: ${{ inputs.rpc-url }}
8277
INPUT_SAFE_ADDRESS: ${{ inputs.safe-address }}
83-
INPUT_TARGET_ADDRESS: ${{ inputs.target-address }}
78+
INPUT_TARGET_ADDRESS: ${{ inputs.transaction-target-address }}
8479
INPUT_SAFE_API_KEY: ${{ inputs.safe-api-key }}
8580
INPUT_CHAIN_ID: ${{ inputs.chain-id }}
8681
INPUT_TRANSACTION_VALUE: ${{ inputs.transaction-value }}
8782
INPUT_TRANSACTION_DATA: ${{ inputs.transaction-data }}
88-
INPUT_OPERATION: ${{ inputs.operation }}
8983
id: safe-transaction

safe-transaction/README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ This reusable GitHub Actions workflow automates the process of creating and prop
1111
| **proposer-private-key** | Private key of the proposer wallet | Yes | - |
1212
| **rpc-url** | RPC URL for the blockchain network | Yes | - |
1313
| **safe-address** | Address of the Safe contract | Yes | - |
14-
| **target-address** | Target address for the transaction | Yes | - |
14+
| **transaction-target-address** | Target address for the transaction | Yes | - |
1515
| **safe-api-key** | Safe API key for transaction service | Yes | - |
1616
| **chain-id** | Chain ID of the blockchain network | No | `42161` (Arbitrum) |
1717
| **transaction-value** | Value to send in the transaction (in wei) | No | `0` |
1818
| **transaction-data** | Transaction data/calldata | No | `0x` |
19-
| **operation** | Operation type (0 for Call, 1 for DelegateCall) | No | `0` |
2019

2120
## Workflow Outputs 📤
2221

@@ -48,7 +47,7 @@ This reusable GitHub Actions workflow automates the process of creating and prop
4847
safe-address:
4948
description: 'Safe contract address'
5049
required: true
51-
target-address:
50+
transaction-target-address:
5251
description: 'Target contract address'
5352
required: true
5453
transaction-data:
@@ -65,7 +64,7 @@ This reusable GitHub Actions workflow automates the process of creating and prop
6564
safe-api-key: ${{ secrets.SAFE_API_KEY }}
6665
with:
6766
safe-address: ${{ inputs.safe-address }}
68-
target-address: ${{ inputs.target-address }}
67+
transaction-target-address: ${{ inputs.transaction-target-address }}
6968
transaction-data: ${{ inputs.transaction-data }}
7069
```
7170
@@ -74,11 +73,6 @@ This reusable GitHub Actions workflow automates the process of creating and prop
7473
- `PROPOSER_PRIVATE_KEY`: The private key of the wallet that will propose the transaction
7574
- `SAFE_API_KEY`: Your Safe API key for the transaction service
7675

77-
## Operation Types 🔧
78-
79-
- **`0`**: **Call** - Normal transaction execution
80-
- **`1`**: **DelegateCall** - Execution in the context of the Safe contract
81-
8276
## Security Considerations 🛡️
8377

8478
⚠️ **Important**: Never expose private keys in logs or code files. Always use GitHub Secrets to store sensitive information securely.

safe-transaction/src/index.js

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@ async function run() {
1010
const proposerPrivateKey = process.env.INPUT_PROPOSER_PRIVATE_KEY;
1111
const rpcUrl = process.env.INPUT_RPC_URL;
1212
const safeAddress = process.env.INPUT_SAFE_ADDRESS;
13-
const targetAddress = process.env.INPUT_TARGET_ADDRESS;
13+
const transactionTargetAddress = process.env.INPUT_TARGET_ADDRESS;
1414
const safeApiKey = process.env.INPUT_SAFE_API_KEY;
15-
const chainId = BigInt(process.env.INPUT_CHAIN_ID || '42161');
16-
const transactionValue = process.env.INPUT_TRANSACTION_VALUE || '0';
17-
const transactionData = process.env.INPUT_TRANSACTION_DATA || '0x';
18-
const operation = process.env.INPUT_OPERATION || '0';
15+
const chainId = BigInt(process.env.INPUT_CHAIN_ID || "42161");
16+
const transactionValue = process.env.INPUT_TRANSACTION_VALUE || "0";
17+
const transactionData = process.env.INPUT_TRANSACTION_DATA || "0x";
18+
// Hardcoded to 0 (Call operation) - DelegateCall (1) is not supported for security reasons
19+
const operation = 0;
1920

2021
core.info(`🚀 Starting Safe transaction creation...`);
2122
core.info(`📍 Safe Address: ${safeAddress}`);
22-
core.info(`🎯 Target Address: ${targetAddress}`);
23+
core.info(`🎯 Target Address: ${transactionTargetAddress}`);
2324

2425
// Initialize wallet
2526
const wallet = new Wallet(proposerPrivateKey);
@@ -28,27 +29,27 @@ async function run() {
2829
// Initialize API Kit
2930
const apiKit = new SafeApiKit({
3031
chainId: chainId,
31-
apiKey: safeApiKey
32+
apiKey: safeApiKey,
3233
});
3334

3435
// Initialize Protocol Kit
3536
const protocolKit = await Safe.init({
3637
provider: rpcUrl,
3738
signer: proposerPrivateKey,
38-
safeAddress: safeAddress
39+
safeAddress: safeAddress,
3940
});
4041

4142
// Create transaction
4243
const safeTransactionData = {
43-
to: targetAddress,
44+
to: transactionTargetAddress,
4445
value: transactionValue,
4546
data: transactionData,
46-
operation: parseInt(operation)
47+
operation: parseInt(operation),
4748
};
4849

49-
core.info('📝 Creating Safe transaction...');
50+
core.info("📝 Creating Safe transaction...");
5051
const safeTransaction = await protocolKit.createTransaction({
51-
transactions: [safeTransactionData]
52+
transactions: [safeTransactionData],
5253
});
5354

5455
const safeTxHash = await protocolKit.getTransactionHash(safeTransaction);
@@ -62,22 +63,23 @@ async function run() {
6263
safeTransactionData: safeTransaction.data,
6364
safeTxHash: safeTxHash,
6465
senderAddress: wallet.address,
65-
senderSignature: signature.data
66+
senderSignature: signature.data,
6667
});
6768

68-
core.info('📤 Transaction proposed to Safe service');
69+
core.info("📤 Transaction proposed to Safe service");
6970

7071
// Get transaction details
7172
const transaction = await apiKit.getTransaction(safeTxHash);
72-
73+
7374
// Set outputs
74-
core.setOutput('safe-tx-hash', safeTxHash);
75-
core.setOutput('transaction', JSON.stringify(transaction));
75+
core.setOutput("safe-tx-hash", safeTxHash);
76+
core.setOutput("transaction", JSON.stringify(transaction));
7677

7778
core.info(`✅ Transaction created successfully!`);
7879
core.info(`🔗 Transaction Hash: ${safeTxHash}`);
79-
core.info(`📋 Transaction Details: ${JSON.stringify(transaction, null, 2)}`);
80-
80+
core.info(
81+
`📋 Transaction Details: ${JSON.stringify(transaction, null, 2)}`
82+
);
8183
} catch (error) {
8284
core.setFailed(`❌ Error creating Safe transaction: ${error.message}`);
8385
core.error(error.stack);

0 commit comments

Comments
 (0)