Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix user controller to use custom Safe API Kit instance when interacting with Filecoin networks #253

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading