You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add status and statusMessage to InstructionNode (#936)
* feat: add status and statusMessage to InstructionNode
* feat: integrate InstructionStatusNode into InstructionNode and update related types
* fix: correct function name in InstructionStatusNode documentation
* refactor: rename instructionStatus to instructionStatusNode in documentation and tests
* rename `InstructionStatusNode.status` to `lifecycle`
* refactor: rename InstructionStatusNode field from status to lifecycle and simplify API signature
* refactor: rename `InstructionStatus` to `InstructionLifecycle`
* remove extraneous empty lines
* fixed style
* update changeset description
Copy file name to clipboardExpand all lines: packages/nodes/docs/InstructionNode.md
+44-1Lines changed: 44 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,7 @@ This node represents an instruction in a program.
25
25
|`remainingAccounts`|[`InstructionRemainingAccountsNode`](./InstructionRemainingAccountsNode.md)[]| (Optional) The list of dynamic remaining accounts requirements for the instruction. For instance, an instruction may have a variable number of signers at the end of the accounts list. |
26
26
|`byteDeltas`|[`InstructionByteDeltaNode`](./InstructionByteDeltaNode.md)[]| (Optional) The list of byte variations that the instruction causes. They should all be added together unless the `subtract` attribute is used. |
27
27
|`discriminators`|[`DiscriminatorNode`](./DiscriminatorNode.md)[]| (Optional) The nodes that distinguish this instruction from others in the program. If multiple discriminators are provided, they are combined using a logical AND operation. |
28
+
|`status`|[`InstructionStatusNode`](./InstructionStatusNode.md)| (Optional) The status of the instruction and an optional message about that status. |
28
29
|`subInstructions`|[`InstructionNode`](./InstructionNode.md)[]| (Optional) A list of nested instructions should this instruction be split into multiple sub-instructions to define distinct scenarios. |
29
30
30
31
## Functions
@@ -121,7 +122,7 @@ instructionNode({
121
122
});
122
123
```
123
124
124
-
### An instruction with nested versionned instructions
125
+
### An instruction with nested versioned instructions
125
126
126
127
```ts
127
128
instructionNode({
@@ -167,3 +168,45 @@ instructionNode({
167
168
],
168
169
});
169
170
```
171
+
172
+
### A deprecated instruction
173
+
174
+
```ts
175
+
instructionNode({
176
+
name: 'oldIncrement',
177
+
status: instructionStatusNode(
178
+
'deprecated',
179
+
'Use the `increment` instruction instead. This will be removed in v3.0.0.',
|`kind`|`"instructionStatusNode"`| The node discriminator. |
12
+
|`lifecycle`|`"live"`\|`"deprecated"`\|`"archived"`\|`"draft"`| The lifecycle status of the instruction. `"live"` means accessible (the default), `"deprecated"` means about to be archived, `"archived"` means no longer accessible but kept for historical parsing, `"draft"` means not fully implemented yet. |
13
+
|`message`|`string`| (Optional) Additional information about the current status for program consumers. |
14
+
15
+
## Functions
16
+
17
+
### `instructionStatusNode(lifecycle, message?)`
18
+
19
+
Helper function that creates an `InstructionStatusNode` object.
20
+
21
+
```ts
22
+
const statusNode =instructionStatusNode('deprecated', 'Use the newInstruction instead');
23
+
```
24
+
25
+
## Examples
26
+
27
+
### A live instruction (no status needed)
28
+
29
+
For live instructions, you typically don't need to set a status at all:
30
+
31
+
```ts
32
+
instructionNode({
33
+
name: 'transfer',
34
+
accounts: [...],
35
+
arguments: [...],
36
+
});
37
+
```
38
+
39
+
### A deprecated instruction
40
+
41
+
```ts
42
+
instructionNode({
43
+
name: 'oldTransfer',
44
+
status: instructionStatusNode('deprecated', 'Use the `transfer` instruction instead. This will be removed in v3.0.0.'),
45
+
accounts: [...],
46
+
arguments: [...],
47
+
});
48
+
```
49
+
50
+
### An archived instruction
51
+
52
+
```ts
53
+
instructionNode({
54
+
name: 'legacyTransfer',
55
+
status: instructionStatusNode('archived', 'This instruction was removed in v2.0.0. It is kept here for historical parsing.'),
56
+
accounts: [...],
57
+
arguments: [...],
58
+
});
59
+
```
60
+
61
+
### A draft instruction
62
+
63
+
```ts
64
+
instructionNode({
65
+
name: 'experimentalFeature',
66
+
status: instructionStatusNode('draft', 'This instruction is under development and may change.'),
0 commit comments