-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adding chain sync service * adding ws transport to viem commenting out alchemy and sign module co-dependencies commenting out atomic nonces moving BalanceService token loading to onApplicationBootstrap * getting the ChainSync service to work refactored websocket inetent service to use viem subscription on websocket connection instead of the ethers alchemy ws adding provers array to the sourceIntents config modifying everywhere we handle addresses to use viems getAddress instead of toLowercase * adding tests for chain sync service updating the abi contracts * add prover to intent
- Loading branch information
Showing
29 changed files
with
677 additions
and
384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { chains } from '@alchemy/aa-core' | ||
import { http, HttpTransport, webSocket, WebSocketTransport } from 'viem' | ||
|
||
/** | ||
* Merges the two strings into a valid api url | ||
* @param rpc the rpc endpoint | ||
* @param apiKey the alchemy api key | ||
* @returns | ||
*/ | ||
export function getAchemyRPCUrl( | ||
chain: chains.Chain, | ||
apiKey: string, | ||
websocketEnabled: boolean = true, | ||
): string { | ||
const url = | ||
websocketEnabled && chain.rpcUrls.alchemy.webSocket | ||
? chain.rpcUrls.alchemy.webSocket[0] | ||
: chain.rpcUrls.alchemy.http[0] | ||
return url + '/' + apiKey | ||
} | ||
|
||
/** | ||
* Returns a transport for the chain with the given api key | ||
* | ||
* @param chain the chain to get the transport for | ||
* @param apiKey the alchemy api key | ||
* @param websocketEnabled whether to use websocket or not, defaults to true | ||
* @returns the websocket or http transport | ||
*/ | ||
export function getTransport( | ||
chain: chains.Chain, | ||
apiKey: string, | ||
websocketEnabled: boolean = true, | ||
): WebSocketTransport | HttpTransport { | ||
const url = getAchemyRPCUrl(chain, apiKey, websocketEnabled) | ||
return websocketEnabled ? webSocket(url) : http(url) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.