@gibs/bridge-sdk 1.12.0 → 1.13.1

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.
Files changed (118) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +234 -432
  3. package/dist/abis.d.ts +1 -0
  4. package/dist/bridge-limits.d.ts +103 -0
  5. package/dist/bridge-limits.js +84 -0
  6. package/dist/chain-info.d.ts +169 -0
  7. package/dist/chain-info.js +410 -0
  8. package/dist/chain-names.d.ts +160 -0
  9. package/dist/chain-names.js +200 -0
  10. package/dist/chains.d.ts +65 -0
  11. package/dist/chains.js +284 -0
  12. package/dist/config.d.ts +216 -0
  13. package/dist/config.js +493 -0
  14. package/dist/consolidated-quote.d.ts +554 -0
  15. package/dist/consolidated-quote.js +773 -0
  16. package/dist/destination-calldata.d.ts +118 -0
  17. package/dist/destination-calldata.js +152 -0
  18. package/dist/ecosystems.d.ts +217 -0
  19. package/dist/ecosystems.js +288 -0
  20. package/dist/fee-type.d.ts +10 -0
  21. package/dist/fee-type.js +9 -0
  22. package/dist/hyperliquid-execution.d.ts +152 -0
  23. package/dist/hyperliquid-execution.js +168 -0
  24. package/dist/image-links.d.ts +117 -0
  25. package/dist/image-links.js +142 -0
  26. package/dist/index.d.ts +20 -0
  27. package/dist/index.js +20 -0
  28. package/dist/lifi-execution-guard.d.ts +199 -0
  29. package/dist/lifi-execution-guard.js +400 -0
  30. package/dist/near-intents-conformance.d.ts +85 -0
  31. package/dist/near-intents-conformance.js +329 -0
  32. package/dist/near-intents-route.d.ts +47 -0
  33. package/dist/near-intents-route.js +265 -0
  34. package/dist/near-intents.d.ts +524 -0
  35. package/dist/near-intents.js +1055 -0
  36. package/dist/origin-deposit.d.ts +326 -0
  37. package/dist/origin-deposit.js +68 -0
  38. package/dist/pre-quote.d.ts +198 -0
  39. package/dist/pre-quote.js +175 -0
  40. package/dist/prices.d.ts +107 -0
  41. package/dist/prices.js +162 -0
  42. package/dist/providers.d.ts +221 -0
  43. package/dist/providers.js +157 -0
  44. package/dist/quote-fees.d.ts +102 -0
  45. package/dist/quote-fees.js +195 -0
  46. package/dist/referral.d.ts +77 -0
  47. package/dist/referral.js +72 -0
  48. package/dist/relay-currencies.d.ts +47 -0
  49. package/dist/relay-currencies.js +89 -0
  50. package/dist/relay-quote.d.ts +301 -0
  51. package/dist/relay-quote.js +983 -0
  52. package/dist/route-steps.d.ts +138 -0
  53. package/dist/route-steps.js +305 -0
  54. package/dist/routing/amounts.d.ts +80 -0
  55. package/dist/routing/amounts.js +120 -0
  56. package/dist/routing/candidate-route.d.ts +43 -0
  57. package/dist/routing/candidate-route.js +45 -0
  58. package/dist/routing/candidate.d.ts +237 -0
  59. package/dist/routing/candidate.js +96 -0
  60. package/dist/routing/carriers/ask-answer.d.ts +60 -0
  61. package/dist/routing/carriers/ask-answer.js +1 -0
  62. package/dist/routing/carriers/omnibridge.d.ts +137 -0
  63. package/dist/routing/carriers/omnibridge.js +419 -0
  64. package/dist/routing/carriers/pulsex.d.ts +149 -0
  65. package/dist/routing/carriers/pulsex.js +453 -0
  66. package/dist/routing/carriers/wrap.d.ts +25 -0
  67. package/dist/routing/carriers/wrap.js +115 -0
  68. package/dist/routing/composed-route-quality.d.ts +103 -0
  69. package/dist/routing/composed-route-quality.js +108 -0
  70. package/dist/routing/entry-chain-anchor.d.ts +88 -0
  71. package/dist/routing/entry-chain-anchor.js +55 -0
  72. package/dist/routing/format.d.ts +31 -0
  73. package/dist/routing/format.js +58 -0
  74. package/dist/routing/index.d.ts +34 -0
  75. package/dist/routing/index.js +42 -0
  76. package/dist/routing/producers.d.ts +770 -0
  77. package/dist/routing/producers.js +1564 -0
  78. package/dist/routing/providers.d.ts +26 -0
  79. package/dist/routing/providers.js +38 -0
  80. package/dist/routing/route-data.d.ts +355 -0
  81. package/dist/routing/route-data.js +1 -0
  82. package/dist/routing/search/compose.d.ts +168 -0
  83. package/dist/routing/search/compose.js +98 -0
  84. package/dist/routing/search/graph.d.ts +653 -0
  85. package/dist/routing/search/graph.js +445 -0
  86. package/dist/routing/search/plan-route-data.d.ts +244 -0
  87. package/dist/routing/search/plan-route-data.js +767 -0
  88. package/dist/routing/search/score.d.ts +353 -0
  89. package/dist/routing/search/score.js +427 -0
  90. package/dist/routing/usd-value.d.ts +17 -0
  91. package/dist/routing/usd-value.js +25 -0
  92. package/dist/settings.d.ts +692 -0
  93. package/dist/settings.js +909 -0
  94. package/dist/ton-execution.d.ts +117 -0
  95. package/dist/ton-execution.js +247 -0
  96. package/dist/tron-execution.d.ts +146 -0
  97. package/dist/tron-execution.js +239 -0
  98. package/dist/types.d.ts +51 -0
  99. package/dist/types.js +1 -0
  100. package/llms.txt +169 -0
  101. package/package.json +204 -23
  102. package/src/chain-info.test.ts +0 -968
  103. package/src/chain-info.ts +0 -498
  104. package/src/chains.test.ts +0 -123
  105. package/src/chains.ts +0 -88
  106. package/src/config.test.ts +0 -679
  107. package/src/config.ts +0 -500
  108. package/src/fee-type.test.ts +0 -45
  109. package/src/fee-type.ts +0 -14
  110. package/src/image-links.test.ts +0 -160
  111. package/src/image-links.ts +0 -65
  112. package/src/index.ts +0 -8
  113. package/src/settings.test.ts +0 -2754
  114. package/src/settings.ts +0 -875
  115. package/src/types.ts +0 -48
  116. package/tsconfig.json +0 -17
  117. package/vitest.config.ts +0 -13
  118. /package/{src/abis.ts → dist/abis.js} +0 -0
