@gibs/bridge-sdk 1.9.1 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,26 +1,26 @@
1
- import { getAddress } from 'viem'
1
+ import { getAddress } from 'viem';
2
2
 
3
- let imageRoot = 'https://gib.show'
3
+ let imageRoot = 'https://gib.show';
4
4
 
5
5
  /**
6
6
  * Sets the image root for the bridge
7
7
  * @param root - the root
8
8
  */
9
9
  export const setImageRoot = (root: string) => {
10
- imageRoot = root
11
- }
10
+ imageRoot = root;
11
+ };
12
12
 
13
13
  /**
14
14
  * Returns the image root for the bridge
15
15
  * @returns the image root
16
16
  */
17
- export const getImageRoot = () => imageRoot
17
+ export const getImageRoot = () => imageRoot;
18
18
 
19
19
  /** The minimal token info */
20
20
  interface MinimalTokenInfo {
21
- chainId: number
22
- address: string
23
- logoURI?: string | null
21
+ chainId: number;
22
+ address: string;
23
+ logoURI?: string | null;
24
24
  }
25
25
 
26
26
  /**
@@ -29,20 +29,24 @@ interface MinimalTokenInfo {
29
29
  * @returns the list image
30
30
  */
31
31
  export const list = (path: string) => {
32
- return `${imageRoot}/list${path}`
33
- }
32
+ return `${imageRoot}/list${path}`;
33
+ };
34
34
 
35
35
  /**
36
36
  * Returns the network image for the given chain id
37
37
  * @param chainId - the chain id
38
38
  * @returns the network image
39
39
  */
40
+ const isTest =
41
+ typeof process !== 'undefined' &&
42
+ (process.env.VITEST === 'true' || process.env.NODE_ENV === 'test');
43
+
40
44
  export const network = (chainId: number) => {
41
- if (!chainId) {
42
- console.trace('network image')
45
+ if (!chainId && !isTest) {
46
+ console.trace('network image');
43
47
  }
44
- return `${imageRoot}/image/${Number(chainId)}`
45
- }
48
+ return `${imageRoot}/image/${Number(chainId)}`;
49
+ };
46
50
 
47
51
  /**
48
52
  * Returns the image url for the given token info
@@ -50,7 +54,7 @@ export const network = (chainId: number) => {
50
54
  * @returns the image url
51
55
  */
52
56
  export const image = (t: MinimalTokenInfo) =>
53
- t.logoURI || `${network(t.chainId)}/${getAddress(t.address)}`
57
+ t.logoURI || `${network(t.chainId)}/${getAddress(t.address)}`;
54
58
 
55
59
  /**
56
60
  * Returns a url that will lookup all sources for the given array
@@ -58,4 +62,4 @@ export const image = (t: MinimalTokenInfo) =>
58
62
  * @returns the images
59
63
  */
60
64
  export const images = (sources: string[]) =>
61
- `${imageRoot}/image/?${sources.map((s) => `i=${s}`).join('&')}`
65
+ `${imageRoot}/image/?${sources.map((s) => `i=${s}`).join('&')}`;
package/src/index.ts CHANGED
@@ -1,8 +1,8 @@
1
- export * from './chain-info.js'
2
- export * from './abis.js'
3
- export * from './config.js'
4
- export * from './chains.js'
5
- export * from './types.js'
6
- export * from './image-links.js'
7
- export * from './fee-type.js'
8
- export * from './settings.js'
1
+ export * from './abis.js';
2
+ export * from './chain-info.js';
3
+ export * from './chains.js';
4
+ export * from './config.js';
5
+ export * from './fee-type.js';
6
+ export * from './image-links.js';
7
+ export * from './settings.js';
8
+ export * from './types.js';