File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed
Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change 11import SafeApiKit from "@safe-global/api-kit" ;
22
3+ import { SafeApiStrategyFactory } from "../lib/safe/SafeApiKitStrategy.js" ;
34import { SupabaseDataService } from "../services/SupabaseDataService.js" ;
45import { ISafeApiCommand } from "../types/safe-signatures.js" ;
56
@@ -15,7 +16,8 @@ export abstract class SafeApiCommand implements ISafeApiCommand {
1516 this . messageHash = messageHash ;
1617 this . chainId = chainId ;
1718 this . dataService = new SupabaseDataService ( ) ;
18- this . safeApiKit = new SafeApiKit . default ( { chainId : BigInt ( chainId ) } ) ;
19+ this . safeApiKit =
20+ SafeApiStrategyFactory . getStrategy ( chainId ) . createInstance ( ) ;
1921 }
2022
2123 abstract execute ( ) : Promise < void > ;
Original file line number Diff line number Diff line change 1+ import SafeApiKit from "@safe-global/api-kit" ;
2+
3+ export interface SafeApiKitStrategy {
4+ createInstance ( ) : SafeApiKit . default ;
5+ }
6+
7+ export class FilecoinMainnetStrategy implements SafeApiKitStrategy {
8+ createInstance ( ) : SafeApiKit . default {
9+ return new SafeApiKit . default ( {
10+ chainId : BigInt ( 314 ) ,
11+ txServiceUrl : "https://transaction.safe.filecoin.io/" ,
12+ } ) ;
13+ }
14+ }
15+
16+ export class FilecoinTestnetStrategy implements SafeApiKitStrategy {
17+ createInstance ( ) : SafeApiKit . default {
18+ return new SafeApiKit . default ( {
19+ chainId : BigInt ( 314159 ) ,
20+ txServiceUrl : "https://transaction-testnet.safe.filecoin.io/" ,
21+ } ) ;
22+ }
23+ }
24+
25+ export class DefaultSafeApiStrategy implements SafeApiKitStrategy {
26+ constructor ( private chainId : number ) { }
27+
28+ createInstance ( ) : SafeApiKit . default {
29+ return new SafeApiKit . default ( {
30+ chainId : BigInt ( this . chainId ) ,
31+ } ) ;
32+ }
33+ }
34+
35+ export class SafeApiStrategyFactory {
36+ static getStrategy ( chainId : number ) : SafeApiKitStrategy {
37+ switch ( chainId ) {
38+ case 314 :
39+ return new FilecoinMainnetStrategy ( ) ;
40+ case 314159 :
41+ return new FilecoinTestnetStrategy ( ) ;
42+ default :
43+ return new DefaultSafeApiStrategy ( chainId ) ;
44+ }
45+ }
46+ }
You can’t perform that action at this time.
0 commit comments