File tree Expand file tree Collapse file tree 4 files changed +63
-0
lines changed
Expand file tree Collapse file tree 4 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ interface UpdatePFTask {
2424
2525/**
2626 * Class to update multiple redstone price feeds at once
27+ * TODO: historical updates....
28+ * TODO: warp time on testnets
2729 */
2830export class RedstoneUpdater extends SDKConstruct {
2931 #logger?: ILogger ;
Original file line number Diff line number Diff line change 1+ import type { TransactionReceipt } from "viem" ;
2+
3+ import type { CreditAccountData } from "../base" ;
4+ import type { NetworkType } from "../chain" ;
5+
6+ export type EtherscanURLParam =
7+ | { block : number }
8+ | { tx : string }
9+ | { address : string } ;
10+
11+ export function etherscanUrl (
12+ entity : EtherscanURLParam | TransactionReceipt | CreditAccountData ,
13+ network : NetworkType ,
14+ ) : string {
15+ let [ prefix , domain ] = [ "" , "etherscan.io" ] ;
16+
17+ let param : EtherscanURLParam ;
18+ if ( "transactionHash" in entity && "blockHash" in entity ) {
19+ param = { tx : entity . transactionHash } ;
20+ } else if ( "creditAccount" in entity && "creditManager" in entity ) {
21+ param = { address : entity . creditAccount } ;
22+ } else {
23+ param = entity ;
24+ }
25+
26+ switch ( network ) {
27+ case "Optimism" :
28+ prefix = "optimistic." ;
29+ break ;
30+ case "Arbitrum" :
31+ domain = "arbiscan.io" ;
32+ break ;
33+ case "Base" :
34+ domain = "basescan.org" ;
35+ break ;
36+ }
37+ const [ key , value ] = Object . entries ( param ) [ 0 ] ;
38+ return `https://${ prefix } ${ domain } /${ key } /${ value } ` ;
39+ }
Original file line number Diff line number Diff line change 1+ import type { Address } from "viem" ;
2+
3+ import type { CreditAccountData } from "../base" ;
4+
5+ /**
6+ * Helper function to filter out low-balance assets
7+ * @param account
8+ * @returns
9+ */
10+ export function filterDust (
11+ account : CreditAccountData ,
12+ ) : Record < Address , bigint > {
13+ const result : Record < Address , bigint > = { } ;
14+ for ( const { token, balance } of account . tokens ) {
15+ if ( balance > 10n ) {
16+ result [ token ] = balance ;
17+ }
18+ }
19+ return result ;
20+ }
Original file line number Diff line number Diff line change @@ -2,5 +2,7 @@ export * from "./AddressMap";
22export * from "./bytes32ToString" ;
33export * from "./childLogger" ;
44export * from "./createRawTx" ;
5+ export * from "./etherscan" ;
6+ export * from "./filterDust" ;
57export * from "./formatter" ;
68export * from "./json" ;
You can’t perform that action at this time.
0 commit comments