-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🗞️ Export Safe-compatible JSON from lz:oapp:wire and lz:ownable:transfer-ownership #576
Comments
To address the problem of Safe UIs not being compatible with the current way of signing safe transactions, we can add a new CLI flag to your task scripts that will enable JSON-compatible output generation. This solution will involve two main functionalities: exporting the JSON file to the filesystem and printing the JSON file to the console. Below are the steps to implement this solution Steps to Implement the Solution
Example Implementation Here’s a sample implementation in Python, assuming you have a task script that processes transactions: Step 1: Modify the Task Script import argparse
import json
import sys
def process_transaction(transaction_data):
# Placeholder for transaction processing logic
processed_data = {"status": "success", "data": transaction_data}
return processed_data
def main():
parser = argparse.ArgumentParser(description="Process transactions for Safe UI.")
parser.add_argument("--input", type=str, required=True, help="Input file containing transaction data.")
parser.add_argument("--output-json", type=str, help="Output JSON file path. If not provided, JSON will be printed to console.")
args = parser.parse_args()
# Read transaction data from input file
with open(args.input, 'r') as file:
transaction_data = json.load(file)
# Process the transaction
result = process_transaction(transaction_data)
# Convert the result to JSON
result_json = json.dumps(result, indent=4)
if args.output_json:
# Export JSON to file
with open(args.output_json, 'w') as output_file:
output_file.write(result_json)
print(f"JSON output saved to {args.output_json}")
else:
# Print JSON to console
print(result_json)
if __name__ == "__main__":
main() Step 2: Export to Filesystem In the Step 3: Print to Console The Step 4: Update Documentation Update the script's documentation and usage instructions: Usage: script_name.py --input <input_file> [--output-json <output_file>]
Options:
--input Input file containing transaction data.
--output-json Output JSON file path. If not provided, JSON will be printed to console.
Examples:
python script_name.py --input transactions.json --output-json output.json
python script_name.py --input transactions.json Benefits of This Approach
This solution provides a straightforward way to handle the compatibility issue with Safe UIs and offers flexibility in how users can export and manage their transaction data. |
Is your feature request related to a problem? Please describe.
Some of the Safe UIs are not compatible with the current way of signing safe transactions. The aforementioned tasks should support a JSON-compatible output generation so that the user can export the transactions and upload them manually to the Safe UI
Describe the solution you'd like
Add a CLI flag to the tasks that will make them either:
The text was updated successfully, but these errors were encountered: