Skip to content

Commit

Permalink
Refactor VisitArgs class to use StatusType enum for status handling
Browse files Browse the repository at this point in the history
  • Loading branch information
b3hr4d committed May 8, 2024
1 parent 85df932 commit 18ec452
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 127 deletions.
4 changes: 2 additions & 2 deletions packages/visitor/src/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export enum Status {
}

export enum StatusType {
Checked = 1 << 2,
Optional = 1 << 3,
Checked = 1 << 6,
Optional = 1 << 7,
}

export class StatusHelper {
Expand Down
78 changes: 39 additions & 39 deletions packages/visitor/test/candid-detail.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
"__status": 2,
"certificate": {
"__label": "certificate",
"__status": 10,
"__status": 130,
"optional": {
"__status": 9,
"__status": 129,
"__label": "certificate",
"vector": {
"__label": "certificate",
Expand All @@ -61,7 +61,7 @@
}
},
"blocks": {
"__status": 9,
"__status": 129,
"__label": "blocks",
"vector": {
"__label": "blocks",
Expand All @@ -75,9 +75,9 @@
},
"icrc1_memo": {
"__label": "icrc1_memo",
"__status": 10,
"__status": 130,
"optional": {
"__status": 9,
"__status": 129,
"__label": "icrc1_memo",
"vector": {
"__label": "icrc1_memo",
Expand All @@ -87,7 +87,7 @@
},
"operation": {
"__label": "operation",
"__status": 10,
"__status": 130,
"optional": {
"__label": "operation",
"__status": 1,
Expand All @@ -103,7 +103,7 @@
}
},
"from": {
"__status": 9,
"__status": 129,
"__label": "from",
"vector": {
"__label": "from",
Expand All @@ -124,7 +124,7 @@
},
"expected_allowance": {
"__label": "expected_allowance",
"__status": 10,
"__status": 130,
"optional": {
"__label": "expected_allowance",
"__status": 1,
Expand All @@ -136,7 +136,7 @@
},
"expires_at": {
"__label": "expires_at",
"__status": 10,
"__status": 130,
"optional": {
"__label": "expires_at",
"__status": 1,
Expand All @@ -147,7 +147,7 @@
}
},
"spender": {
"__status": 9,
"__status": 129,
"__label": "spender",
"vector": {
"__label": "spender",
Expand All @@ -159,7 +159,7 @@
"__label": "Burn",
"__status": 1,
"from": {
"__status": 9,
"__status": 129,
"__label": "from",
"vector": {
"__label": "from",
Expand All @@ -176,9 +176,9 @@
},
"spender": {
"__label": "spender",
"__status": 10,
"__status": 130,
"optional": {
"__status": 9,
"__status": 129,
"__label": "spender",
"vector": {
"__label": "spender",
Expand All @@ -191,7 +191,7 @@
"__label": "Mint",
"__status": 1,
"to": {
"__status": 9,
"__status": 129,
"__label": "to",
"vector": {
"__label": "to",
Expand All @@ -211,7 +211,7 @@
"__label": "Transfer",
"__status": 1,
"to": {
"__status": 9,
"__status": 129,
"__label": "to",
"vector": {
"__label": "to",
Expand All @@ -227,7 +227,7 @@
}
},
"from": {
"__status": 9,
"__status": 129,
"__label": "from",
"vector": {
"__label": "from",
Expand All @@ -244,9 +244,9 @@
},
"spender": {
"__label": "spender",
"__status": 10,
"__status": 130,
"optional": {
"__status": 9,
"__status": 129,
"__label": "spender",
"vector": {
"__label": "spender",
Expand Down Expand Up @@ -276,9 +276,9 @@
},
"parent_hash": {
"__label": "parent_hash",
"__status": 10,
"__status": 130,
"optional": {
"__status": 9,
"__status": 129,
"__label": "parent_hash",
"vector": {
"__label": "parent_hash",
Expand All @@ -297,7 +297,7 @@
"__status": 1
},
"archived_blocks": {
"__status": 9,
"__status": 129,
"__label": "archived_blocks",
"vector": {
"__label": "archived_blocks",
Expand All @@ -315,7 +315,7 @@
"__label": "Ok",
"__status": 1,
"blocks": {
"__status": 9,
"__status": 129,
"__label": "blocks",
"vector": {
"__label": "blocks",
Expand All @@ -329,9 +329,9 @@
},
"icrc1_memo": {
"__label": "icrc1_memo",
"__status": 10,
"__status": 130,
"optional": {
"__status": 9,
"__status": 129,
"__label": "icrc1_memo",
"vector": {
"__label": "icrc1_memo",
Expand All @@ -341,7 +341,7 @@
},
"operation": {
"__label": "operation",
"__status": 10,
"__status": 130,
"optional": {
"__label": "operation",
"__status": 1,
Expand All @@ -357,7 +357,7 @@
}
},
"from": {
"__status": 9,
"__status": 129,
"__label": "from",
"vector": {
"__label": "from",
Expand All @@ -378,7 +378,7 @@
},
"expected_allowance": {
"__label": "expected_allowance",
"__status": 10,
"__status": 130,
"optional": {
"__label": "expected_allowance",
"__status": 1,
Expand All @@ -390,7 +390,7 @@
},
"expires_at": {
"__label": "expires_at",
"__status": 10,
"__status": 130,
"optional": {
"__label": "expires_at",
"__status": 1,
Expand All @@ -401,7 +401,7 @@
}
},
"spender": {
"__status": 9,
"__status": 129,
"__label": "spender",
"vector": {
"__label": "spender",
Expand All @@ -413,7 +413,7 @@
"__label": "Burn",
"__status": 1,
"from": {
"__status": 9,
"__status": 129,
"__label": "from",
"vector": {
"__label": "from",
Expand All @@ -430,9 +430,9 @@
},
"spender": {
"__label": "spender",
"__status": 10,
"__status": 130,
"optional": {
"__status": 9,
"__status": 129,
"__label": "spender",
"vector": {
"__label": "spender",
Expand All @@ -445,7 +445,7 @@
"__label": "Mint",
"__status": 1,
"to": {
"__status": 9,
"__status": 129,
"__label": "to",
"vector": {
"__label": "to",
Expand All @@ -465,7 +465,7 @@
"__label": "Transfer",
"__status": 1,
"to": {
"__status": 9,
"__status": 129,
"__label": "to",
"vector": {
"__label": "to",
Expand All @@ -481,7 +481,7 @@
}
},
"from": {
"__status": 9,
"__status": 129,
"__label": "from",
"vector": {
"__label": "from",
Expand All @@ -498,9 +498,9 @@
},
"spender": {
"__label": "spender",
"__status": 10,
"__status": 130,
"optional": {
"__status": 9,
"__status": 129,
"__label": "spender",
"vector": {
"__label": "spender",
Expand Down Expand Up @@ -530,9 +530,9 @@
},
"parent_hash": {
"__label": "parent_hash",
"__status": 10,
"__status": 130,
"optional": {
"__status": 9,
"__status": 129,
"__label": "parent_hash",
"vector": {
"__label": "parent_hash",
Expand Down
64 changes: 33 additions & 31 deletions packages/visitor/test/status-loop-new.txt
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
Status:
1: Visible
2: Checked
4: Hidden
8: Optional
16: newOption
2: Hidden
Visible: 1
Checked: 2
Hidden: 4
Hidden: 2
4: Checked
8: Optional
16: NewOption
Checked: 4
Optional: 8
newOption: 16
NewOption: 16
-----
0:
1: Visible
2: Checked
3: Checked Visible
4: Hidden
5: Hidden Visible
2: Hidden
3: Hidden Visible
4: Checked
5: Checked Visible
6: Hidden Checked
7: Hidden Checked Visible
8: Optional
9: Visible Optional
10: Checked Optional
11: Checked Visible Optional
12: Hidden Optional
13: Hidden Visible Optional
10: Hidden Optional
11: Hidden Visible Optional
12: Checked Optional
13: Checked Visible Optional
14: Hidden Checked Optional
15: Hidden Checked Visible Optional
16: newOption
17: Visible newOption
18: Checked newOption
19: Checked Visible newOption
20: Hidden newOption
21: Hidden Visible newOption
22: Hidden Checked newOption
23: Hidden Checked Visible newOption
24: Optional newOption
25: Visible Optional newOption
26: Checked Optional newOption
27: Checked Visible Optional newOption
28: Hidden Optional newOption
29: Hidden Visible Optional newOption
30: Hidden Checked Optional newOption
31: Hidden Checked Visible Optional newOption
16: NewOption
17: Visible NewOption
18: Hidden NewOption
19: Hidden Visible NewOption
20: Checked NewOption
21: Checked Visible NewOption
22: Hidden Checked NewOption
23: Hidden Checked Visible NewOption
24: Optional NewOption
25: Visible Optional NewOption
26: Hidden Optional NewOption
27: Hidden Visible Optional NewOption
28: Checked Optional NewOption
29: Checked Visible Optional NewOption
30: Hidden Checked Optional NewOption
31: Hidden Checked Visible Optional NewOption
Loading

0 comments on commit 18ec452

Please sign in to comment.