@gibs/bridge-sdk 1.7.2 → 1.9.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.
- package/README.md +476 -12
- package/dist/src/abis.d.ts +15 -0
- package/dist/src/abis.js +1 -0
- package/dist/src/chain-info.d.ts +1 -1
- package/dist/src/chains.js +1 -1
- package/dist/src/config.d.ts +28 -5
- package/dist/src/config.js +71 -17
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -3
- package/src/abis.ts +1 -0
- package/src/chain-info.ts +2 -2
- package/src/chains.ts +1 -1
- package/src/config.ts +104 -17
package/README.md
CHANGED
|
@@ -1,23 +1,487 @@
|
|
|
1
|
-
# Bridge
|
|
1
|
+
# Bridge SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A comprehensive toolkit for facilitating cross-chain bridge operations across multiple blockchain networks. This SDK provides low-level building blocks for implementing bridge functionality in decentralized applications.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## 🎯 Use Cases
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
### Primary Use Cases
|
|
8
|
+
- **Cross-Chain Bridge Implementation**: Build applications that move tokens between different blockchain networks
|
|
9
|
+
- **Multi-Chain DApp Development**: Create applications that operate across PulseChain, Ethereum, Binance Smart Chain, and other supported networks
|
|
10
|
+
- **Bridge Provider Integration**: Integrate with multiple bridge providers (PulseChain native bridges, TokenSex, etc.)
|
|
11
|
+
- **Token Metadata Management**: Access standardized token information, logos, and network-specific addresses
|
|
12
|
+
- **Fee Calculation**: Calculate and manage bridge fees across different providers and networks
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
### Target Applications
|
|
15
|
+
- Cross-chain DEX interfaces
|
|
16
|
+
- Bridge aggregator platforms
|
|
17
|
+
- Multi-chain portfolio management tools
|
|
18
|
+
- DeFi applications requiring cross-chain functionality
|
|
19
|
+
- Wallet applications with bridge features
|
|
20
|
+
|
|
21
|
+
## 🔧 Core Functionality
|
|
22
|
+
|
|
23
|
+
### Chain Management
|
|
24
|
+
- **Supported Networks**: PulseChain (0x171), Ethereum (0x1), Binance Smart Chain (0x38), and testnets
|
|
25
|
+
- **Chain Metadata**: Complete chain configurations including RPC URLs, native tokens, and visual assets
|
|
26
|
+
- **Chain Utilities**: Convert between chain IDs and human-readable chain keys
|
|
27
|
+
|
|
28
|
+
### Token & Bridge Configuration
|
|
29
|
+
- **Token Types**: Standardized token metadata with cross-chain bridge information
|
|
30
|
+
- **Bridge Providers**: Support for multiple bridge providers with different fee structures
|
|
31
|
+
- **Asset Mapping**: Native asset addresses and wrapped token configurations across chains
|
|
32
|
+
|
|
33
|
+
### Smart Contract Integration
|
|
34
|
+
- **ABIs**: Pre-configured contract ABIs for bridge operations
|
|
35
|
+
- **Contract Addresses**: Deployed contract addresses across supported networks
|
|
36
|
+
- **Type Safety**: Full TypeScript support with strongly typed contract interactions
|
|
37
|
+
|
|
38
|
+
## 📦 Installation
|
|
10
39
|
|
|
11
|
-
## install
|
|
12
40
|
```sh
|
|
13
|
-
npm
|
|
41
|
+
npm install @gibs/bridge-sdk
|
|
42
|
+
# or
|
|
43
|
+
yarn add @gibs/bridge-sdk
|
|
14
44
|
```
|
|
15
45
|
|
|
16
|
-
##
|
|
46
|
+
## 📖 API Examples
|
|
47
|
+
|
|
48
|
+
### Types (`@gibs/bridge-sdk/types`)
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import type {
|
|
52
|
+
Token,
|
|
53
|
+
BridgeKey,
|
|
54
|
+
TokenList,
|
|
55
|
+
TokenOut,
|
|
56
|
+
PerNetworkBridgeLink,
|
|
57
|
+
Extensions,
|
|
58
|
+
TokenMetadata,
|
|
59
|
+
VisualChain
|
|
60
|
+
} from '@gibs/bridge-sdk/types'
|
|
61
|
+
|
|
62
|
+
// Core token metadata
|
|
63
|
+
const tokenMetadata: TokenMetadata = {
|
|
64
|
+
name: "Wrapped Ethereum",
|
|
65
|
+
symbol: "WETH",
|
|
66
|
+
decimals: 18
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Bridge link information
|
|
70
|
+
const bridgeLink: PerNetworkBridgeLink = {
|
|
71
|
+
tokenAddress: "0x..." // Address on destination chain
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Token extensions for cross-chain info
|
|
75
|
+
const extensions: Extensions = {
|
|
76
|
+
wrapped: { address: "0x..." },
|
|
77
|
+
bridgeInfo: {
|
|
78
|
+
369: { tokenAddress: "0x..." } // PulseChain mapping
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Complete token with bridge metadata
|
|
83
|
+
const token: Token = {
|
|
84
|
+
...tokenMetadata,
|
|
85
|
+
address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
86
|
+
chainId: 1,
|
|
87
|
+
logoURI: "https://example.com/weth.png",
|
|
88
|
+
extensions
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Token for output (address can be null)
|
|
92
|
+
const tokenOut: TokenOut = {
|
|
93
|
+
...tokenMetadata,
|
|
94
|
+
address: null, // Can be null for native tokens
|
|
95
|
+
chainId: 369,
|
|
96
|
+
logoURI: null
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Bridge route definition
|
|
100
|
+
const bridgeKey: BridgeKey = [
|
|
101
|
+
'pulsechain', // Provider
|
|
102
|
+
'0x1', // From chain (Ethereum)
|
|
103
|
+
'0x171' // To chain (PulseChain)
|
|
104
|
+
]
|
|
105
|
+
|
|
106
|
+
// Visual chain with logo info
|
|
107
|
+
const visualChain: VisualChain = {
|
|
108
|
+
id: 369,
|
|
109
|
+
name: 'PulseChain',
|
|
110
|
+
chainId: '0x171' as any,
|
|
111
|
+
logoURI: 'https://example.com/pls.png',
|
|
112
|
+
alt: 'PulseChain logo'
|
|
113
|
+
// ... other Chain properties
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Config (`@gibs/bridge-sdk/config`)
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
import {
|
|
121
|
+
Chains,
|
|
122
|
+
Provider,
|
|
123
|
+
toChain,
|
|
124
|
+
toChainKey,
|
|
125
|
+
pathways,
|
|
126
|
+
validBridgeKeys,
|
|
127
|
+
inferBridgeKey,
|
|
128
|
+
pathway,
|
|
129
|
+
isNative,
|
|
130
|
+
canChangeUnwrap,
|
|
131
|
+
defaultAssetIn
|
|
132
|
+
} from '@gibs/bridge-sdk/config'
|
|
133
|
+
|
|
134
|
+
// Chain enum usage
|
|
135
|
+
console.log(Chains.PLS) // "0x171"
|
|
136
|
+
console.log(Chains.ETH) // "0x1"
|
|
137
|
+
|
|
138
|
+
// Provider enum usage
|
|
139
|
+
console.log(Provider.PULSECHAIN) // "pulsechain"
|
|
140
|
+
|
|
141
|
+
// Convert numeric chain ID to hex
|
|
142
|
+
const chainHex = toChain(369) // "0x171"
|
|
143
|
+
const chainHex2 = toChain("369") // "0x171"
|
|
144
|
+
|
|
145
|
+
// Convert chain ID to human-readable key
|
|
146
|
+
const chainKey = toChainKey(369) // "PLS"
|
|
147
|
+
|
|
148
|
+
// Get all valid bridge routes for environment
|
|
149
|
+
const bridgeRoutes = validBridgeKeys(true) // Production routes
|
|
150
|
+
const testRoutes = validBridgeKeys(false) // Include testnets
|
|
151
|
+
|
|
152
|
+
// Find bridge provider for chain pair
|
|
153
|
+
const bridgeKey = inferBridgeKey({
|
|
154
|
+
fromChain: Chains.ETH,
|
|
155
|
+
toChain: Chains.PLS,
|
|
156
|
+
isProd: true
|
|
157
|
+
}) // Returns: ['pulsechain', '0x1', '0x171']
|
|
158
|
+
|
|
159
|
+
// Get pathway configuration for a bridge route
|
|
160
|
+
const pathwayConfig = pathway(['pulsechain', '0x1', '0x171'], true)
|
|
161
|
+
console.log(pathwayConfig?.from) // Bridge contract on Ethereum
|
|
162
|
+
console.log(pathwayConfig?.to) // Bridge contract on PulseChain
|
|
163
|
+
|
|
164
|
+
// Check if token is native to chain
|
|
165
|
+
const native = isNative(token, bridgeKey) // boolean
|
|
166
|
+
|
|
167
|
+
// Check if unwrapping is allowed
|
|
168
|
+
const canUnwrap = canChangeUnwrap(bridgeKey, token) // boolean
|
|
169
|
+
|
|
170
|
+
// Get default asset for bridge route
|
|
171
|
+
const defaultToken = defaultAssetIn(bridgeKey, true) // Default token address
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
import {
|
|
176
|
+
nativeAssetOut,
|
|
177
|
+
nativeTokenSymbol,
|
|
178
|
+
nativeTokenName,
|
|
179
|
+
uniV2Routers
|
|
180
|
+
} from '@gibs/bridge-sdk/config'
|
|
181
|
+
|
|
182
|
+
// Get native wrapped token address for a chain
|
|
183
|
+
const wethAddress = nativeAssetOut[Chains.ETH] // "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
|
|
184
|
+
const wplsAddress = nativeAssetOut[Chains.PLS] // "0xA1077a294dDE1B09bB078844df40758a5D0f9a27"
|
|
185
|
+
|
|
186
|
+
// Get native token symbols and names
|
|
187
|
+
const ethSymbol = nativeTokenSymbol[Chains.ETH] // "ETH"
|
|
188
|
+
const plsName = nativeTokenName[Chains.PLS] // "Pulse"
|
|
189
|
+
|
|
190
|
+
// Get UniV2 router addresses for chain
|
|
191
|
+
const plsRouters = uniV2Routers[Chains.PLS] // Array of router addresses
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Settings (`@gibs/bridge-sdk/settings`)
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
import {
|
|
198
|
+
oneEther,
|
|
199
|
+
basisPoints,
|
|
200
|
+
bridgePathway,
|
|
201
|
+
amountToBridge,
|
|
202
|
+
bridgeCost,
|
|
203
|
+
estimatedAmountOut,
|
|
204
|
+
estimatedFee,
|
|
205
|
+
oneTokenInt,
|
|
206
|
+
assetOutKey,
|
|
207
|
+
assetOut
|
|
208
|
+
} from '@gibs/bridge-sdk/settings'
|
|
209
|
+
|
|
210
|
+
// Common constants
|
|
211
|
+
console.log(oneEther) // 1000000000000000000n (1e18)
|
|
212
|
+
console.log(basisPoints) // 10000n
|
|
213
|
+
|
|
214
|
+
// Calculate actual amount to bridge
|
|
215
|
+
const amount = amountToBridge({
|
|
216
|
+
amountIn: 1000000000000000000n, // 1 ETH
|
|
217
|
+
assetIn: token,
|
|
218
|
+
}) // Returns 1000000000000000000n or 0n if invalid
|
|
219
|
+
|
|
220
|
+
// Calculate bridge cost
|
|
221
|
+
const cost = bridgeCost({
|
|
222
|
+
bridgeKey: ['pulsechain', '0x1', '0x171'],
|
|
223
|
+
amountIn: oneEther,
|
|
224
|
+
// ... other parameters
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
// Estimate output amount after fees
|
|
228
|
+
const outputAmount = estimatedAmountOut({
|
|
229
|
+
amountIn: oneEther,
|
|
230
|
+
bridgeKey: ['pulsechain', '0x1', '0x171'],
|
|
231
|
+
// ... fee parameters
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
// Calculate fee amount
|
|
235
|
+
const feeAmount = estimatedFee({
|
|
236
|
+
amountIn: oneEther,
|
|
237
|
+
feeType: 'percent',
|
|
238
|
+
// ... other parameters
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
// Convert amount to "one token" representation
|
|
242
|
+
const oneToken = oneTokenInt({
|
|
243
|
+
decimals: 18,
|
|
244
|
+
amount: oneEther
|
|
245
|
+
}) // 1000000000000000000n
|
|
246
|
+
|
|
247
|
+
// Generate asset out key for caching
|
|
248
|
+
const cacheKey = assetOutKey({
|
|
249
|
+
bridgeKey: ['pulsechain', '0x1', '0x171'],
|
|
250
|
+
assetIn: token
|
|
251
|
+
}) // String key for asset lookup
|
|
252
|
+
|
|
253
|
+
// Get output asset configuration
|
|
254
|
+
const outputAsset = assetOut({
|
|
255
|
+
bridgeKey: ['pulsechain', '0x1', '0x171'],
|
|
256
|
+
assetIn: token,
|
|
257
|
+
// ... other parameters
|
|
258
|
+
})
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Chain Info (`@gibs/bridge-sdk/chain-info`)
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
import {
|
|
265
|
+
loadBridgeFees,
|
|
266
|
+
nativeSymbol,
|
|
267
|
+
tokenBridgeInfo,
|
|
268
|
+
fetchPriceCorrective,
|
|
269
|
+
minBridgeAmountIn,
|
|
270
|
+
chainMulticall
|
|
271
|
+
} from '@gibs/bridge-sdk/chain-info'
|
|
272
|
+
|
|
273
|
+
// Load bridge fees for a route
|
|
274
|
+
const fees = await loadBridgeFees({
|
|
275
|
+
pathway: pathwayConfig,
|
|
276
|
+
fromChainClient: ethClient,
|
|
277
|
+
toChainClient: plsClient
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
// Get native symbol for token, with unwrap logic
|
|
281
|
+
const symbol = nativeSymbol(token, false) // "WETH" or "ETH" if unwrapped
|
|
282
|
+
|
|
283
|
+
// Get token bridge information
|
|
284
|
+
const bridgeInfo = await tokenBridgeInfo({
|
|
285
|
+
bridgeKey: ['pulsechain', '0x1', '0x171'],
|
|
286
|
+
client: ethClient,
|
|
287
|
+
target: token.address,
|
|
288
|
+
// ... other parameters
|
|
289
|
+
})
|
|
17
290
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
//
|
|
291
|
+
// Fetch price corrective data
|
|
292
|
+
const priceData = fetchPriceCorrective({
|
|
293
|
+
bridgeKey: ['pulsechain', '0x1', '0x171'],
|
|
294
|
+
// ... other parameters
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
// Get minimum bridge amount
|
|
298
|
+
const minAmount = await minBridgeAmountIn({
|
|
299
|
+
bridgeKey: ['pulsechain', '0x1', '0x171'],
|
|
300
|
+
client: ethClient,
|
|
301
|
+
// ... other parameters
|
|
302
|
+
})
|
|
303
|
+
|
|
304
|
+
// Create multicall helper for chain
|
|
305
|
+
const multicall = chainMulticall(ethClient)
|
|
306
|
+
// Use for batched contract calls
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### Image Links (`@gibs/bridge-sdk/image-links`)
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
import * as imageLinks from '@gibs/bridge-sdk/image-links'
|
|
313
|
+
|
|
314
|
+
// Configure image root URL
|
|
315
|
+
imageLinks.setImageRoot('https://cdn.example.com/images/')
|
|
316
|
+
const currentRoot = imageLinks.getImageRoot() // Current root URL
|
|
317
|
+
|
|
318
|
+
// Get network image URL
|
|
319
|
+
const networkImage = imageLinks.network(1) // Ethereum logo URL
|
|
320
|
+
const plsImage = imageLinks.network(369) // PulseChain logo URL
|
|
321
|
+
|
|
322
|
+
// Get single token image
|
|
323
|
+
const tokenImage = imageLinks.image({
|
|
324
|
+
chainId: 1,
|
|
325
|
+
address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
|
|
326
|
+
})
|
|
327
|
+
|
|
328
|
+
// Get token images for multiple sources
|
|
329
|
+
const tokenImages = imageLinks.images([
|
|
330
|
+
"1/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH on Ethereum
|
|
331
|
+
"369/0xA1077a294dDE1B09bB078844df40758a5D0f9a27" // WPLS on PulseChain
|
|
332
|
+
])
|
|
333
|
+
|
|
334
|
+
// List available images in a directory
|
|
335
|
+
const availableImages = imageLinks.list('tokens/') // Array of image paths
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### ABIs (`@gibs/bridge-sdk/abis`)
|
|
339
|
+
|
|
340
|
+
```typescript
|
|
22
341
|
import * as abis from '@gibs/bridge-sdk/abis'
|
|
342
|
+
|
|
343
|
+
// Bridge contract ABIs
|
|
344
|
+
const inputBridgeAbi = abis.inputBridge // Input bridge contract
|
|
345
|
+
const outputBridgeAbi = abis.outputBridge // Output bridge contract
|
|
346
|
+
const outputRouterAbi = abis.outputRouter // Output router contract
|
|
347
|
+
|
|
348
|
+
// Token contract ABIs
|
|
349
|
+
const erc677Abi = abis.erc677 // ERC677 token contract
|
|
350
|
+
const erc677ExtraAbi = abis.erc677ExtraInput // With extra input functions
|
|
351
|
+
|
|
352
|
+
// Router and fee ABIs
|
|
353
|
+
const nativeRouterAbi = abis.nativeRouter // Native token router
|
|
354
|
+
const feeManagerAbi = abis.feeManager // Fee management contract
|
|
355
|
+
const univ2RouterAbi = abis.univ2Router // UniswapV2 router
|
|
356
|
+
|
|
357
|
+
// Utility ABIs and types
|
|
358
|
+
const feeDeliveryStruct = abis.feeDeliveryStruct // Fee delivery struct ABI
|
|
359
|
+
const homeAmbAbi = abis.homeAmb // Home AMB contract
|
|
360
|
+
const pairAbi = abis.pair // Pair contract
|
|
361
|
+
|
|
362
|
+
// Use with viem contract calls
|
|
363
|
+
const contract = getContract({
|
|
364
|
+
address: bridgeAddress,
|
|
365
|
+
abi: inputBridgeAbi,
|
|
366
|
+
client: publicClient
|
|
367
|
+
})
|
|
368
|
+
|
|
369
|
+
const bridgeFunction = contract.read.someFunction()
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### Fee Types (`@gibs/bridge-sdk/fee-type`)
|
|
373
|
+
|
|
374
|
+
```typescript
|
|
375
|
+
import { FeeType, feeTypeValToKeyMap, type FeeTypeKeys } from '@gibs/bridge-sdk/fee-type'
|
|
376
|
+
|
|
377
|
+
// Fee type enum
|
|
378
|
+
console.log(FeeType.PERCENT) // "%"
|
|
379
|
+
console.log(FeeType.GAS_TIP) // "gas+%"
|
|
380
|
+
console.log(FeeType.FIXED) // "fixed"
|
|
381
|
+
|
|
382
|
+
// Fee type keys
|
|
383
|
+
const percentKey: FeeTypeKeys = 'PERCENT'
|
|
384
|
+
const gasTipKey: FeeTypeKeys = 'GAS_TIP'
|
|
385
|
+
|
|
386
|
+
// Convert fee type value back to key
|
|
387
|
+
const feeTypeKey = feeTypeValToKeyMap.get('%') // "PERCENT"
|
|
388
|
+
const gasKey = feeTypeValToKeyMap.get('gas+%') // "GAS_TIP"
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
### Chains (`@gibs/bridge-sdk/chains`)
|
|
392
|
+
|
|
393
|
+
```typescript
|
|
394
|
+
import { chainsMetadata } from '@gibs/bridge-sdk/chains'
|
|
395
|
+
import { Chains } from '@gibs/bridge-sdk/config'
|
|
396
|
+
|
|
397
|
+
// Get complete chain configuration
|
|
398
|
+
const pulseChain = chainsMetadata[Chains.PLS]
|
|
399
|
+
console.log(pulseChain.name) // "PulseChain"
|
|
400
|
+
console.log(pulseChain.chainId) // "0x171"
|
|
401
|
+
console.log(pulseChain.logoURI) // Chain logo URL
|
|
402
|
+
console.log(pulseChain.rpcUrls.default.http[0]) // Default RPC URL
|
|
403
|
+
|
|
404
|
+
// Access native currency info
|
|
405
|
+
console.log(pulseChain.nativeCurrency.name) // "Pulse"
|
|
406
|
+
console.log(pulseChain.nativeCurrency.symbol) // "PLS"
|
|
407
|
+
console.log(pulseChain.nativeCurrency.decimals) // 18
|
|
408
|
+
|
|
409
|
+
// Access contract addresses
|
|
410
|
+
console.log(pulseChain.contracts?.multicall3?.address) // Multicall3 address
|
|
411
|
+
console.log(pulseChain.contracts?.ensRegistry?.address) // ENS registry if available
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
## 📋 API Reference
|
|
415
|
+
|
|
416
|
+
### Exports
|
|
417
|
+
|
|
418
|
+
| Export Path | Description |
|
|
419
|
+
|-------------|-------------|
|
|
420
|
+
| `@gibs/bridge-sdk` | Main entry point with all exports |
|
|
421
|
+
| `@gibs/bridge-sdk/types` | TypeScript type definitions |
|
|
422
|
+
| `@gibs/bridge-sdk/config` | Chain IDs, providers, and core configuration |
|
|
423
|
+
| `@gibs/bridge-sdk/chains` | Chain metadata and network configurations |
|
|
424
|
+
| `@gibs/bridge-sdk/abis` | Smart contract ABIs |
|
|
425
|
+
| `@gibs/bridge-sdk/image-links` | Network and token image utilities |
|
|
426
|
+
| `@gibs/bridge-sdk/fee-type` | Fee calculation types and utilities |
|
|
427
|
+
| `@gibs/bridge-sdk/settings` | Bridge settings and configuration |
|
|
428
|
+
| `@gibs/bridge-sdk/chain-info` | Chain-specific bridge information |
|
|
429
|
+
|
|
430
|
+
### Key Types
|
|
431
|
+
|
|
432
|
+
```typescript
|
|
433
|
+
// Core chain identifier
|
|
434
|
+
enum Chains {
|
|
435
|
+
PLS = '0x171', // PulseChain
|
|
436
|
+
ETH = '0x1', // Ethereum
|
|
437
|
+
BNB = '0x38', // Binance Smart Chain
|
|
438
|
+
SEP = '0xaa36a7', // Sepolia Testnet
|
|
439
|
+
V4PLS = '0x3af' // PulseChain V4 Testnet
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// Bridge providers
|
|
443
|
+
enum Provider {
|
|
444
|
+
PULSECHAIN = 'pulsechain',
|
|
445
|
+
TOKENSEX = 'tokensex'
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// Bridge route: [Provider, FromChain, ToChain]
|
|
449
|
+
type BridgeKey = [Provider, Chains, Chains]
|
|
450
|
+
|
|
451
|
+
// Token with bridge metadata
|
|
452
|
+
interface Token {
|
|
453
|
+
name: string
|
|
454
|
+
symbol: string
|
|
455
|
+
decimals: number
|
|
456
|
+
address: string
|
|
457
|
+
chainId: number
|
|
458
|
+
logoURI: string | null
|
|
459
|
+
extensions?: {
|
|
460
|
+
wrapped?: { address: Hex }
|
|
461
|
+
bridgeInfo?: Record<number, PerNetworkBridgeLink>
|
|
462
|
+
}
|
|
463
|
+
}
|
|
23
464
|
```
|
|
465
|
+
|
|
466
|
+
## ⚠️ Important Notes
|
|
467
|
+
|
|
468
|
+
- **Beta Stage**: This SDK is in active development. APIs may change between versions.
|
|
469
|
+
- **Version Sync**: All packages in this monorepo maintain synchronized versions.
|
|
470
|
+
- **Low-Level Tools**: These are building blocks that require careful integration.
|
|
471
|
+
- **Dependencies**: Built on top of `@gibs/common` utilities and `viem` for Ethereum interactions.
|
|
472
|
+
|
|
473
|
+
## 🔗 Dependencies
|
|
474
|
+
|
|
475
|
+
- `@gibs/common`: Shared utilities for RPC clients, caching, and ERC20 operations
|
|
476
|
+
- `viem`: Type-safe Ethereum library for contract interactions
|
|
477
|
+
- `lodash`: Utility functions for data manipulation
|
|
478
|
+
|
|
479
|
+
## 📝 Development Status
|
|
480
|
+
|
|
481
|
+
This package is actively maintained and used in production bridge applications. However, as it's in beta:
|
|
482
|
+
|
|
483
|
+
- APIs may change in minor version updates
|
|
484
|
+
- New bridge providers and chains are regularly added
|
|
485
|
+
- Breaking changes will be documented in release notes
|
|
486
|
+
|
|
487
|
+
For the most up-to-date information, check the package version and changelog.
|
package/dist/src/abis.d.ts
CHANGED
|
@@ -200,6 +200,21 @@ export declare const outputRouter: readonly [{
|
|
|
200
200
|
readonly outputs: readonly [{
|
|
201
201
|
readonly type: "address";
|
|
202
202
|
}];
|
|
203
|
+
}, {
|
|
204
|
+
readonly name: "safeExecuteSignaturesWithAutoGasLimit";
|
|
205
|
+
readonly type: "function";
|
|
206
|
+
readonly stateMutability: "payable";
|
|
207
|
+
readonly inputs: readonly [{
|
|
208
|
+
readonly type: "address";
|
|
209
|
+
readonly name: "runner";
|
|
210
|
+
}, {
|
|
211
|
+
readonly type: "bytes";
|
|
212
|
+
readonly name: "_data";
|
|
213
|
+
}, {
|
|
214
|
+
readonly type: "bytes";
|
|
215
|
+
readonly name: "_signatures";
|
|
216
|
+
}];
|
|
217
|
+
readonly outputs: readonly [];
|
|
203
218
|
}];
|
|
204
219
|
/** the abi for the output bridge */
|
|
205
220
|
export declare const outputBridge: readonly [{
|
package/dist/src/abis.js
CHANGED
|
@@ -28,6 +28,7 @@ export const outputRouter = parseAbi([
|
|
|
28
28
|
'function onTokenBridged(address _token, uint256 _value, bytes memory _data) external payable',
|
|
29
29
|
'function WETH() external view returns(address)',
|
|
30
30
|
'function bridge() external view returns(address)',
|
|
31
|
+
'function safeExecuteSignaturesWithAutoGasLimit(address runner,bytes calldata _data,bytes calldata _signatures) external payable',
|
|
31
32
|
]);
|
|
32
33
|
/** the abi for the output bridge */
|
|
33
34
|
export const outputBridge = parseAbi(['function bridgeContract() external view returns(address)']);
|
package/dist/src/chain-info.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare const links: (({ chainId, target, address, client }: {
|
|
|
28
28
|
target: Hex;
|
|
29
29
|
address: Hex;
|
|
30
30
|
client: PublicClient;
|
|
31
|
-
}) => Promise
|
|
31
|
+
}) => Promise<[`0x${string}`, `0x${string}`]>) & _.MemoizedFunction;
|
|
32
32
|
/**
|
|
33
33
|
* Returns the token bridge info for the given bridge key, asset in, is prod, from chain client, and to chain client
|
|
34
34
|
* @param bridgeKey - the bridge key
|
package/dist/src/chains.js
CHANGED
package/dist/src/config.d.ts
CHANGED
|
@@ -26,11 +26,11 @@ export declare const toChain: (chainId: number | string) => Chains;
|
|
|
26
26
|
* @returns the chain key
|
|
27
27
|
*/
|
|
28
28
|
export declare const toChainKey: (chainId: number | string) => "ETH" | "PLS" | "BNB" | "SEP" | "V4PLS" | undefined;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
export declare const Providers: {
|
|
30
|
+
readonly PULSECHAIN: "pulsechain";
|
|
31
|
+
readonly TOKENSEX: "tokensex";
|
|
32
|
+
};
|
|
33
|
+
export type Provider = typeof Providers[keyof typeof Providers];
|
|
34
34
|
/** A map of chains to native asset out addresses */
|
|
35
35
|
export declare const nativeAssetOut: Record<Chains, Hex>;
|
|
36
36
|
/** A map of chains to deprecated native asset out addresses */
|
|
@@ -111,3 +111,26 @@ export declare const isUnwrappable: (bridgeKey: BridgeKey | null, assetIn: Pick<
|
|
|
111
111
|
* @returns boolean
|
|
112
112
|
*/
|
|
113
113
|
export declare const canChangeUnwrap: (bridgeKey: BridgeKey, assetIn: Token | null) => boolean;
|
|
114
|
+
export declare const chains: {
|
|
115
|
+
readonly ethereum: 1;
|
|
116
|
+
readonly bsc: 56;
|
|
117
|
+
readonly pulsechain: 369;
|
|
118
|
+
readonly pulsechainV4: 943;
|
|
119
|
+
readonly sepolia: 11155111;
|
|
120
|
+
};
|
|
121
|
+
export declare const chainIds: (1 | 56 | 369 | 943 | 11155111)[];
|
|
122
|
+
export type ChainId = (typeof chainIds)[number];
|
|
123
|
+
export type Side = 'home' | 'foreign';
|
|
124
|
+
export type MinimalKey = `${ChainId}-${Hex}`;
|
|
125
|
+
export type PathwayInfo = {
|
|
126
|
+
pair: string;
|
|
127
|
+
key: string;
|
|
128
|
+
home: Hex;
|
|
129
|
+
foreign: Hex;
|
|
130
|
+
};
|
|
131
|
+
export type ProviderHomeChainEntry = Partial<Record<ChainId, PathwayInfo[]>>;
|
|
132
|
+
export type ProviderEntries = Partial<Record<ChainId, ProviderHomeChainEntry>>;
|
|
133
|
+
export type BridgeConfig = Record<Provider, ProviderEntries>;
|
|
134
|
+
export declare const bridgeConfigs: BridgeConfig;
|
|
135
|
+
export declare const HOME_TO_FOREIGN_FEE: `0x${string}`;
|
|
136
|
+
export declare const FOREIGN_TO_HOME_FEE: `0x${string}`;
|