@@ -62,7 +62,7 @@ export class StarknetPriceFeedContract extends PriceFeedContract {
62
62
return sources . map ( ( source ) => {
63
63
return {
64
64
emitterChain : Number ( source . emitter_chain_id ) ,
65
- emitterAddress : source . emitter_address . toString ( 16 ) ,
65
+ emitterAddress : source . emitter_address . toString ( 16 ) . padStart ( 64 , "0" ) ,
66
66
} ;
67
67
} ) ;
68
68
}
@@ -82,7 +82,7 @@ export class StarknetPriceFeedContract extends PriceFeedContract {
82
82
async getFeeTokenAddresses ( ) : Promise < string [ ] > {
83
83
const contract = await this . getContractClient ( ) ;
84
84
const tokens : bigint [ ] = await contract . fee_token_addresses ( ) ;
85
- return tokens . map ( ( t ) => t . toString ( 16 ) ) ;
85
+ return tokens . map ( ( t ) => t . toString ( 16 ) . padStart ( 64 , "0" ) ) ;
86
86
}
87
87
88
88
/**
@@ -126,21 +126,7 @@ export class StarknetPriceFeedContract extends PriceFeedContract {
126
126
senderPrivateKey : PrivateKey ,
127
127
vaas : Buffer [ ]
128
128
) : Promise < TxResult > {
129
- // We need the account address to send transactions.
130
- throw new Error ( "Use executeUpdatePriceFeedWithAddress instead" ) ;
131
- }
132
-
133
- /**
134
- * Executes the update instructions contained in the VAAs using the sender credentials
135
- * @param senderPrivateKey private key of the sender in hex format without 0x prefix
136
- * @param senderAddress address of the sender's account in hex format without 0x prefix
137
- * @param vaa VAA containing price update messages to execute
138
- */
139
- async executeUpdatePriceFeedWithAddress (
140
- senderPrivateKey : PrivateKey ,
141
- senderAddress : string ,
142
- vaa : Buffer
143
- ) : Promise < TxResult > {
129
+ const senderAddress = await this . chain . getAccountAddress ( senderPrivateKey ) ;
144
130
const provider = this . chain . getProvider ( ) ;
145
131
const contract = await this . getContractClient ( ) ;
146
132
const account = new Account (
@@ -155,35 +141,27 @@ export class StarknetPriceFeedContract extends PriceFeedContract {
155
141
const tokenContract = new Contract ( tokenClassData . abi , feeToken , provider ) ;
156
142
tokenContract . connect ( account ) ;
157
143
158
- const updateData = ByteBuffer . fromBuffer ( vaa ) ;
159
- const feeAmount = await contract . get_update_fee ( updateData , feeToken ) ;
160
- const feeTx = await tokenContract . approve ( this . address , feeAmount ) ;
161
- await provider . waitForTransaction ( feeTx . transaction_hash ) ;
162
-
163
- const tx = await contract . update_price_feeds ( updateData ) ;
164
- const info = await provider . waitForTransaction ( tx . transaction_hash ) ;
165
- return { id : tx . transaction_hash , info } ;
166
- }
167
-
168
- executeGovernanceInstruction (
169
- senderPrivateKey : PrivateKey ,
170
- vaa : Buffer
171
- ) : Promise < TxResult > {
172
- // We need the account address to send transactions.
173
- throw new Error ( "Use executeGovernanceInstructionWithAddress instead" ) ;
144
+ const ids = [ ] ;
145
+ const infos = [ ] ;
146
+ for ( const vaa of vaas ) {
147
+ const updateData = ByteBuffer . fromBuffer ( vaa ) ;
148
+ const feeAmount = await contract . get_update_fee ( updateData , feeToken ) ;
149
+ const feeTx = await tokenContract . approve ( this . address , feeAmount ) ;
150
+ await provider . waitForTransaction ( feeTx . transaction_hash ) ;
151
+
152
+ const tx = await contract . update_price_feeds ( updateData ) ;
153
+ const info = await provider . waitForTransaction ( tx . transaction_hash ) ;
154
+ ids . push ( tx . transaction_hash ) ;
155
+ infos . push ( info ) ;
156
+ }
157
+ return { id : ids . join ( "," ) , info : infos } ;
174
158
}
175
159
176
- /**
177
- * Executes the governance instruction contained in the VAA using the sender credentials
178
- * @param senderPrivateKey private key of the sender in hex format without 0x prefix
179
- * @param senderAddress address of the sender's account in hex format without 0x prefix
180
- * @param vaa the VAA to execute
181
- */
182
- async executeGovernanceInstructionWithAddress (
160
+ async executeGovernanceInstruction (
183
161
senderPrivateKey : PrivateKey ,
184
- senderAddress : string ,
185
162
vaa : Buffer
186
163
) : Promise < TxResult > {
164
+ const senderAddress = await this . chain . getAccountAddress ( senderPrivateKey ) ;
187
165
const provider = this . chain . getProvider ( ) ;
188
166
const contract = await this . getContractClient ( ) ;
189
167
const account = new Account (
@@ -205,7 +183,7 @@ export class StarknetPriceFeedContract extends PriceFeedContract {
205
183
await contract . governance_data_source ( ) ;
206
184
return {
207
185
emitterChain : Number ( source . emitter_chain_id ) ,
208
- emitterAddress : source . emitter_address . toString ( 16 ) ,
186
+ emitterAddress : source . emitter_address . toString ( 16 ) . padStart ( 64 , "0" ) ,
209
187
} ;
210
188
}
211
189
0 commit comments