@@ -1,160 +0,0 @@
1
- import { beforeEach, describe, expect, it } from 'vitest';
2
- import { getImageRoot, image, images, list, network, setImageRoot } from './image-links';
3
-
4
- describe('image-links', () => {
5
- beforeEach(() => {
6
- // Reset to default before each test
7
- setImageRoot('https://gib.show');
8
- });
9
-
10
- describe('setImageRoot and getImageRoot', () => {
11
- it('should have default image root', () => {
12
- expect(getImageRoot()).toBe('https://gib.show');
13
- });
14
-
15
- it('should update image root', () => {
16
- setImageRoot('https://custom.domain');
17
- expect(getImageRoot()).toBe('https://custom.domain');
18
- });
19
-
20
- it('should affect all subsequent URL generations', () => {
21
- setImageRoot('https://test.com');
22
- expect(list('/tokens')).toBe('https://test.com/list/tokens');
23
- expect(network(1)).toBe('https://test.com/image/1');
24
- });
25
- });
26
-
27
- describe('list', () => {
28
- it('should generate list URL with path', () => {
29
- expect(list('/pulsex')).toBe('https://gib.show/list/pulsex');
30
- });
31
-
32
- it('should handle paths without leading slash', () => {
33
- expect(list('tokens')).toBe('https://gib.show/listtokens');
34
- });
35
-
36
- it('should handle paths with query params', () => {
37
- expect(list('/pulsechain-bridge/foreign?extensions=bridgeInfo')).toBe(
38
- 'https://gib.show/list/pulsechain-bridge/foreign?extensions=bridgeInfo',
39
- );
40
- });
41
-
42
- it('should handle empty path', () => {
43
- expect(list('')).toBe('https://gib.show/list');
44
- });
45
- });
46
-
47
- describe('network', () => {
48
- it('should generate network image URL for Ethereum', () => {
49
- expect(network(1)).toBe('https://gib.show/image/1');
50
- });
51
-
52
- it('should generate network image URL for PulseChain', () => {
53
- expect(network(369)).toBe('https://gib.show/image/369');
54
- });
55
-
56
- it('should generate network image URL for BSC', () => {
57
- expect(network(56)).toBe('https://gib.show/image/56');
58
- });
59
-
60
- it('should convert string numbers to number', () => {
61
- expect(network('369' as any)).toBe('https://gib.show/image/369');
62
- });
63
-
64
- it('should handle zero chainId', () => {
65
- expect(network(0)).toBe('https://gib.show/image/0');
66
- });
67
-
68
- it('should handle falsy chainId', () => {
69
- expect(network(null as any)).toBe('https://gib.show/image/0');
70
- expect(network(undefined as any)).toBe('https://gib.show/image/NaN');
71
- });
72
- });
73
-
74
- describe('image', () => {
75
- it('should use logoURI if provided', () => {
76
- const token = {
77
- chainId: 1,
78
- address: '0xdac17f958d2ee523a2206206994597c13d831ec7',
79
- logoURI: 'https://custom.com/usdt.png',
80
- };
81
- expect(image(token)).toBe('https://custom.com/usdt.png');
82
- });
83
-
84
- it('should generate URL from chainId and address if no logoURI', () => {
85
- const token = {
86
- chainId: 1,
87
- address: '0xdac17f958d2ee523a2206206994597c13d831ec7',
88
- };
89
- expect(image(token)).toBe(
90
- 'https://gib.show/image/1/0xdAC17F958D2ee523a2206206994597C13D831ec7',
91
- );
92
- });
93
-
94
- it('should checksum the address', () => {
95
- const token = {
96
- chainId: 1,
97
- address: '0xdac17f958d2ee523a2206206994597c13d831ec7', // lowercase
98
- };
99
- const result = image(token);
100
- // Address should be checksummed in the URL
101
- expect(result).toContain('0xdAC17F958D2ee523a2206206994597C13D831ec7');
102
- });
103
-
104
- it('should handle null logoURI', () => {
105
- const token = {
106
- chainId: 369,
107
- address: '0xa1077a294dde1b09bb078844df40758a5d0f9a27',
108
- logoURI: null,
109
- };
110
- expect(image(token)).toBe(
111
- 'https://gib.show/image/369/0xA1077a294dDE1B09bB078844df40758a5D0f9a27',
112
- );
113
- });
114
-
115
- it('should handle different chain IDs', () => {
116
- const bscToken = {
117
- chainId: 56,
118
- address: '0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82',
119
- };
120
- expect(image(bscToken)).toBe(
121
- 'https://gib.show/image/56/0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82',
122
- );
123
- });
124
- });
125
-
126
- describe('images', () => {
127
- it('should generate multi-source image URL', () => {
128
- const sources = ['source1', 'source2', 'source3'];
129
- expect(images(sources)).toBe('https://gib.show/image/?i=source1&i=source2&i=source3');
130
- });
131
-
132
- it('should handle single source', () => {
133
- expect(images(['single'])).toBe('https://gib.show/image/?i=single');
134
- });
135
-
136
- it('should handle empty array', () => {
137
- expect(images([])).toBe('https://gib.show/image/?');
138
- });
139
-
140
- it('should handle URL-encoded sources', () => {
141
- const sources = ['https://example.com/image1.png', 'https://example.com/image2.png'];
142
- expect(images(sources)).toBe(
143
- 'https://gib.show/image/?i=https://example.com/image1.png&i=https://example.com/image2.png',
144
- );
145
- });
146
- });
147
-
148
- describe('integration', () => {
149
- it('should work with custom root across all functions', () => {
150
- setImageRoot('https://cdn.example.com');
151
-
152
- expect(list('/tokens')).toBe('https://cdn.example.com/list/tokens');
153
- expect(network(1)).toBe('https://cdn.example.com/image/1');
154
- expect(image({ chainId: 1, address: '0xdac17f958d2ee523a2206206994597c13d831ec7' })).toBe(
155
- 'https://cdn.example.com/image/1/0xdAC17F958D2ee523a2206206994597C13D831ec7',
156
- );
157
- expect(images(['a', 'b'])).toBe('https://cdn.example.com/image/?i=a&i=b');
158
- });
159
- });
160
- });
@@ -1,65 +0,0 @@
1
- import { getAddress } from 'viem';
2
-
3
- let imageRoot = 'https://gib.show';
4
-
5
- /**
6
- * Sets the image root for the bridge
7
- * @param root - the root
8
- */
9
- export const setImageRoot = (root: string) => {
10
- imageRoot = root;
11
- };
12
-
13
- /**
14
- * Returns the image root for the bridge
15
- * @returns the image root
16
- */
17
- export const getImageRoot = () => imageRoot;
18
-
19
- /** The minimal token info */
20
- interface MinimalTokenInfo {
21
- chainId: number;
22
- address: string;
23
- logoURI?: string | null;
24
- }
25
-
26
- /**
27
- * Returns the list image for the given path
28
- * @param path - the path
29
- * @returns the list image
30
- */
31
- export const list = (path: string) => {
32
- return `${imageRoot}/list${path}`;
33
- };
34
-
35
- /**
36
- * Returns the network image for the given chain id
37
- * @param chainId - the chain id
38
- * @returns the network image
39
- */
40
- const isTest =
41
- typeof process !== 'undefined' &&
42
- (process.env.VITEST === 'true' || process.env.NODE_ENV === 'test');
43
-
44
- export const network = (chainId: number) => {
45
- if (!chainId && !isTest) {
46
- console.trace('network image');
47
- }
48
- return `${imageRoot}/image/${Number(chainId)}`;
49
- };
50
-
51
- /**
52
- * Returns the image url for the given token info
53
- * @param t - the token info
54
- * @returns the image url
55
- */
56
- export const image = (t: MinimalTokenInfo) =>
57
- t.logoURI || `${network(t.chainId)}/${getAddress(t.address)}`;
58
-
59
- /**
60
- * Returns a url that will lookup all sources for the given array
61
- * @param sources - the sources
62
- * @returns the images
63
- */
64
- export const images = (sources: string[]) =>
65
- `${imageRoot}/image/?${sources.map((s) => `i=${s}`).join('&')}`;
package/src/index.ts DELETED
@@ -1,8 +0,0 @@
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';