@codama/renderers-rust 1.0.21 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.node.cjs +4 -4
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +6 -6
- package/dist/index.node.mjs.map +1 -1
- package/dist/templates/accountsPage.njk +10 -10
- package/dist/templates/errorsPage.njk +3 -3
- package/dist/templates/instructionsCpiPage.njk +23 -23
- package/dist/templates/instructionsCpiPageBuilder.njk +10 -10
- package/dist/templates/instructionsPage.njk +13 -13
- package/dist/templates/instructionsPageBuilder.njk +8 -8
- package/dist/templates/programsMod.njk +1 -1
- package/dist/templates/sharedPage.njk +3 -3
- package/package.json +6 -6
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
{% endif %}
|
|
8
8
|
|
|
9
9
|
{% if account.isSigner === 'either' %}
|
|
10
|
-
{% set type = '(&\'b
|
|
10
|
+
{% set type = '(&\'b solana_account_info::AccountInfo<\'a>, bool)' %}
|
|
11
11
|
{% else %}
|
|
12
|
-
{% set type = '&\'b
|
|
12
|
+
{% set type = '&\'b solana_account_info::AccountInfo<\'a>' %}
|
|
13
13
|
{% endif %}
|
|
14
14
|
|
|
15
15
|
{% if account.isOptional %}
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
/// `{{ instruction.name | snakeCase }}` CPI instruction.
|
|
25
25
|
pub struct {{ instruction.name | pascalCase }}Cpi<'a, 'b> {
|
|
26
26
|
/// The program to invoke.
|
|
27
|
-
pub __program: &'b
|
|
27
|
+
pub __program: &'b solana_account_info::AccountInfo<'a>,
|
|
28
28
|
{% for account in instruction.accounts %}
|
|
29
29
|
{% if account.docs.length > 0 %}
|
|
30
30
|
{{ macros.docblock(account.docs) }}
|
|
31
31
|
{% endif %}
|
|
32
32
|
|
|
33
33
|
{% if account.isSigner === 'either' %}
|
|
34
|
-
{% set type = '(&\'b
|
|
34
|
+
{% set type = '(&\'b solana_account_info::AccountInfo<\'a>, bool)' %}
|
|
35
35
|
{% else %}
|
|
36
|
-
{% set type = '&\'b
|
|
36
|
+
{% set type = '&\'b solana_account_info::AccountInfo<\'a>' %}
|
|
37
37
|
{% endif %}
|
|
38
38
|
|
|
39
39
|
{% if account.isOptional %}
|
|
@@ -50,7 +50,7 @@ pub struct {{ instruction.name | pascalCase }}Cpi<'a, 'b> {
|
|
|
50
50
|
|
|
51
51
|
impl<'a, 'b> {{ instruction.name | pascalCase }}Cpi<'a, 'b> {
|
|
52
52
|
pub fn new(
|
|
53
|
-
program: &'b
|
|
53
|
+
program: &'b solana_account_info::AccountInfo<'a>,
|
|
54
54
|
{% if instruction.accounts.length > 0 %}
|
|
55
55
|
accounts: {{ instruction.name | pascalCase }}CpiAccounts<'a, 'b>,
|
|
56
56
|
{% endif %}
|
|
@@ -69,15 +69,15 @@ impl<'a, 'b> {{ instruction.name | pascalCase }}Cpi<'a, 'b> {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
#[inline(always)]
|
|
72
|
-
pub fn invoke(&self) ->
|
|
72
|
+
pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult {
|
|
73
73
|
self.invoke_signed_with_remaining_accounts(&[], &[])
|
|
74
74
|
}
|
|
75
75
|
#[inline(always)]
|
|
76
|
-
pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b
|
|
76
|
+
pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_entrypoint::ProgramResult {
|
|
77
77
|
self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
|
|
78
78
|
}
|
|
79
79
|
#[inline(always)]
|
|
80
|
-
pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) ->
|
|
80
|
+
pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_entrypoint::ProgramResult {
|
|
81
81
|
self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
|
|
82
82
|
}
|
|
83
83
|
#[allow(clippy::arithmetic_side_effects)]
|
|
@@ -86,32 +86,32 @@ impl<'a, 'b> {{ instruction.name | pascalCase }}Cpi<'a, 'b> {
|
|
|
86
86
|
pub fn invoke_signed_with_remaining_accounts(
|
|
87
87
|
&self,
|
|
88
88
|
signers_seeds: &[&[&[u8]]],
|
|
89
|
-
remaining_accounts: &[(&'b
|
|
90
|
-
) ->
|
|
89
|
+
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]
|
|
90
|
+
) -> solana_program_entrypoint::ProgramResult {
|
|
91
91
|
let mut accounts = Vec::with_capacity({{ instruction.accounts.length + '+' if instruction.accounts.length > 0}} remaining_accounts.len());
|
|
92
92
|
{% for account in instruction.accounts %}
|
|
93
93
|
{% if account.isSigner === 'either' %}
|
|
94
94
|
{% if account.isOptional and instruction.optionalAccountStrategy === 'programId' %}
|
|
95
95
|
if let Some(({{ account.name | snakeCase }}, signer)) = self.{{ account.name | snakeCase }} {
|
|
96
|
-
accounts.push(
|
|
96
|
+
accounts.push(solana_instruction::AccountMeta::{{ 'new' if account.isWritable else 'new_readonly' }}(
|
|
97
97
|
*{{ account.name | snakeCase }}.key,
|
|
98
98
|
signer,
|
|
99
99
|
));
|
|
100
100
|
} else {
|
|
101
|
-
accounts.push(
|
|
101
|
+
accounts.push(solana_instruction::AccountMeta::new_readonly(
|
|
102
102
|
crate::{{ program.name | snakeCase | upper }}_ID,
|
|
103
103
|
false,
|
|
104
104
|
));
|
|
105
105
|
}
|
|
106
106
|
{% elif account.isOptional %}
|
|
107
107
|
if let Some(({{ account.name | snakeCase }}, signer)) = self.{{ account.name | snakeCase }} {
|
|
108
|
-
accounts.push(
|
|
108
|
+
accounts.push(solana_instruction::AccountMeta::{{ 'new' if account.isWritable else 'new_readonly' }}(
|
|
109
109
|
*{{ account.name | snakeCase }}.key,
|
|
110
110
|
signer,
|
|
111
111
|
));
|
|
112
112
|
}
|
|
113
113
|
{% else %}
|
|
114
|
-
accounts.push(
|
|
114
|
+
accounts.push(solana_instruction::AccountMeta::{{ 'new' if account.isWritable else 'new_readonly' }}(
|
|
115
115
|
*self.{{ account.name | snakeCase }}.0.key,
|
|
116
116
|
self.{{ account.name | snakeCase }}.1,
|
|
117
117
|
));
|
|
@@ -119,25 +119,25 @@ impl<'a, 'b> {{ instruction.name | pascalCase }}Cpi<'a, 'b> {
|
|
|
119
119
|
{% else %}
|
|
120
120
|
{% if account.isOptional and instruction.optionalAccountStrategy === 'programId' %}
|
|
121
121
|
if let Some({{ account.name | snakeCase }}) = self.{{ account.name | snakeCase }} {
|
|
122
|
-
accounts.push(
|
|
122
|
+
accounts.push(solana_instruction::AccountMeta::{{ 'new' if account.isWritable else 'new_readonly' }}(
|
|
123
123
|
*{{ account.name | snakeCase }}.key,
|
|
124
124
|
{{ 'true' if account.isSigner else 'false' }},
|
|
125
125
|
));
|
|
126
126
|
} else {
|
|
127
|
-
accounts.push(
|
|
127
|
+
accounts.push(solana_instruction::AccountMeta::new_readonly(
|
|
128
128
|
crate::{{ program.name | snakeCase | upper }}_ID,
|
|
129
129
|
false,
|
|
130
130
|
));
|
|
131
131
|
}
|
|
132
132
|
{% elif account.isOptional %}
|
|
133
133
|
if let Some({{ account.name | snakeCase }}) = self.{{ account.name | snakeCase }} {
|
|
134
|
-
accounts.push(
|
|
134
|
+
accounts.push(solana_instruction::AccountMeta::{{ 'new' if account.isWritable else 'new_readonly' }}(
|
|
135
135
|
*{{ account.name | snakeCase }}.key,
|
|
136
136
|
{{ 'true' if account.isSigner else 'false' }},
|
|
137
137
|
));
|
|
138
138
|
}
|
|
139
139
|
{% else %}
|
|
140
|
-
accounts.push(
|
|
140
|
+
accounts.push(solana_instruction::AccountMeta::{{ 'new' if account.isWritable else 'new_readonly' }}(
|
|
141
141
|
*self.{{ account.name | snakeCase }}.key,
|
|
142
142
|
{{ 'true' if account.isSigner else 'false' }}
|
|
143
143
|
));
|
|
@@ -145,7 +145,7 @@ impl<'a, 'b> {{ instruction.name | pascalCase }}Cpi<'a, 'b> {
|
|
|
145
145
|
{% endif %}
|
|
146
146
|
{% endfor %}
|
|
147
147
|
remaining_accounts.iter().for_each(|remaining_account| {
|
|
148
|
-
accounts.push(
|
|
148
|
+
accounts.push(solana_instruction::AccountMeta {
|
|
149
149
|
pubkey: *remaining_account.0.key,
|
|
150
150
|
is_signer: remaining_account.1,
|
|
151
151
|
is_writable: remaining_account.2,
|
|
@@ -157,7 +157,7 @@ impl<'a, 'b> {{ instruction.name | pascalCase }}Cpi<'a, 'b> {
|
|
|
157
157
|
data.append(&mut args);
|
|
158
158
|
{% endif %}
|
|
159
159
|
|
|
160
|
-
let instruction =
|
|
160
|
+
let instruction = solana_instruction::Instruction {
|
|
161
161
|
program_id: crate::{{ program.name | snakeCase | upper }}_ID,
|
|
162
162
|
accounts,
|
|
163
163
|
data,
|
|
@@ -176,9 +176,9 @@ impl<'a, 'b> {{ instruction.name | pascalCase }}Cpi<'a, 'b> {
|
|
|
176
176
|
remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
|
|
177
177
|
|
|
178
178
|
if signers_seeds.is_empty() {
|
|
179
|
-
|
|
179
|
+
solana_cpi::invoke(&instruction, &account_infos)
|
|
180
180
|
} else {
|
|
181
|
-
|
|
181
|
+
solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
}
|
|
@@ -21,7 +21,7 @@ pub struct {{ instruction.name | pascalCase }}CpiBuilder<'a, 'b> {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
impl<'a, 'b> {{ instruction.name | pascalCase }}CpiBuilder<'a, 'b> {
|
|
24
|
-
pub fn new(program: &'b
|
|
24
|
+
pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
|
|
25
25
|
let instruction = Box::new({{ instruction.name | pascalCase }}CpiBuilderInstruction {
|
|
26
26
|
__program: program,
|
|
27
27
|
{% for account in instruction.accounts %}
|
|
@@ -40,7 +40,7 @@ impl<'a, 'b> {{ instruction.name | pascalCase }}CpiBuilder<'a, 'b> {
|
|
|
40
40
|
{{'/// `[optional account]`\n' if account.isOptional }}
|
|
41
41
|
{{- macros.docblock(account.docs) -}}
|
|
42
42
|
#[inline(always)]
|
|
43
|
-
pub fn {{ account.name | snakeCase }}(&mut self, {{ account.name | snakeCase }}: {{ "Option<&'b
|
|
43
|
+
pub fn {{ account.name | snakeCase }}(&mut self, {{ account.name | snakeCase }}: {{ "Option<&'b solana_account_info::AccountInfo<'a>>" if account.isOptional else "&'b solana_account_info::AccountInfo<'a>" }}{{ ', as_signer: bool' if account.isSigner === 'either' }}) -> &mut Self {
|
|
44
44
|
{% if account.isOptional %}
|
|
45
45
|
{% if account.isSigner === 'either' %}
|
|
46
46
|
if let Some({{ account.name | snakeCase }}) = {{ account.name | snakeCase }} {
|
|
@@ -75,7 +75,7 @@ impl<'a, 'b> {{ instruction.name | pascalCase }}CpiBuilder<'a, 'b> {
|
|
|
75
75
|
{% endfor %}
|
|
76
76
|
/// Add an additional account to the instruction.
|
|
77
77
|
#[inline(always)]
|
|
78
|
-
pub fn add_remaining_account(&mut self, account: &'b
|
|
78
|
+
pub fn add_remaining_account(&mut self, account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
|
|
79
79
|
self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
|
|
80
80
|
self
|
|
81
81
|
}
|
|
@@ -84,17 +84,17 @@ impl<'a, 'b> {{ instruction.name | pascalCase }}CpiBuilder<'a, 'b> {
|
|
|
84
84
|
/// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
|
|
85
85
|
/// and a `bool` indicating whether the account is a signer or not.
|
|
86
86
|
#[inline(always)]
|
|
87
|
-
pub fn add_remaining_accounts(&mut self, accounts: &[(&'b
|
|
87
|
+
pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
|
|
88
88
|
self.instruction.__remaining_accounts.extend_from_slice(accounts);
|
|
89
89
|
self
|
|
90
90
|
}
|
|
91
91
|
#[inline(always)]
|
|
92
|
-
pub fn invoke(&self) ->
|
|
92
|
+
pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult {
|
|
93
93
|
self.invoke_signed(&[])
|
|
94
94
|
}
|
|
95
95
|
#[allow(clippy::clone_on_copy)]
|
|
96
96
|
#[allow(clippy::vec_init_then_push)]
|
|
97
|
-
pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) ->
|
|
97
|
+
pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_entrypoint::ProgramResult {
|
|
98
98
|
{% if hasArgs %}
|
|
99
99
|
let args = {{ instruction.name | pascalCase }}InstructionArgs {
|
|
100
100
|
{% for arg in instructionArgs %}
|
|
@@ -127,12 +127,12 @@ impl<'a, 'b> {{ instruction.name | pascalCase }}CpiBuilder<'a, 'b> {
|
|
|
127
127
|
|
|
128
128
|
#[derive(Clone, Debug)]
|
|
129
129
|
struct {{ instruction.name | pascalCase }}CpiBuilderInstruction<'a, 'b> {
|
|
130
|
-
__program: &'b
|
|
130
|
+
__program: &'b solana_account_info::AccountInfo<'a>,
|
|
131
131
|
{% for account in instruction.accounts %}
|
|
132
132
|
{% if account.isSigner === 'either' %}
|
|
133
|
-
{{ account.name | snakeCase }}: Option<(&'b
|
|
133
|
+
{{ account.name | snakeCase }}: Option<(&'b solana_account_info::AccountInfo<'a>, bool)>,
|
|
134
134
|
{% else %}
|
|
135
|
-
{{ account.name | snakeCase }}: Option<&'b
|
|
135
|
+
{{ account.name | snakeCase }}: Option<&'b solana_account_info::AccountInfo<'a>>,
|
|
136
136
|
{% endif %}
|
|
137
137
|
{% endfor %}
|
|
138
138
|
{% for arg in instructionArgs %}
|
|
@@ -141,5 +141,5 @@ struct {{ instruction.name | pascalCase }}CpiBuilderInstruction<'a, 'b> {
|
|
|
141
141
|
{% endif %}
|
|
142
142
|
{% endfor %}
|
|
143
143
|
/// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
|
|
144
|
-
__remaining_accounts: Vec<(&'b
|
|
144
|
+
__remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
|
|
145
145
|
}
|
|
@@ -14,9 +14,9 @@ pub struct {{ instruction.name | pascalCase }} {
|
|
|
14
14
|
{% endif %}
|
|
15
15
|
|
|
16
16
|
{% if account.isSigner === 'either' %}
|
|
17
|
-
{% set type = '(
|
|
17
|
+
{% set type = '(solana_pubkey::Pubkey, bool)' %}
|
|
18
18
|
{% else %}
|
|
19
|
-
{% set type = '
|
|
19
|
+
{% set type = 'solana_pubkey::Pubkey' %}
|
|
20
20
|
{% endif %}
|
|
21
21
|
|
|
22
22
|
{% if account.isOptional %}
|
|
@@ -28,38 +28,38 @@ pub struct {{ instruction.name | pascalCase }} {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
impl {{ instruction.name | pascalCase }} {
|
|
31
|
-
pub fn instruction(&self{{ ', args: ' + instruction.name | pascalCase + 'InstructionArgs' if hasArgs }}) ->
|
|
31
|
+
pub fn instruction(&self{{ ', args: ' + instruction.name | pascalCase + 'InstructionArgs' if hasArgs }}) -> solana_instruction::Instruction {
|
|
32
32
|
self.instruction_with_remaining_accounts({{ 'args, ' if hasArgs }}&[])
|
|
33
33
|
}
|
|
34
34
|
#[allow(clippy::arithmetic_side_effects)]
|
|
35
35
|
#[allow(clippy::vec_init_then_push)]
|
|
36
|
-
pub fn instruction_with_remaining_accounts(&self{{ ', args: ' + instruction.name | pascalCase + 'InstructionArgs' if hasArgs }}, remaining_accounts: &[
|
|
36
|
+
pub fn instruction_with_remaining_accounts(&self{{ ', args: ' + instruction.name | pascalCase + 'InstructionArgs' if hasArgs }}, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
|
|
37
37
|
let mut accounts = Vec::with_capacity({{ instruction.accounts.length + '+' if instruction.accounts.length > 0}} remaining_accounts.len());
|
|
38
38
|
{% for account in instruction.accounts %}
|
|
39
39
|
{% if account.isSigner === 'either' %}
|
|
40
40
|
{% if account.isOptional %}
|
|
41
41
|
{% if instruction.optionalAccountStrategy === 'programId' %}
|
|
42
42
|
if let Some(({{ account.name | snakeCase }}, signer)) = self.{{ account.name | snakeCase }} {
|
|
43
|
-
accounts.push(
|
|
43
|
+
accounts.push(solana_instruction::AccountMeta::{{ 'new' if account.isWritable else 'new_readonly' }}(
|
|
44
44
|
{{ account.name | snakeCase }},
|
|
45
45
|
signer,
|
|
46
46
|
));
|
|
47
47
|
} else {
|
|
48
|
-
accounts.push(
|
|
48
|
+
accounts.push(solana_instruction::AccountMeta::new_readonly(
|
|
49
49
|
crate::{{ program.name | snakeCase | upper }}_ID,
|
|
50
50
|
false,
|
|
51
51
|
));
|
|
52
52
|
}
|
|
53
53
|
{% else %}
|
|
54
54
|
if let Some(({{ account.name | snakeCase }}, signer)) = self.{{ account.name | snakeCase }} {
|
|
55
|
-
accounts.push(
|
|
55
|
+
accounts.push(solana_instruction::AccountMeta::{{ 'new' if account.isWritable else 'new_readonly' }}(
|
|
56
56
|
{{ account.name | snakeCase }},
|
|
57
57
|
signer,
|
|
58
58
|
));
|
|
59
59
|
}
|
|
60
60
|
{% endif %}
|
|
61
61
|
{% else %}
|
|
62
|
-
accounts.push(
|
|
62
|
+
accounts.push(solana_instruction::AccountMeta::{{ 'new' if account.isWritable else 'new_readonly' }}(
|
|
63
63
|
self.{{ account.name | snakeCase }}.0,
|
|
64
64
|
self.{{ account.name | snakeCase }}.1,
|
|
65
65
|
));
|
|
@@ -68,26 +68,26 @@ impl {{ instruction.name | pascalCase }} {
|
|
|
68
68
|
{% if account.isOptional %}
|
|
69
69
|
{% if instruction.optionalAccountStrategy === 'programId' %}
|
|
70
70
|
if let Some({{ account.name | snakeCase }}) = self.{{ account.name | snakeCase }} {
|
|
71
|
-
accounts.push(
|
|
71
|
+
accounts.push(solana_instruction::AccountMeta::{{ 'new' if account.isWritable else 'new_readonly' }}(
|
|
72
72
|
{{ account.name | snakeCase }},
|
|
73
73
|
{{ 'true' if account.isSigner else 'false' }},
|
|
74
74
|
));
|
|
75
75
|
} else {
|
|
76
|
-
accounts.push(
|
|
76
|
+
accounts.push(solana_instruction::AccountMeta::new_readonly(
|
|
77
77
|
crate::{{ program.name | snakeCase | upper }}_ID,
|
|
78
78
|
false,
|
|
79
79
|
));
|
|
80
80
|
}
|
|
81
81
|
{% elif account.isOptional %}
|
|
82
82
|
if let Some({{ account.name | snakeCase }}) = self.{{ account.name | snakeCase }} {
|
|
83
|
-
accounts.push(
|
|
83
|
+
accounts.push(solana_instruction::AccountMeta::{{ 'new' if account.isWritable else 'new_readonly' }}(
|
|
84
84
|
{{ account.name | snakeCase }},
|
|
85
85
|
{{ 'true' if account.isSigner else 'false' }},
|
|
86
86
|
));
|
|
87
87
|
}
|
|
88
88
|
{% endif %}
|
|
89
89
|
{% else %}
|
|
90
|
-
accounts.push(
|
|
90
|
+
accounts.push(solana_instruction::AccountMeta::{{ 'new' if account.isWritable else 'new_readonly' }}(
|
|
91
91
|
self.{{ account.name | snakeCase }},
|
|
92
92
|
{{ 'true' if account.isSigner else 'false' }}
|
|
93
93
|
));
|
|
@@ -101,7 +101,7 @@ impl {{ instruction.name | pascalCase }} {
|
|
|
101
101
|
data.append(&mut args);
|
|
102
102
|
{% endif %}
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
solana_instruction::Instruction {
|
|
105
105
|
program_id: crate::{{ program.name | snakeCase | upper }}_ID,
|
|
106
106
|
accounts,
|
|
107
107
|
data,
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
pub struct {{ instruction.name | pascalCase }}Builder {
|
|
21
21
|
{% for account in instruction.accounts %}
|
|
22
22
|
{% if account.isSigner === 'either' %}
|
|
23
|
-
{{ account.name | snakeCase }}: Option<(
|
|
23
|
+
{{ account.name | snakeCase }}: Option<(solana_pubkey::Pubkey, bool)>,
|
|
24
24
|
{% else %}
|
|
25
|
-
{{ account.name | snakeCase }}: Option<
|
|
25
|
+
{{ account.name | snakeCase }}: Option<solana_pubkey::Pubkey>,
|
|
26
26
|
{% endif %}
|
|
27
27
|
{% endfor %}
|
|
28
28
|
{% for arg in instructionArgs %}
|
|
@@ -30,7 +30,7 @@ pub struct {{ instruction.name | pascalCase }}Builder {
|
|
|
30
30
|
{{ arg.name | snakeCase }}: {{ arg.type if arg.innerOptionType else 'Option<' + arg.type + '>' }},
|
|
31
31
|
{% endif %}
|
|
32
32
|
{% endfor %}
|
|
33
|
-
__remaining_accounts: Vec<
|
|
33
|
+
__remaining_accounts: Vec<solana_instruction::AccountMeta>,
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
impl {{ instruction.name | pascalCase }}Builder {
|
|
@@ -45,7 +45,7 @@ impl {{ instruction.name | pascalCase }}Builder {
|
|
|
45
45
|
{% endif %}
|
|
46
46
|
{{- macros.docblock(account.docs) -}}
|
|
47
47
|
#[inline(always)]
|
|
48
|
-
pub fn {{ account.name | snakeCase }}(&mut self, {{ account.name | snakeCase }}: {{ 'Option<
|
|
48
|
+
pub fn {{ account.name | snakeCase }}(&mut self, {{ account.name | snakeCase }}: {{ 'Option<solana_pubkey::Pubkey>' if account.isOptional else 'solana_pubkey::Pubkey' }}{{ ', as_signer: bool' if account.isSigner === 'either' }}) -> &mut Self {
|
|
49
49
|
{% if account.isOptional %}
|
|
50
50
|
{% if account.isSigner === 'either' %}
|
|
51
51
|
if let Some({{ account.name | snakeCase }}) = {{ account.name | snakeCase }} {
|
|
@@ -80,18 +80,18 @@ impl {{ instruction.name | pascalCase }}Builder {
|
|
|
80
80
|
{% endfor %}
|
|
81
81
|
/// Add an additional account to the instruction.
|
|
82
82
|
#[inline(always)]
|
|
83
|
-
pub fn add_remaining_account(&mut self, account:
|
|
83
|
+
pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
|
|
84
84
|
self.__remaining_accounts.push(account);
|
|
85
85
|
self
|
|
86
86
|
}
|
|
87
87
|
/// Add additional accounts to the instruction.
|
|
88
88
|
#[inline(always)]
|
|
89
|
-
pub fn add_remaining_accounts(&mut self, accounts: &[
|
|
89
|
+
pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &mut Self {
|
|
90
90
|
self.__remaining_accounts.extend_from_slice(accounts);
|
|
91
91
|
self
|
|
92
92
|
}
|
|
93
93
|
#[allow(clippy::clone_on_copy)]
|
|
94
|
-
pub fn instruction(&self) ->
|
|
94
|
+
pub fn instruction(&self) -> solana_instruction::Instruction {
|
|
95
95
|
let accounts = {{ instruction.name | pascalCase }} {
|
|
96
96
|
{% for account in instruction.accounts %}
|
|
97
97
|
{% if account.isOptional %}
|
|
@@ -99,7 +99,7 @@ impl {{ instruction.name | pascalCase }}Builder {
|
|
|
99
99
|
{% elif account.defaultValue.kind === 'programId' %}
|
|
100
100
|
{{ account.name | snakeCase }}: self.{{ account.name | snakeCase }}, {# Program ID set on the instruction creation. #}
|
|
101
101
|
{% elif account.defaultValue.kind === 'publicKeyValueNode' %}
|
|
102
|
-
{{ account.name | snakeCase }}: self.{{ account.name | snakeCase }}.unwrap_or(
|
|
102
|
+
{{ account.name | snakeCase }}: self.{{ account.name | snakeCase }}.unwrap_or(solana_pubkey::pubkey!("{{ account.defaultValue.publicKey }}")),
|
|
103
103
|
{% else %}
|
|
104
104
|
{{ account.name | snakeCase }}: self.{{ account.name | snakeCase }}.expect("{{ account.name | snakeCase }} is not set"),
|
|
105
105
|
{% endif %}
|
|
@@ -16,8 +16,8 @@ For now, we just define them here. This the following caveat:
|
|
|
16
16
|
#[cfg(feature = "fetch")]
|
|
17
17
|
#[derive(Debug, Clone)]
|
|
18
18
|
pub struct DecodedAccount<T> {
|
|
19
|
-
pub address:
|
|
20
|
-
pub account:
|
|
19
|
+
pub address: solana_pubkey::Pubkey,
|
|
20
|
+
pub account: solana_account::Account,
|
|
21
21
|
pub data: T,
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -25,7 +25,7 @@ For now, we just define them here. This the following caveat:
|
|
|
25
25
|
#[derive(Debug, Clone)]
|
|
26
26
|
pub enum MaybeAccount<T> {
|
|
27
27
|
Exists(DecodedAccount<T>),
|
|
28
|
-
NotFound(
|
|
28
|
+
NotFound(solana_pubkey::Pubkey),
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
{% endif %}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codama/renderers-rust",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Renders Rust clients for your programs",
|
|
5
5
|
"exports": {
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@solana/codecs-strings": "rc",
|
|
32
32
|
"nunjucks": "^3.2.4",
|
|
33
|
-
"@codama/errors": "1.
|
|
34
|
-
"@codama/nodes": "1.
|
|
35
|
-
"@codama/renderers-core": "1.0.
|
|
36
|
-
"@codama/visitors-core": "1.
|
|
33
|
+
"@codama/errors": "1.3.0",
|
|
34
|
+
"@codama/nodes": "1.3.0",
|
|
35
|
+
"@codama/renderers-core": "1.0.16",
|
|
36
|
+
"@codama/visitors-core": "1.3.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/nunjucks": "^3.2.6",
|
|
40
|
-
"@codama/nodes-from-anchor": "1.1
|
|
40
|
+
"@codama/nodes-from-anchor": "1.2.1"
|
|
41
41
|
},
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"repository": {
|