Skip to content

Commit

Permalink
fix: network explorer url
Browse files Browse the repository at this point in the history
  • Loading branch information
hhio618 committed Jan 9, 2025
1 parent 3142bf1 commit 82b5ae5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/parser/payment-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { BaseModule } from "../types/module";
import { Result } from "../types/results";
import { isAdmin, isCollaborative } from "../helpers/checkers";
import { getFundingWalletBalance, transferFromFundingWallet } from "../helpers/web3";
import { getNetworkExplorer, NetworkId } from "@ubiquity-dao/rpc-handler";

interface Payload {
evmNetworkId: number;
Expand All @@ -44,6 +45,7 @@ export class PaymentModule extends BaseModule {
readonly _supabase = createClient<Database>(this.context.env.SUPABASE_URL, this.context.env.SUPABASE_KEY);

async transform(data: Readonly<IssueActivity>, result: Result): Promise<Result> {
const networkExplorer = await this._getNetworkExplorer(this._evmNetworkId);
const canMakePayment = await this._canMakePayment(data);
const privateKey = await this._getPrivateKey(this._evmPrivateEncrypted);
if (!canMakePayment) {
Expand Down Expand Up @@ -154,7 +156,7 @@ export class PaymentModule extends BaseModule {
key,
value.total.toString()
);
result[key].explorerUrl = `https://gnosisscan.io/tx/${tx.hash}`;
result[key].explorerUrl = `${networkExplorer}/tx/${tx.hash}`;
} else {
try {
const permits = await generatePayoutPermit(
Expand Down Expand Up @@ -197,6 +199,14 @@ export class PaymentModule extends BaseModule {
return sumPayouts;
}

async _getNetworkExplorer(networkId: number) {
const networkExplorer = getNetworkExplorer(String(networkId) as NetworkId);
if (!networkExplorer) {
return "https://blockscan.com";
}
return networkExplorer[0].url;
}

async _canMakePayment(data: Readonly<IssueActivity>) {
if (!data.self?.closed_by || !data.self.user) return false;

Expand Down

0 comments on commit 82b5ae5

Please sign in to comment.