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

Mintbase / mintbase-js / 7929488522

16 Feb 2024 10:48AM UTC coverage: 77.204%. First build
7929488522

Pull #476

github

rubenmarcus
fix attributes by contract
Pull Request #476: fix attributes by contract

839 of 1269 branches covered (66.12%)

Branch coverage included in aggregate %.

1149 of 1306 relevant lines covered (87.98%)

12.91 hits per line

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

71.67
/packages/rpc/src/methods/txnstatus.ts
1
import { Network } from '@mintbase-js/sdk';
2
import { requestFromNearRpc } from '../util';
3✔
3

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

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

21
  let failure = false;
9✔
22
  let pending = false;
9✔
23
  if (!(res.result?.receipts_outcome instanceof Array)) {
9!
24
    throw new Error(`Malformed response: ${JSON.stringify(res)}`);
×
25
  }
26
  res.result?.receipts_outcome?.forEach((outcome: any) => {
9!
27
    if (!outcome?.outcome?.status) {
12!
28
      throw new Error(`Malformed response: ${JSON.stringify(res)}`);
×
29
    }
30
    if (outcome.outcome.status.Unknown) {
12!
31
      pending = true;
×
32
    }
33
    if (outcome.outcome.status.Failure) {
12✔
34
      failure = true;
3✔
35
    }
36
  });
37
  if (failure) {
9✔
38
    return 'failure';
3✔
39
  }
40
  if (pending) {
6!
41
    return 'pending';
×
42
  }
43
  return 'success';
6✔
44
};
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