Skip to content

Commit

Permalink
use binary proto encoded format
Browse files Browse the repository at this point in the history
  • Loading branch information
TalDerei committed Aug 20, 2024
1 parent c55e674 commit dd814ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Binary file added apps/extension/public/penumbra-1-genesis.bin
Binary file not shown.
10 changes: 6 additions & 4 deletions packages/context/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import { FullViewingKey, WalletId } from '@penumbra-zone/protobuf/penumbra/core/
import { ChainRegistryClient } from '@penumbra-labs/registry';
import { AppParameters } from '@penumbra-zone/protobuf/penumbra/core/app/v1/app_pb';
import { AssetId } from '@penumbra-zone/protobuf/penumbra/core/asset/v1/asset_pb';
import Penumbra1Genesis from './penumbra-1-genesis.json';
import { CompactBlock } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/compact_block/v1/compact_block_pb';
import { JsonObject } from '@bufbuild/protobuf';

export interface ServicesConfig {
readonly chainId: string;
Expand All @@ -22,7 +20,7 @@ export interface ServicesConfig {
export class Services implements ServicesInterface {
private walletServicesPromise: Promise<WalletServices> | undefined;

constructor(private config: ServicesConfig) {}
constructor(private config: ServicesConfig) { }

// If getWalletServices() is called multiple times concurrently, they'll all
// wait for the same promise rather than each starting their own
Expand Down Expand Up @@ -106,10 +104,14 @@ export class Services implements ServicesInterface {
idbConstants: indexedDb.constants(),
});

// Dynamically fetch binary file for genesis compact block
const response = await fetch('./penumbra-1-genesis.bin');
const genesisBinaryData = await response.arrayBuffer();

const blockProcessor = new BlockProcessor({
genesisBlock:
chainId === 'penumbra-1'
? CompactBlock.fromJson(Penumbra1Genesis as JsonObject)
? CompactBlock.fromBinary(new Uint8Array(genesisBinaryData))
: undefined,
viewServer,
querier,
Expand Down

0 comments on commit dd814ae

Please sign in to comment.