This repository was archived by the owner on Apr 3, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -9,16 +9,21 @@ export class AptosPriceServiceConnection extends PriceServiceConnection {
9
9
* @param priceIds Array of hex-encoded price ids.
10
10
* @returns Array of price update data, serialized such that it can be passed to the Pyth Aptos contract.
11
11
*/
12
- async getPriceFeedsUpdateData ( priceIds : HexString [ ] ) : Promise < Uint8Array > {
12
+ async getPriceFeedsUpdateData ( priceIds : HexString [ ] ) : Promise < number [ ] [ ] > {
13
13
// Fetch the latest price feed update VAAs from the price service
14
14
const latestVaas = await this . getLatestVaas ( priceIds ) ;
15
+ return latestVaas . map ( ( vaa ) => Array . from ( Buffer . from ( vaa , "base64" ) ) ) ;
16
+ }
15
17
16
- // Serialize the VAAs using BCS
18
+ /**
19
+ * Serializes the given updateData using BCS. Browser wallets typically automatically
20
+ * serialize the data, but this function can be used to manually serialize the update data
21
+ * if necessary.
22
+ */
23
+ static serializeUpdateData ( updateData : number [ ] [ ] ) : Uint8Array {
17
24
const serializer = new BCS . Serializer ( ) ;
18
- serializer . serializeU32AsUleb128 ( latestVaas . length ) ;
19
- latestVaas . forEach ( ( vaa ) =>
20
- serializer . serializeBytes ( Buffer . from ( vaa , "base64" ) )
21
- ) ;
25
+ serializer . serializeU32AsUleb128 ( updateData . length ) ;
26
+ updateData . forEach ( ( vaa ) => serializer . serializeBytes ( Buffer . from ( vaa ) ) ) ;
22
27
return serializer . getBytes ( ) ;
23
28
}
24
29
}
You can’t perform that action at this time.
0 commit comments