Skip to content

Commit

Permalink
Merge pull request #253 from pheuberger/fix-user-controller-safe-api-kit
Browse files Browse the repository at this point in the history
Fix user controller to use custom Safe API Kit instance when interacting with Filecoin networks
  • Loading branch information
bitbeckers authored Feb 12, 2025
2 parents 5488f1b + 13262d5 commit fed67a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/lib/safe/SafeApiKitStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class FilecoinMainnetStrategy implements SafeApiKitStrategy {
createInstance(): SafeApiKit.default {
return new SafeApiKit.default({
chainId: BigInt(314),
txServiceUrl: "https://transaction.safe.filecoin.io/",
txServiceUrl: "https://transaction.safe.filecoin.io/api",
});
}
}
Expand All @@ -17,7 +17,7 @@ export class FilecoinTestnetStrategy implements SafeApiKitStrategy {
createInstance(): SafeApiKit.default {
return new SafeApiKit.default({
chainId: BigInt(314159),
txServiceUrl: "https://transaction-testnet.safe.filecoin.io/",
txServiceUrl: "https://transaction-testnet.safe.filecoin.io/api",
});
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/lib/users/MultisigUpsertStrategy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { z } from "zod";
import SafeApiKit, { type SafeApiKitConfig } from "@safe-global/api-kit";
import SafeApiKit from "@safe-global/api-kit";

import { SignatureRequestPurpose } from "../../graphql/schemas/typeDefs/signatureRequestTypeDefs.js";
import { SupabaseDataService } from "../../services/SupabaseDataService.js";
import { UserResponse } from "../../types/api.js";
import { isTypedMessage } from "../../utils/signatures.js";
import { SafeApiStrategyFactory } from "../safe/SafeApiKitStrategy.js";

import type { UserUpsertStrategy } from "./UserUpsertStrategy.js";
import type { MultisigUpdateRequest } from "./schemas.js";
Expand All @@ -30,17 +31,16 @@ export default class MultisigUpdateStrategy implements UserUpsertStrategy {
private readonly dataService: SupabaseDataService;
// Safe SDKs only support CommonJS, so TS interprets `SafeApiKit` as a namespace.
// https://docs.safe.global/sdk/overview
// Hence the explicit `default` here and on the instantiation further down.
// Hence the explicit `default` here.
private readonly safeApiKit: SafeApiKit.default;

constructor(
private readonly address: string,
private readonly request: MultisigUpdateRequest,
) {
const config: SafeApiKitConfig = {
chainId: BigInt(request.chain_id),
};
this.safeApiKit = new SafeApiKit.default(config);
this.safeApiKit = SafeApiStrategyFactory.getStrategy(
this.request.chain_id,
).createInstance();
this.dataService = new SupabaseDataService();
}

Expand Down

0 comments on commit fed67a6

Please sign in to comment.