• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Mintbase / mintbase-js / 3802521708

pending completion
3802521708

push

github

Ruben Marcus
fix method imports

182 of 258 branches covered (70.54%)

Branch coverage included in aggregate %.

456 of 501 relevant lines covered (91.02%)

3.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.81
/packages/rpc/src/methods/txnstatus.ts
1
import { requestFromNearRpc } from '../util';
1✔
2

3
export type TxnStatus = 'pending' | 'success' | 'failure';
4

5
export const getTxnStatus = async (
1✔
6
  txnHash: string,
7
  senderId: string,
8
): Promise<TxnStatus> => {
3✔
9
  const res = await requestFromNearRpc({
3✔
10
    jsonrpc: '2.0',
11
    id: 'dontcare',
12
    method: 'tx',
13
    params: [txnHash, senderId],
14
  });
15
  if (res?.error) {
3!
16
    throw res.error;
×
17
  }
18

19
  let failure = false;
3✔
20
  let pending = false;
3✔
21
  if (!(res.result?.receipts_outcome instanceof Array)) {
3!
22
    throw new Error(`Malformed response: ${JSON.stringify(res)}`);
×
23
  }
24
  res.result?.receipts_outcome?.forEach((outcome: any) => {
3!
25
    if (!outcome?.outcome?.status) {
4!
26
      throw new Error(`Malformed response: ${JSON.stringify(res)}`);
×
27
    }
28
    if (outcome.outcome.status.Unknown) {
4!
29
      pending = true;
×
30
    }
31
    if (outcome.outcome.status.Failure) {
4✔
32
      failure = true;
1✔
33
    }
34
  });
35
  if (failure) {
3✔
36
    return 'failure';
1✔
37
  }
38
  if (pending) {
2!
39
    return 'pending';
×
40
  }
41
  return 'success';
2✔
42
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc