|
13 | 13 | cli_path = f"cd {get_project_root()}/source && ./ckb-cli" |
14 | 14 |
|
15 | 15 |
|
16 | | -def exception_use_old_ckb(): |
17 | | - def decorator(func): |
18 | | - @wraps(func) |
19 | | - def wrapper(*args, **kwargs): |
20 | | - try: |
21 | | - return func(*args, **kwargs) |
22 | | - except Exception as e: |
23 | | - if "SoftFork" in str(e): |
24 | | - global cli_path |
25 | | - cli_path = f"cd {get_project_root()}/source && ./ckb-cli-old" |
26 | | - print("------ change use old ckb-cli -------") |
27 | | - try: |
28 | | - ret = func(*args, **kwargs) |
29 | | - cli_path = f"cd {get_project_root()}/source && ./ckb-cli" |
30 | | - return ret |
31 | | - except Exception as e: |
32 | | - cli_path = f"cd {get_project_root()}/source && ./ckb-cli" |
33 | | - raise e |
34 | | - else: |
35 | | - raise e |
36 | | - |
37 | | - return wrapper |
38 | | - |
39 | | - return decorator |
40 | | - |
41 | | - |
42 | | -@exception_use_old_ckb() |
43 | 16 | def wallet_get_capacity(ckb_address, api_url="http://127.0.0.1:8114"): |
44 | 17 | """ |
45 | 18 | MacBook-Pro-4 0.111.0 % ./ckb-cli wallet get-capacity |
@@ -67,7 +40,6 @@ def wallet_get_capacity(ckb_address, api_url="http://127.0.0.1:8114"): |
67 | 40 | Exception(f"Number not found :{capacity_response}") |
68 | 41 |
|
69 | 42 |
|
70 | | -@exception_use_old_ckb() |
71 | 43 | def wallet_get_live_cells(ckb_address, api_url="http://127.0.0.1:8114"): |
72 | 44 | """ |
73 | 45 | ./ckb-cli wallet get-live-cells --address |
@@ -132,7 +104,6 @@ def wallet_get_live_cells(ckb_address, api_url="http://127.0.0.1:8114"): |
132 | 104 | return json.loads(run_command(cmd)) |
133 | 105 |
|
134 | 106 |
|
135 | | -@exception_use_old_ckb() |
136 | 107 | def wallet_transfer_by_private_key( |
137 | 108 | private_key, |
138 | 109 | to_ckb_address, |
@@ -630,18 +601,30 @@ def tx_add_header_dep(block_hash, tx_file): |
630 | 601 | f.write(tx_info_str) |
631 | 602 |
|
632 | 603 |
|
633 | | -def get_deploy_toml_config(account_private, contract_bin_path, enable_type_id): |
| 604 | +def get_deploy_toml_config( |
| 605 | + account_private, contract_bin_path, enable_type_id, dep_groups_enable_type_id="old" |
| 606 | +): |
634 | 607 | # get account script |
635 | 608 | account = util_key_info_by_private_key(account_private) |
| 609 | + # handle enable_type_id line in dep_groups |
| 610 | + dep_groups_enable_line = "" |
| 611 | + if not ( |
| 612 | + isinstance(dep_groups_enable_type_id, str) |
| 613 | + and dep_groups_enable_type_id.lower() == "old" |
| 614 | + ): |
| 615 | + dep_groups_enable_line = ( |
| 616 | + f"\nenable_type_id = {str(dep_groups_enable_type_id).lower()}" |
| 617 | + ) |
| 618 | + |
636 | 619 | # return format toml |
637 | 620 | return f""" |
638 | | - [[cells]] |
| 621 | +[[cells]] |
639 | 622 | name = "compact_udt_lock" |
640 | 623 | enable_type_id = {str(enable_type_id).lower()} |
641 | 624 | location = {{ file = "{contract_bin_path}" }} |
642 | 625 |
|
643 | 626 | [[dep_groups]] |
644 | | -name = "my_dep_group" |
| 627 | +name = "my_dep_group"{dep_groups_enable_line} |
645 | 628 | cells = [] |
646 | 629 |
|
647 | 630 | [lock] |
|
0 commit comments