@@ -59,55 +59,6 @@ static bool valid_writable_account( SolParameters *prm,
59
59
is_rent_exempt ( * ka -> lamports , ka -> data_len );
60
60
}
61
61
62
- static uint64_t add_price ( SolParameters * prm , SolAccountInfo * ka )
63
- {
64
- // Validate command parameters
65
- cmd_add_price_t * cptr = (cmd_add_price_t * )prm -> data ;
66
- if ( prm -> data_len != sizeof ( cmd_add_price_t ) ||
67
- cptr -> expo_ > PC_MAX_NUM_DECIMALS ||
68
- cptr -> expo_ < - PC_MAX_NUM_DECIMALS ||
69
- cptr -> ptype_ == PC_PTYPE_UNKNOWN ) {
70
- return ERROR_INVALID_ARGUMENT ;
71
- }
72
-
73
- // Account (1) is the product account that we're going to add to
74
- // Account (2) is the new price account
75
- // Verify that these are signed, writable accounts with correct ownership
76
- // and size
77
- if ( prm -> ka_num != 3 ||
78
- !valid_funding_account ( & ka [0 ] ) ||
79
- !valid_signable_account ( prm , & ka [1 ], PC_PROD_ACC_SIZE ) ||
80
- !valid_signable_account ( prm , & ka [2 ], sizeof ( pc_price_t ) ) ) {
81
- return ERROR_INVALID_ARGUMENT ;
82
- }
83
-
84
- // Verify that the product account is valid
85
- // and that the new price account is uninitialized
86
- pc_prod_t * pptr = (pc_prod_t * )ka [1 ].data ;
87
- pc_price_t * sptr = (pc_price_t * )ka [2 ].data ;
88
- if ( pptr -> magic_ != PC_MAGIC ||
89
- pptr -> ver_ != cptr -> ver_ ||
90
- pptr -> type_ != PC_ACCTYPE_PRODUCT ||
91
- sptr -> magic_ != 0 ) {
92
- return ERROR_INVALID_ARGUMENT ;
93
- }
94
-
95
- // Initialize symbol account
96
- sol_memset ( sptr , 0 , sizeof ( pc_price_t ) );
97
- sptr -> magic_ = PC_MAGIC ;
98
- sptr -> ver_ = cptr -> ver_ ;
99
- sptr -> type_ = PC_ACCTYPE_PRICE ;
100
- sptr -> size_ = sizeof ( pc_price_t ) - sizeof ( sptr -> comp_ );
101
- sptr -> expo_ = cptr -> expo_ ;
102
- sptr -> ptype_ = cptr -> ptype_ ;
103
- pc_pub_key_assign ( & sptr -> prod_ , (pc_pub_key_t * )ka [1 ].key );
104
-
105
- // bind price account to product account
106
- pc_pub_key_assign ( & sptr -> next_ , & pptr -> px_acc_ );
107
- pc_pub_key_assign ( & pptr -> px_acc_ , (pc_pub_key_t * )ka [2 ].key );
108
- return SUCCESS ;
109
- }
110
-
111
62
static uint64_t init_price ( SolParameters * prm , SolAccountInfo * ka )
112
63
{
113
64
// Validate command parameters
@@ -156,53 +107,6 @@ static uint64_t init_price( SolParameters *prm, SolAccountInfo *ka )
156
107
return SUCCESS ;
157
108
}
158
109
159
- static uint64_t add_publisher ( SolParameters * prm , SolAccountInfo * ka )
160
- {
161
- // Validate command parameters
162
- cmd_add_publisher_t * cptr = (cmd_add_publisher_t * )prm -> data ;
163
- if ( prm -> data_len != sizeof ( cmd_add_publisher_t ) ||
164
- pc_pub_key_is_zero ( & cptr -> pub_ ) ) {
165
- return ERROR_INVALID_ARGUMENT ;
166
- }
167
-
168
- // Account (1) is the price account
169
- // Verify that this is signed, writable with correct ownership
170
- // and size
171
- if ( prm -> ka_num != 2 ||
172
- !valid_funding_account ( & ka [0 ] ) ||
173
- !valid_signable_account ( prm , & ka [1 ], sizeof ( pc_price_t ) ) ) {
174
- return ERROR_INVALID_ARGUMENT ;
175
- }
176
-
177
- // Verify that symbol account is initialized and corresponds to the
178
- // same symbol and price-type in the instruction parameters
179
- pc_price_t * sptr = (pc_price_t * )ka [1 ].data ;
180
- if ( sptr -> magic_ != PC_MAGIC ||
181
- sptr -> ver_ != cptr -> ver_ ||
182
- sptr -> type_ != PC_ACCTYPE_PRICE ) {
183
- return ERROR_INVALID_ARGUMENT ;
184
- }
185
-
186
- // try to add publisher
187
- for (uint32_t i = 0 ; i != sptr -> num_ ; ++ i ) {
188
- pc_price_comp_t * iptr = & sptr -> comp_ [i ];
189
- if ( pc_pub_key_equal ( & iptr -> pub_ , & cptr -> pub_ ) ) {
190
- return ERROR_INVALID_ARGUMENT ;
191
- }
192
- }
193
- if ( sptr -> num_ >= PC_COMP_SIZE ) {
194
- return ERROR_INVALID_ARGUMENT ;
195
- }
196
- pc_price_comp_t * iptr = & sptr -> comp_ [sptr -> num_ ++ ];
197
- sol_memset ( iptr , 0 , sizeof ( pc_price_comp_t ) );
198
- pc_pub_key_assign ( & iptr -> pub_ , & cptr -> pub_ );
199
-
200
- // update size of account
201
- sptr -> size_ = sizeof ( pc_price_t ) - sizeof ( sptr -> comp_ ) +
202
- sptr -> num_ * sizeof ( pc_price_comp_t );
203
- return SUCCESS ;
204
- }
205
-
206
110
// remove publisher from price node
207
111
static uint64_t del_publisher ( SolParameters * prm , SolAccountInfo * ka )
208
112
{
@@ -353,8 +257,8 @@ static uint64_t dispatch( SolParameters *prm, SolAccountInfo *ka )
353
257
case e_cmd_add_mapping : return ERROR_INVALID_ARGUMENT ;
354
258
case e_cmd_add_product : return ERROR_INVALID_ARGUMENT ;
355
259
case e_cmd_upd_product : return ERROR_INVALID_ARGUMENT ;
356
- case e_cmd_add_price : return add_price ( prm , ka ) ;
357
- case e_cmd_add_publisher : return add_publisher ( prm , ka ) ;
260
+ case e_cmd_add_price : return ERROR_INVALID_ARGUMENT ;
261
+ case e_cmd_add_publisher : return ERROR_INVALID_ARGUMENT ;
358
262
case e_cmd_del_publisher : return del_publisher ( prm , ka );
359
263
case e_cmd_init_price : return init_price ( prm , ka );
360
264
case e_cmd_init_test : return ERROR_INVALID_ARGUMENT ;
0 commit comments