Skip to content

Commit

Permalink
Merge branch 'master' into crystalin-package-npm
Browse files Browse the repository at this point in the history
  • Loading branch information
crystalin authored Nov 8, 2024
2 parents 9d28377 + c155768 commit bd00367
Show file tree
Hide file tree
Showing 5 changed files with 481 additions and 35 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/publish-typescript-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,20 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 20.10.0
cache: pnpm
registry-url: https://registry.npmjs.org/
- name: Build Typescript Augment API package
run: |
cd typescript-api
pnpm i
pnpm i --frozen-lockfile
pnpm build
- name: Publish typescript API
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
package: typescript-api/package.json
dry-run: ${{ github.event.inputs.DryRun }}
run: |
cd typescript-api
if [ "${{ github.event.inputs.DryRun }}" == "true" ]; then
pnpm publish --access public --no-git-checks --dry-run
else
pnpm publish --access public --no-git-checks
fi
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
23 changes: 19 additions & 4 deletions node/service/src/lazy_loading/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,22 @@ impl<Block: BlockT + DeserializeOwned> Blockchain<Block> {
pub fn id(&self, id: BlockId<Block>) -> Option<Block::Hash> {
match id {
BlockId::Hash(h) => Some(h),
BlockId::Number(n) => self.storage.read().hashes.get(&n).cloned(),
BlockId::Number(n) => {
let block_hash = self.storage.read().hashes.get(&n).cloned();
match block_hash {
None => {
let block_hash =
self.rpc_client.block_hash::<Block>(Some(n)).ok().flatten();

block_hash.clone().map(|h| {
self.storage.write().hashes.insert(n, h);
});

block_hash
}
block_hash => block_hash,
}
}
}
}

Expand Down Expand Up @@ -1506,17 +1521,17 @@ impl RPC {

pub fn block_hash<Block: BlockT + DeserializeOwned>(
&self,
block_number: Option<BlockNumber>,
block_number: Option<<Block::Header as HeaderT>::Number>,
) -> Result<Option<Block::Hash>, jsonrpsee::core::ClientError> {
let request = &|| {
substrate_rpc_client::ChainApi::<
BlockNumber,
<Block::Header as HeaderT>::Number,
Block::Hash,
Block::Header,
SignedBlock<Block>,
>::block_hash(
&self.http_client,
block_number.map(|n| ListOrValue::Value(NumberOrHex::Number(n.into()))),
block_number.map(|n| ListOrValue::Value(NumberOrHex::Hex(n.into()))),
)
};

Expand Down
2 changes: 1 addition & 1 deletion node/service/src/lazy_loading/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn produce_genesis_block<TBl: BlockT + sp_runtime::DeserializeOwned>(

let genesis_block_hash: TBl::Hash = backend
.rpc_client
.block_hash::<TBl>(Some(0))
.block_hash::<TBl>(Some(Default::default()))
.unwrap()
.expect("Not able to obtain genesis block hash");

Expand Down
Loading

0 comments on commit bd00367

Please sign in to comment.