-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename ByteDiscriminatorNode to ConstantDiscriminatorNode and use Con…
…stantValueNode (#203)
- Loading branch information
1 parent
a56e919
commit 484da01
Showing
15 changed files
with
150 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@metaplex-foundation/kinobi": minor | ||
--- | ||
|
||
Rename ByteDiscriminatorNode to ConstantDiscriminatorNode and use ConstantValueNode |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ConstantValueNode } from '../valueNodes'; | ||
|
||
export interface ConstantDiscriminatorNode< | ||
TConstant extends ConstantValueNode = ConstantValueNode, | ||
> { | ||
readonly kind: 'constantDiscriminatorNode'; | ||
|
||
// Children. | ||
readonly constant: TConstant; | ||
|
||
// Data. | ||
readonly offset: number; | ||
} | ||
|
||
export function constantDiscriminatorNode<TConstant extends ConstantValueNode>( | ||
constant: TConstant, | ||
offset: number = 0 | ||
): ConstantDiscriminatorNode { | ||
return { kind: 'constantDiscriminatorNode', constant, offset }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export * from './ByteDiscriminatorNode'; | ||
export * from './ConstantDiscriminatorNode'; | ||
export * from './DiscriminatorNode'; | ||
export * from './FieldDiscriminatorNode'; | ||
export * from './SizeDiscriminatorNode'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
test/visitors/nodes/discriminatorNodes/ByteDiscriminatorNode.test.ts
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
test/visitors/nodes/discriminatorNodes/ConstantDiscriminatorNode.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import test from 'ava'; | ||
import { | ||
constantDiscriminatorNode, | ||
constantValueNodeFromBytes, | ||
} from '../../../../src'; | ||
import { | ||
deleteNodesVisitorMacro, | ||
getDebugStringVisitorMacro, | ||
identityVisitorMacro, | ||
mergeVisitorMacro, | ||
} from '../_setup'; | ||
|
||
const node = constantDiscriminatorNode( | ||
constantValueNodeFromBytes('base16', '01020304'), | ||
42 | ||
); | ||
|
||
test(mergeVisitorMacro, node, 4); | ||
test(identityVisitorMacro, node); | ||
test(deleteNodesVisitorMacro, node, '[constantDiscriminatorNode]', null); | ||
test(deleteNodesVisitorMacro, node, '[constantValueNode]', null); | ||
test( | ||
getDebugStringVisitorMacro, | ||
node, | ||
` | ||
constantDiscriminatorNode [offset:42] | ||
| constantValueNode | ||
| | bytesTypeNode | ||
| | bytesValueNode [base16.01020304]` | ||
); |