-
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.
Add InstructionRemainingAccountsNode (#134)
* Add InstructionRemainingAccountsNode * Update js renderer templates * Add changeset
- Loading branch information
1 parent
9432c41
commit 9439055
Showing
16 changed files
with
148 additions
and
65 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 | ||
--- | ||
|
||
Add InstructionRemainingAccountsNode |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { ArgumentValueNode, ResolverValueNode } from './contextualValueNodes'; | ||
|
||
export type InstructionRemainingAccountsNode = { | ||
readonly kind: 'instructionRemainingAccountsNode'; | ||
|
||
// Children. | ||
readonly value: ArgumentValueNode | ResolverValueNode; | ||
|
||
// Data. | ||
readonly isWritable?: boolean; | ||
readonly isSigner?: boolean | 'either'; | ||
}; | ||
|
||
export type InstructionRemainingAccountsNodeInput = Omit< | ||
InstructionRemainingAccountsNode, | ||
'kind' | ||
>; | ||
|
||
export function instructionRemainingAccountsNode( | ||
value: ArgumentValueNode | ResolverValueNode, | ||
options: { | ||
isWritable?: boolean; | ||
isSigner?: boolean | 'either'; | ||
} = {} | ||
): InstructionRemainingAccountsNode { | ||
return { | ||
kind: 'instructionRemainingAccountsNode', | ||
value, | ||
isWritable: options.isWritable, | ||
isSigner: options.isSigner, | ||
}; | ||
} |
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
9 changes: 4 additions & 5 deletions
9
src/renderers/js-experimental/fragments/instructionRemainingAccounts.njk
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,6 +1,5 @@ | ||
// Remaining accounts. | ||
{% if remainingAccounts.kind === 'arg' %} | ||
const remainingAccounts: IAccountMeta[] = args.{{ remainingAccounts.name | camelCase }}.map((address) => ({ address, role: {{ "AccountRole.WRITABLE" if remainingAccounts.isWritable else "AccountRole.READONLY" }} })); | ||
{% elif remainingAccounts.kind === 'resolver' %} | ||
const remainingAccounts: IAccountMeta[] = {{ awaitKeyword }}{{ nameApi.resolverFunction(remainingAccounts.name) }}(resolverScope); | ||
{% if remainingAccounts.value.kind === 'argumentValueNode' %} | ||
args.{{ remainingAccounts.value.name | camelCase }}.map((address) => ({ address, role: {{ "AccountRole.WRITABLE" if remainingAccounts.isWritable else "AccountRole.READONLY" }} })) | ||
{% elif remainingAccounts.value.kind === 'resolverValueNode' %} | ||
{{ awaitKeyword }}{{ nameApi.resolverFunction(remainingAccounts.value.name) }}(resolverScope) | ||
{% endif %} |
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
8 changes: 4 additions & 4 deletions
8
src/renderers/js/templates/instructionsPageRemainingAccounts.njk
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,9 +1,9 @@ | ||
{% if instruction.remainingAccounts.kind === 'arg' %} | ||
{% if remainingAccounts.value.kind === 'argumentValueNode' %} | ||
// Remaining Accounts. | ||
const remainingAccounts = resolvedArgs.{{ instruction.remainingAccounts.name | camelCase }}.map((value, index) => ({ index, value, isWritable: {{ "true" if instruction.remainingAccounts.isWritable else "false" }} })); | ||
const remainingAccounts = resolvedArgs.{{ remainingAccounts.value.name | camelCase }}.map((value, index) => ({ index, value, isWritable: {{ "true" if remainingAccounts.isWritable else "false" }} })); | ||
orderedAccounts.push(...remainingAccounts); | ||
{% elif instruction.remainingAccounts.kind === 'resolver' %} | ||
{% elif remainingAccounts.value.kind === 'resolverValueNode' %} | ||
// Remaining Accounts. | ||
const remainingAccounts = {{ instruction.remainingAccounts.name | camelCase }}(context, resolvedAccounts, resolvedArgs, programId); | ||
const remainingAccounts = {{ remainingAccounts.value.name | camelCase }}(context, resolvedAccounts, resolvedArgs, programId); | ||
orderedAccounts.push(...remainingAccounts); | ||
{% endif %} |
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
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