Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ccharly committed Apr 25, 2024
1 parent 4622fe6 commit 07feb9f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 36 deletions.
1 change: 1 addition & 0 deletions src/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { CaipChainId } from '@metamask/utils';

import type { CaipAssetType } from './caip-types';
import type { BalancesResult } from './types';

Expand Down
5 changes: 1 addition & 4 deletions src/caip-types.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
isCaipAssetType,
isCaipAssetId,
} from './caip-types';
import { isCaipAssetType, isCaipAssetId } from './caip-types';

describe('isCaipAssetType', () => {
// Imported from: https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-19.md#test-cases
Expand Down
10 changes: 0 additions & 10 deletions src/caip-types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
import type {
CaipChainId,
CaipNamespace,
CaipReference,
} from '@metamask/utils';
import {
CaipChainIdStruct,
CaipNamespaceStruct,
CaipReferenceStruct,
} from '@metamask/utils';
import type { Infer } from 'superstruct';
import { is, string, pattern } from 'superstruct';

Expand Down
3 changes: 1 addition & 2 deletions src/rpc-handler.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { Json, JsonRpcRequest } from '@metamask/utils';
import type { Json, JsonRpcRequest, CaipChainId } from '@metamask/utils';
import { assert } from 'superstruct';

import type { Chain } from './api';
import type { CaipChainId } from '@metamask/utils';
import { JsonRpcRequestStruct } from './JsonRpcRequest';
import { GetBalancesRequestStruct } from './rpc-types';

Expand Down
2 changes: 1 addition & 1 deletion src/rpc-types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CaipChainIdStruct } from '@metamask/utils';
import type { Infer } from 'superstruct';
import {
record,
Expand All @@ -9,7 +10,6 @@ import {
literal,
} from 'superstruct';

import { CaipChainIdStruct } from '@metamask/utils';
import { CaipAssetTypeStruct } from './caip-types';

export const AmountStruct = object({});
Expand Down
32 changes: 13 additions & 19 deletions src/types.test.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
import { is, literal, max, number, string, union } from 'superstruct';
import { is } from 'superstruct';

import { StringNumberStruct } from './types';

describe('types', () => {
describe('StringNumber', () => {
it.each([
'0',
'0.0',
'0.1',
'0.19',
'00.19',
'0.000000000000000000000',
])('validates basic number: %s', (input: string) => {
expect(is(input, StringNumberStruct)).toBe(true);
});
it.each(['0', '0.0', '0.1', '0.19', '00.19', '0.000000000000000000000'])(
'validates basic number: %s',
(input: string) => {
expect(is(input, StringNumberStruct)).toBe(true);
},
);

it.each([
'foobar',
'NaN',
'0.123.4',
'1e3',
])('fails to validate wrong number: %s', (input: string) => {
expect(is(input, StringNumberStruct)).toBe(false);
});
it.each(['foobar', 'NaN', '0.123.4', '1e3'])(
'fails to validate wrong number: %s',
(input: string) => {
expect(is(input, StringNumberStruct)).toBe(false);
},
);
});
});

0 comments on commit 07feb9f

Please sign in to comment.