subsquid / squid-sdk

The main repo of the squid SDK
GNU General Public License v3.0
1.21k stars 147 forks source link

AddFireblocksWeb3ProviderSupport #305

Open HelmiTrabelsi opened 2 months ago

HelmiTrabelsi commented 2 months ago

As we are paying for Fireblocks services, including the Fireblocks Web3 provider, we want to use this service in the indexer to avoid paying for another Web3 provider. However, we could not use it because squid-SDK only supports RPC URLs.

These changes allow the use of Fireblocks as a Web3 infrastructure provider in the Squid-SDK by making changes to the rpc-client and evm-processor packages. This update also facilitates using any other Web3 infrastructure provider that doesn't support RPC URLs.

belopash commented 2 months ago

This is not needed. Fireblocks SDK uses axios with regular urls under the hood.

What you need to do is to pass baseUrl to the url property and add X-API-Key header with an api key to the headers.

HelmiTrabelsi commented 2 months ago

According to the Fireblocks SDK documentation (https://developers.fireblocks.com/reference/signing-a-request-jwt-structure) we need base url, X-API-Key, JWT. We tried to add this to our setRpcEndpoint but got 401 error.

new EvmBatchProcessor().setRpcEndpoint({
    url: 'https://api.fireblocks.io/v1',
    rateLimit: 10,
    headers: {
      'X-API-Key': 'XXXXXXXXXXXXXXX',
      'Authorization': 'Bearer JWT'
  })
belopash commented 2 months ago

@HelmiTrabelsi just to make sure, does fireblocks support rpc methods other than those releted to transactions signing? e.g eth_blockNumber

Initially I checked the wrong package, but from the provider package you are importing, it looks like they are requested bypassing fireblocks sdk class and authorization for those methods are not needed at all, except some optional Authorization header formed from the creds in a url itself https://github.com/fireblocks/fireblocks-web3-provider/blob/c0ee722f103548b26ef1317bf00f660d962cc603/src/provider.ts#L337 https://github.com/fireblocks/fireblocks-web3-provider/blob/c0ee722f103548b26ef1317bf00f660d962cc603/src/provider.ts#L75