Skip to content

Commit 2d48427

Browse files
Le-CaignecgfournierProzguesmi
authored
feat: Add new Safe Wallet reusable workflow (#85)
* add new reusable workflow * refactor: rename target-address to transaction-target-address in README, workflow, and source code for consistency * chore: update changelog and version to 1.0.0 for safe transaction workflow * chore: remove unused keywords from package.json * chore: update README to reflect workflow usage changes and remove obsolete workflow file * chore: remove unnecessary blank line in README for improved readability * chore: remove redundant prepare script from package.json * chore: move proposer-private-key and safe-api-key to secrets in workflow inputs * chore: remove npm cache configuration from Node.js setup * chore: add ref to checkout step in safe-transaction workflow for testing * chore: add prepare script to package.json and clarify operation type in transaction creation * refactor: update Safe initialization method from init to create for consistency * refactor: enhance wallet initialization with provider and integrate EthersAdapter for improved functionality * style: standardize quotation marks in index.js for consistency * feat: add debug logging for safe transaction data and specify origin in transaction proposal * feat: add transaction service URL for Safe API initialization * feat: add debug logging for API Kit initialization in safe transaction * feat: enhance debug logging for safe transaction process and API Kit state * refactor: simplify wallet and Safe initialization by removing unnecessary dependencies and parameters * refactor: remove chain-id input from workflow and update dependencies for improved compatibility * refactor: update dependencies and improve Safe transaction proposal process with new API and Protocol Kits * refactor: update API Kit and Protocol Kit initialization to use default exports * refactor: update API and Protocol Kit initialization to remove default exports * refactor: remove module type declaration from package.json * refactor: add chain-id input to workflow and update README and index.ts for default handling * refactor: move chain-id input definition to the correct position in the workflow * refactor: rename transaction-target-address to transaction-to for consistency * refactor: update Node.js version from 20 to 22 in workflow * refactor: add origin field to transaction proposal for GitHub Action context * Update safe-transaction/README.md Co-authored-by: gfournieriExec <[email protected]> * refactor: remove chain-id input and detect it from RPC URL in workflow * refactor: replace ethers with viem for wallet and chain ID detection * Update safe-transaction/package.json Co-authored-by: Zied Guesmi <[email protected]> * Update safe-transaction/package.json Co-authored-by: Zied Guesmi <[email protected]> * Update .github/workflows/safe-transaction.yml Co-authored-by: Zied Guesmi <[email protected]> * Update .github/workflows/safe-transaction.yml Co-authored-by: Zied Guesmi <[email protected]> * Update .github/workflows/safe-transaction.yml Co-authored-by: Zied Guesmi <[email protected]> * Update .github/workflows/safe-transaction.yml Co-authored-by: Zied Guesmi <[email protected]> * Update .github/workflows/safe-transaction.yml Co-authored-by: Zied Guesmi <[email protected]> * Update .github/workflows/safe-transaction.yml Co-authored-by: Zied Guesmi <[email protected]> * Update .github/workflows/safe-transaction.yml Co-authored-by: Zied Guesmi <[email protected]> * Update .github/workflows/safe-transaction.yml Co-authored-by: Zied Guesmi <[email protected]> * feat: add reusable workflow for proposing Safe multisig transactions - Created a new GitHub Actions workflow for proposing transactions to a Gnosis Safe multisig wallet. - Added inputs for RPC URL, Safe address, transaction target, value, and data. - Implemented job steps for checking out the repository, setting up Node.js, installing dependencies, building the action, and proposing the transaction. - Included a README with usage instructions and a changelog. - Added TypeScript configuration and source code for the action. - Created .gitignore to exclude unnecessary files and directories. - Initialized package.json and package-lock.json for dependency management. - Added version tracking with version.txt. * feat: add environment variable validation and update dependencies * refactor: streamline transaction proposal logic and enhance error handling * feat: update Safe multisig transaction workflow to use new environment variable structure and enhance validation * feat: enhance validation for SAFE_PROPOSER_PRIVATE_KEY in environment configuration * chore: remove redundant chain ID detection logs from transaction proposal workflow * fix: update workflow name to 'Propose Safe Multisig Transaction' for clarity * Update propose-safe-multisig-tx/src/index.ts Co-authored-by: Zied Guesmi <[email protected]> * Update propose-safe-multisig-tx/src/index.ts Co-authored-by: Zied Guesmi <[email protected]> * Update propose-safe-multisig-tx/src/index.ts Co-authored-by: Zied Guesmi <[email protected]> * Update propose-safe-multisig-tx/README.md Co-authored-by: Zied Guesmi <[email protected]> * feat: update workflow example for contract upgrade process * chore: remove temporary reference for testing in workflow --------- Co-authored-by: gfournieriExec <[email protected]> Co-authored-by: Zied Guesmi <[email protected]>
1 parent 2e0d532 commit 2d48427

File tree

11 files changed

+922
-0
lines changed

11 files changed

+922
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: 'Propose Safe Multisig Transaction'
2+
on:
3+
workflow_call:
4+
inputs:
5+
rpc-url:
6+
description: 'RPC URL for the blockchain network'
7+
required: true
8+
type: string
9+
safe-address:
10+
description: 'Address of the Safe contract'
11+
required: true
12+
type: string
13+
transaction-to:
14+
description: 'Target address of the transaction'
15+
required: true
16+
type: string
17+
transaction-value:
18+
description: 'Value to send in the transaction (in wei, default: 0)'
19+
required: false
20+
default: '0'
21+
type: string
22+
transaction-data:
23+
description: 'Transaction data/calldata'
24+
required: true
25+
type: string
26+
secrets:
27+
safe-proposer-private-key:
28+
description: 'Private key of the proposer wallet'
29+
required: true
30+
safe-api-key:
31+
description: 'Safe API key for transaction service'
32+
required: true
33+
outputs:
34+
tx-hash:
35+
description: 'Hash of the Safe transaction'
36+
value: ${{ jobs.propose-transaction.outputs.tx-hash }}
37+
tx-details:
38+
description: 'Created transaction details'
39+
value: ${{ jobs.propose-transaction.outputs.tx-details }}
40+
41+
jobs:
42+
propose-transaction:
43+
runs-on: ubuntu-latest
44+
outputs:
45+
tx-hash: ${{ steps.safe-transaction.outputs.tx-hash }}
46+
tx-details: ${{ steps.safe-transaction.outputs.tx-details }}
47+
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
with:
52+
repository: iExecBlockchainComputing/github-actions-workflows
53+
54+
- name: Setup Node.js
55+
uses: actions/setup-node@v4
56+
with:
57+
node-version: '22'
58+
59+
- name: Install dependencies
60+
run: npm ci
61+
working-directory: ./propose-safe-multisig-tx
62+
63+
- name: Build action
64+
run: npm run build
65+
working-directory: ./propose-safe-multisig-tx
66+
67+
- name: Propose Safe Transaction
68+
run: npm run propose
69+
working-directory: ./propose-safe-multisig-tx
70+
env:
71+
RPC_URL: ${{ inputs.rpc-url }}
72+
SAFE_ADDRESS: ${{ inputs.safe-address }}
73+
TRANSACTION_TO: ${{ inputs.transaction-to }}
74+
TRANSACTION_VALUE: ${{ inputs.transaction-value }}
75+
TRANSACTION_DATA: ${{ inputs.transaction-data }}
76+
SAFE_PROPOSER_PRIVATE_KEY: ${{ secrets.safe-proposer-private-key }}
77+
SAFE_API_KEY: ${{ secrets.safe-api-key }}
78+
id: safe-transaction

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ Provides a standardized workflow for building, testing, and publishing Rust pack
2525
### 🧹 [Stale Issues and PRs](./stale)
2626
Automatically identifies and closes stale issues and pull requests to maintain a clean and focused repository. Helps your team concentrate on active work items and reduces maintenance overhead.
2727

28+
### 🛡️ [Safe Multisig Transaction Proposer](./propose-safe-multisig-tx)
29+
Automates the process of proposing transactions to a Safe multi-signature wallet (Gnosis Safe). Features smart chain detection, comprehensive validation, and secure transaction handling for blockchain operations.
30+
2831
## 🔧 Usage
2932

3033
Each workflow has its own detailed documentation in its respective directory. The comprehensive documentation includes:
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build outputs
5+
dist/
6+
7+
# IDE
8+
.vscode/
9+
.idea/
10+
11+
# OS
12+
.DS_Store
13+
Thumbs.db
14+
15+
# Environment variables
16+
.env
17+
.env.local
18+
.env.*.local
19+
20+
# Logs
21+
logs/
22+
*.log
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
## 1.0.0 (2025-09-29)
4+
5+
### Features
6+
7+
* **safe-transaction:** add workflow for safe transaction submission ([#85](https://github.com/iExecBlockchainComputing/github-actions-workflows/pull/85))

propose-safe-multisig-tx/README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Safe Multisig Transaction Proposer - Reusable Workflow
2+
3+
## Overview 🌟
4+
5+
This reusable GitHub Actions workflow automates the process of proposing transactions to a Safe multi-signature wallet (Gnosis Safe). It handles the proposal submission, making it easy to integrate Safe transactions into your CI/CD pipeline.
6+
7+
## Workflow Inputs 🛠️
8+
9+
| **Input** | **Description** | **Required** | **Default** |
10+
| ------------------------ | ------------------------------------------------------------- | ------------ | ----------------------------------- |
11+
| **rpc-url** | RPC URL for the blockchain network | Yes | - |
12+
| **safe-address** | Address of the Safe contract | Yes | - |
13+
| **transaction-to** | Target address for the transaction | Yes | - |
14+
| **transaction-value** | Value to send in the transaction (in wei) | No | `0` |
15+
| **transaction-data** | Transaction data/calldata | Yes | - |
16+
| **safe-proposer-private-key** | Private key of the proposer wallet | Yes (Secret) | - |
17+
| **safe-api-key** | Safe API key for transaction service | Yes (Secret) | - |
18+
19+
## Workflow Outputs 📤
20+
21+
| **Output** | **Description** |
22+
| ----------------- | ----------------------------------------- |
23+
| **tx-hash** | Hash of the Safe transaction created |
24+
| **tx-details** | Complete transaction details (JSON) |
25+
26+
## How to Use This Reusable Workflow 🔄
27+
28+
1. **Call the Reusable Workflow**
29+
In another workflow file, invoke this reusable workflow like so:
30+
31+
```yaml
32+
name: Upgrade contract
33+
34+
on:
35+
workflow_dispatch:
36+
37+
jobs:
38+
upgrade:
39+
uses: ./.github/workflows/propose-safe-multisig-tx.yml
40+
secrets:
41+
safe-proposer-private-key: ${{ secrets.SAFE_PROPOSER_PRIVATE_KEY }}
42+
safe-api-key: ${{ secrets.SAFE_API_KEY }}
43+
with:
44+
rpc-url: 'https://...'
45+
safe-address: '0xab...'
46+
transaction-to: '0xcd...'
47+
transaction-value: '0'
48+
transaction-data: '0xef' # Upgrade transaction calldata
49+
```
50+
51+
2. **Configure Secrets**
52+
Ensure that the required secrets are added to your repository's settings:
53+
- `SAFE_PROPOSER_PRIVATE_KEY`: The private key of the wallet that will propose the transaction
54+
- `SAFE_API_KEY`: Your Safe API key for the transaction service
55+
56+
## Security Considerations 🛡️
57+
58+
⚠️ **Important**: Never expose private keys in logs or code files. Always use GitHub Secrets to store sensitive information securely.

0 commit comments

Comments
 (0)