@gibs/bridge-sdk 1.10.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.
- package/package.json +12 -5
- package/src/abis.ts +3 -70
- package/src/chain-info.test.ts +968 -0
- package/src/chain-info.ts +161 -127
- package/src/chains.test.ts +123 -0
- package/src/chains.ts +5 -5
- package/src/config.test.ts +679 -0
- package/src/config.ts +138 -118
- package/src/fee-type.test.ts +45 -0
- package/src/fee-type.ts +2 -2
- package/src/image-links.test.ts +160 -0
- package/src/image-links.ts +20 -16
- package/src/index.ts +8 -8
- package/src/settings.test.ts +2754 -0
- package/src/settings.ts +325 -348
- package/src/types.ts +25 -25
- package/tsconfig.json +2 -1
- package/vitest.config.ts +13 -0
- package/dist/src/abis.d.ts +0 -384
- package/dist/src/abis.js +0 -68
- package/dist/src/chain-info.d.ts +0 -130
- package/dist/src/chain-info.js +0 -350
- package/dist/src/chains.d.ts +0 -6
- package/dist/src/chains.js +0 -86
- package/dist/src/config.d.ts +0 -136
- package/dist/src/config.js +0 -386
- package/dist/src/fee-type.d.ts +0 -10
- package/dist/src/fee-type.js +0 -9
- package/dist/src/image-links.d.ts +0 -41
- package/dist/src/image-links.js +0 -45
- package/dist/src/index.d.ts +0 -8
- package/dist/src/index.js +0 -8
- package/dist/src/settings.d.ts +0 -357
- package/dist/src/settings.js +0 -642
- package/dist/src/types.d.ts +0 -44
- package/dist/src/types.js +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/src/config.js
DELETED
|
@@ -1,386 +0,0 @@
|
|
|
1
|
-
import { getAddress, keccak256, stringToHex, zeroAddress } from "viem";
|
|
2
|
-
import _ from 'lodash';
|
|
3
|
-
/**
|
|
4
|
-
* Add here your chain id as hex, be sure to add your chain in the chainsMetadata object too
|
|
5
|
-
*/
|
|
6
|
-
export var Chains;
|
|
7
|
-
(function (Chains) {
|
|
8
|
-
Chains["PLS"] = "0x171";
|
|
9
|
-
Chains["ETH"] = "0x1";
|
|
10
|
-
Chains["BNB"] = "0x38";
|
|
11
|
-
// testnets
|
|
12
|
-
Chains["SEP"] = "0xaa36a7";
|
|
13
|
-
Chains["V4PLS"] = "0x3af";
|
|
14
|
-
// TBNB = '0x61',
|
|
15
|
-
})(Chains || (Chains = {}));
|
|
16
|
-
/** A map of chain ids to chain keys */
|
|
17
|
-
export const chainIdToKey = new Map(Object.entries(Chains).map(([key, chain]) => [chain, key]));
|
|
18
|
-
/**
|
|
19
|
-
* Converts a chain id to a chain key
|
|
20
|
-
* @param chainId - the chain id
|
|
21
|
-
* @returns the chain key
|
|
22
|
-
*/
|
|
23
|
-
export const toChain = (chainId) => `0x${Number(chainId).toString(16)}`;
|
|
24
|
-
/**
|
|
25
|
-
* Converts a chain id to a chain key
|
|
26
|
-
* @param chainId - the chain id
|
|
27
|
-
* @returns the chain key
|
|
28
|
-
*/
|
|
29
|
-
export const toChainKey = (chainId) => chainIdToKey.get(toChain(chainId));
|
|
30
|
-
// /** The provider of an omnibridge */
|
|
31
|
-
// export enum Provider {
|
|
32
|
-
// PULSECHAIN = 'pulsechain',
|
|
33
|
-
// TOKENSEX = 'tokensex',
|
|
34
|
-
// }
|
|
35
|
-
export const Providers = {
|
|
36
|
-
PULSECHAIN: 'pulsechain',
|
|
37
|
-
TOKENSEX: 'tokensex',
|
|
38
|
-
};
|
|
39
|
-
/** A map of chains to native asset out addresses */
|
|
40
|
-
export const nativeAssetOut = {
|
|
41
|
-
[Chains.ETH]: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
42
|
-
[Chains.BNB]: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
|
|
43
|
-
[Chains.PLS]: '0xA1077a294dDE1B09bB078844df40758a5D0f9a27',
|
|
44
|
-
[Chains.SEP]: '0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9',
|
|
45
|
-
[Chains.V4PLS]: '0x70499adEBB11Efd915E3b69E700c331778628707',
|
|
46
|
-
};
|
|
47
|
-
/** A map of chains to deprecated native asset out addresses */
|
|
48
|
-
export const deprecatedNativeAssetOut = {
|
|
49
|
-
[Chains.PLS]: new Set(['0x97Ac4a2439A47c07ad535bb1188c989dae755341']),
|
|
50
|
-
};
|
|
51
|
-
/** A map of chains to uni v2 router addresses */
|
|
52
|
-
export const uniV2Routers = {
|
|
53
|
-
[Chains.PLS]: [
|
|
54
|
-
'0x98bf93ebf5c380C0e6Ae8e192A7e2AE08edAcc02',
|
|
55
|
-
'0x165C3410fC91EF562C50559f7d2289fEbed552d9',
|
|
56
|
-
],
|
|
57
|
-
[Chains.ETH]: ['0x7a250d5630b4cf539739df2c5dacb4c659f2488d'],
|
|
58
|
-
[Chains.BNB]: ['0x05fF2B0DB69458A0750badebc4f9e13aDd608C7F'],
|
|
59
|
-
[Chains.SEP]: ['0xeE567Fe1712Faf6149d80dA1E6934E354124CfE3'],
|
|
60
|
-
[Chains.V4PLS]: [
|
|
61
|
-
'0xDaE9dd3d1A52CfCe9d5F2fAC7fDe164D500E50f7',
|
|
62
|
-
'0x636f6407B90661b73b1C0F7e24F4C79f624d0738',
|
|
63
|
-
],
|
|
64
|
-
};
|
|
65
|
-
/** A map of chains to native token symbols */
|
|
66
|
-
export const nativeTokenSymbol = {
|
|
67
|
-
[Chains.PLS]: 'PLS',
|
|
68
|
-
[Chains.V4PLS]: 'V4PLS',
|
|
69
|
-
[Chains.ETH]: 'ETH',
|
|
70
|
-
[Chains.SEP]: 'sepETH',
|
|
71
|
-
[Chains.BNB]: 'BNB',
|
|
72
|
-
};
|
|
73
|
-
/** A map of chains to native token names */
|
|
74
|
-
export const nativeTokenName = {
|
|
75
|
-
[Chains.PLS]: 'Pulse',
|
|
76
|
-
[Chains.V4PLS]: 'V4 Pulse',
|
|
77
|
-
[Chains.ETH]: 'Ether',
|
|
78
|
-
[Chains.SEP]: 'Sepolia Ether',
|
|
79
|
-
[Chains.BNB]: 'BNB',
|
|
80
|
-
};
|
|
81
|
-
/** The settings for the pulsechain pls eth pathway */
|
|
82
|
-
const pulsechainPLSETHSettings = {
|
|
83
|
-
from: '0x0e18d0d556b652794EF12Bf68B2dC857EF5f3996',
|
|
84
|
-
to: '0xe20E337DB2a00b1C37139c873B92a0AAd3F468bF',
|
|
85
|
-
destinationRouter: '0x1F0144Ce3BDaf11944Fe0beF6444599a0500695B',
|
|
86
|
-
nativeRouter: '0xE66877Cfe4CEc10ffBbBB3092B7001321AB5809D',
|
|
87
|
-
};
|
|
88
|
-
export const pathways = {
|
|
89
|
-
[Providers.PULSECHAIN]: {
|
|
90
|
-
[Chains.PLS]: {
|
|
91
|
-
[Chains.ETH]: {
|
|
92
|
-
from: '0x4fD0aaa7506f3d9cB8274bdB946Ec42A1b8751Ef',
|
|
93
|
-
to: '0x1715a3E4A142d8b698131108995174F37aEBA10D',
|
|
94
|
-
destinationRouter: '0x2Ed02372C3efF1F239B22a901ceA8Cf6fbf82d8d',
|
|
95
|
-
nativeRouter: '0x612Da68aA7BcA625dD2F27f252cddB573674991A',
|
|
96
|
-
validator: '0x5ECfE77502317F3677f23C3b8Ab17929ACE3D74E',
|
|
97
|
-
usesExtraParam: false,
|
|
98
|
-
feeManager: 'from',
|
|
99
|
-
toHome: false,
|
|
100
|
-
requiresDelivery: true,
|
|
101
|
-
// weth from ethereum on pulsechain
|
|
102
|
-
bridgedNativeAssetOut: '0x02DcdD04e3F455D838cd1249292C58f3B79e3C3C',
|
|
103
|
-
settingOverrides: {
|
|
104
|
-
[zeroAddress]: pulsechainPLSETHSettings,
|
|
105
|
-
[getAddress(nativeAssetOut[Chains.PLS])]: pulsechainPLSETHSettings,
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
[Chains.ETH]: {
|
|
110
|
-
[Chains.PLS]: {
|
|
111
|
-
from: '0x1715a3E4A142d8b698131108995174F37aEBA10D',
|
|
112
|
-
to: '0x4fD0aaa7506f3d9cB8274bdB946Ec42A1b8751Ef',
|
|
113
|
-
nativeRouter: '0x2Ed02372C3efF1F239B22a901ceA8Cf6fbf82d8d',
|
|
114
|
-
destinationRouter: '0x612Da68aA7BcA625dD2F27f252cddB573674991A',
|
|
115
|
-
validator: '0x5ECfE77502317F3677f23C3b8Ab17929ACE3D74E',
|
|
116
|
-
feeManager: 'to',
|
|
117
|
-
usesExtraParam: false,
|
|
118
|
-
toHome: true,
|
|
119
|
-
requiresDelivery: false,
|
|
120
|
-
// wpls from pulsechain on ethereum
|
|
121
|
-
bridgedNativeAssetOut: '0xA882606494D86804B5514E07e6Bd2D6a6eE6d68A',
|
|
122
|
-
settingOverrides: {
|
|
123
|
-
[getAddress('0xa882606494d86804b5514e07e6bd2d6a6ee6d68a')]: {
|
|
124
|
-
from: '0xe20E337DB2a00b1C37139c873B92a0AAd3F468bF',
|
|
125
|
-
to: '0x0e18d0d556b652794EF12Bf68B2dC857EF5f3996',
|
|
126
|
-
destinationRouter: '0xE66877Cfe4CEc10ffBbBB3092B7001321AB5809D',
|
|
127
|
-
nativeRouter: '0x1F0144Ce3BDaf11944Fe0beF6444599a0500695B',
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
[Providers.TOKENSEX]: {
|
|
134
|
-
[Chains.PLS]: {
|
|
135
|
-
[Chains.BNB]: {
|
|
136
|
-
from: '0xf1DFc63e10fF01b8c3d307529b47AefaD2154C0e',
|
|
137
|
-
to: '0xb4005881e81a6ecd2c1f75d58e8e41f28d59c6b1',
|
|
138
|
-
destinationRouter: '0x9c50EfD36dF2DBD310fBC981d6D8478cF3484B85',
|
|
139
|
-
nativeRouter: '0xB80B80EBB375BD83a9d6c0761b197d16a8670f81',
|
|
140
|
-
validator: '0xc3c3d5d3ba946a2eb3906878ebe187418b0b524e',
|
|
141
|
-
feeManager: 'from',
|
|
142
|
-
usesExtraParam: true,
|
|
143
|
-
toHome: false,
|
|
144
|
-
requiresDelivery: true,
|
|
145
|
-
// wbnb from bsc on pulsechain (tokensex)
|
|
146
|
-
bridgedNativeAssetOut: '0x518076CCE3729eF1a3877EA3647a26e278e764FE',
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
[Chains.BNB]: {
|
|
150
|
-
[Chains.PLS]: {
|
|
151
|
-
from: '0xb4005881e81a6ecd2c1f75d58e8e41f28d59c6b1',
|
|
152
|
-
to: '0xf1DFc63e10fF01b8c3d307529b47AefaD2154C0e',
|
|
153
|
-
nativeRouter: '0x9c50EfD36dF2DBD310fBC981d6D8478cF3484B85',
|
|
154
|
-
destinationRouter: '0xB80B80EBB375BD83a9d6c0761b197d16a8670f81',
|
|
155
|
-
validator: '0xc3c3d5d3ba946a2eb3906878ebe187418b0b524e',
|
|
156
|
-
feeManager: 'to',
|
|
157
|
-
usesExtraParam: true,
|
|
158
|
-
toHome: true,
|
|
159
|
-
requiresDelivery: false,
|
|
160
|
-
// wpls from pulsechain on bsc (tokensex)
|
|
161
|
-
bridgedNativeAssetOut: '0xF6088134D28eeBEF7128BA41FaDb2FCA0666c64C',
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
};
|
|
166
|
-
export const testnetPathways = {
|
|
167
|
-
[Providers.TOKENSEX]: {
|
|
168
|
-
// plsv4 to bnb home omnibridge: 0xfd0c07C376D27EA0E9fA64Ac5D2481439e36CF9C
|
|
169
|
-
// [Chains.BNB]: {
|
|
170
|
-
// [Chains.V4PLS]: {
|
|
171
|
-
// from: '0xDDf1b0CD7fb7AAA310c703C17995c6671F9DC806',
|
|
172
|
-
// to: '0xfd0c07C376D27EA0E9fA64Ac5D2481439e36CF9C',
|
|
173
|
-
// usesExtraParam: false,
|
|
174
|
-
// requiresDelivery: false,
|
|
175
|
-
// toHome: true,
|
|
176
|
-
// feeManager: 'to',
|
|
177
|
-
// defaultAssetIn: {
|
|
178
|
-
// chainId: 56,
|
|
179
|
-
// address: nativeAssetOut[Chains.TBNB],
|
|
180
|
-
// },
|
|
181
|
-
// },
|
|
182
|
-
// },
|
|
183
|
-
// [Chains.V4PLS]: {
|
|
184
|
-
// [Chains.BNB]: {
|
|
185
|
-
// from: '0xfd0c07C376D27EA0E9fA64Ac5D2481439e36CF9C',
|
|
186
|
-
// to: '0xDDf1b0CD7fb7AAA310c703C17995c6671F9DC806',
|
|
187
|
-
// },
|
|
188
|
-
// },
|
|
189
|
-
},
|
|
190
|
-
[Providers.PULSECHAIN]: {
|
|
191
|
-
[Chains.V4PLS]: {
|
|
192
|
-
[Chains.SEP]: {
|
|
193
|
-
from: '0x6B08a50865aDeCe6e3869D9AfbB316d0a0436B6c',
|
|
194
|
-
to: '0x546e37DAA15cdb82fd1a717E5dEEa4AF08D4349A',
|
|
195
|
-
nativeRouter: '0xCA1BDc038909038C4B3cbab0EA0ec3cC2839F106',
|
|
196
|
-
destinationRouter: '0xCb4057d7DA4CE521B93b71186DfE11f9FBC3e3b1',
|
|
197
|
-
validator: '0xDcd4D88552c86114b2ca029F7F8d4e1a7951d051',
|
|
198
|
-
usesExtraParam: false,
|
|
199
|
-
requiresDelivery: true,
|
|
200
|
-
toHome: false,
|
|
201
|
-
feeManager: 'from',
|
|
202
|
-
bridgedNativeAssetOut: '0x3677bd78ccf4d299328ecfba61790cf8dbfcf686',
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
[Chains.SEP]: {
|
|
206
|
-
[Chains.V4PLS]: {
|
|
207
|
-
from: '0x546e37DAA15cdb82fd1a717E5dEEa4AF08D4349A',
|
|
208
|
-
to: '0x6B08a50865aDeCe6e3869D9AfbB316d0a0436B6c',
|
|
209
|
-
nativeRouter: '0xCb4057d7DA4CE521B93b71186DfE11f9FBC3e3b1',
|
|
210
|
-
destinationRouter: '0xCA1BDc038909038C4B3cbab0EA0ec3cC2839F106',
|
|
211
|
-
validator: '0xDcd4D88552c86114b2ca029F7F8d4e1a7951d051',
|
|
212
|
-
usesExtraParam: false,
|
|
213
|
-
requiresDelivery: false,
|
|
214
|
-
toHome: true,
|
|
215
|
-
feeManager: 'to',
|
|
216
|
-
bridgedNativeAssetOut: '0x35807560aD0597E23F452cdc82D4Fb0e7E3c6590',
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
|
-
};
|
|
221
|
-
/** The mainnet bridge keys */
|
|
222
|
-
const mainnetBridgeKeys = [
|
|
223
|
-
[Providers.PULSECHAIN, Chains.PLS, Chains.ETH],
|
|
224
|
-
[Providers.PULSECHAIN, Chains.ETH, Chains.PLS],
|
|
225
|
-
[Providers.TOKENSEX, Chains.PLS, Chains.BNB],
|
|
226
|
-
[Providers.TOKENSEX, Chains.BNB, Chains.PLS],
|
|
227
|
-
];
|
|
228
|
-
/** The testnet bridge keys */
|
|
229
|
-
const testnetBridgeKeys = [
|
|
230
|
-
[Providers.PULSECHAIN, Chains.SEP, Chains.V4PLS],
|
|
231
|
-
[Providers.PULSECHAIN, Chains.V4PLS, Chains.SEP],
|
|
232
|
-
];
|
|
233
|
-
/** Returns the valid bridge keys for the given is prod */
|
|
234
|
-
export const validBridgeKeys = (isProd) => [
|
|
235
|
-
...mainnetBridgeKeys,
|
|
236
|
-
...(isProd ? [] : testnetBridgeKeys),
|
|
237
|
-
];
|
|
238
|
-
/**
|
|
239
|
-
* Infers the bridge key from the current key, provider, from chain, and to chain
|
|
240
|
-
* @param currentKey - the current bridge key
|
|
241
|
-
* @param provider - the provider
|
|
242
|
-
* @param fromChain - the from chain
|
|
243
|
-
* @param toChain - the to chain
|
|
244
|
-
* @returns the inferred bridge key
|
|
245
|
-
*/
|
|
246
|
-
export const inferBridgeKey = ({ currentKey, provider, fromChain, toChain, }) => {
|
|
247
|
-
const [, fromChainKey, toChainKey] = currentKey;
|
|
248
|
-
const from = fromChain ?? fromChainKey;
|
|
249
|
-
const to = toChain ?? toChainKey;
|
|
250
|
-
const currentFromChainIsValid = !!_.get(pathways, [provider, from]);
|
|
251
|
-
const nextFromChain = currentFromChainIsValid
|
|
252
|
-
? from
|
|
253
|
-
: Object.keys(pathways[provider])[0];
|
|
254
|
-
const currentToChainIsValid = !!_.get(pathways, [provider, nextFromChain, to]);
|
|
255
|
-
const nextToChain = currentToChainIsValid
|
|
256
|
-
? to
|
|
257
|
-
: Object.keys(pathways[provider][nextFromChain])[0];
|
|
258
|
-
return [provider, nextFromChain, nextToChain];
|
|
259
|
-
};
|
|
260
|
-
/**
|
|
261
|
-
* Returns the pathway for the given bridge key, is prod, and asset in address
|
|
262
|
-
* @param bridgeKey - the bridge key
|
|
263
|
-
* @param isProd - whether to use the production pathway
|
|
264
|
-
* @param assetInAddress - the asset in address
|
|
265
|
-
* @returns the pathway
|
|
266
|
-
*/
|
|
267
|
-
export const pathway = (bridgeKey, isProd, assetInAddress) => {
|
|
268
|
-
if (!bridgeKey)
|
|
269
|
-
return;
|
|
270
|
-
let pathway = _.get(pathways, bridgeKey) || (!isProd ? _.get(testnetPathways, bridgeKey) : undefined);
|
|
271
|
-
if (assetInAddress) {
|
|
272
|
-
const addr = getAddress(assetInAddress);
|
|
273
|
-
if (pathway?.settingOverrides?.[addr]) {
|
|
274
|
-
pathway = {
|
|
275
|
-
...pathway,
|
|
276
|
-
...pathway.settingOverrides[addr],
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
return pathway;
|
|
281
|
-
};
|
|
282
|
-
/**
|
|
283
|
-
* Returns the default asset in for the given bridge key and is prod
|
|
284
|
-
* @param bridgeKey - the bridge key
|
|
285
|
-
* @param isProd - whether to use the production pathway
|
|
286
|
-
* @returns the default asset in
|
|
287
|
-
*/
|
|
288
|
-
export const defaultAssetIn = ($bridgeKey, isProd) => {
|
|
289
|
-
if (!$bridgeKey)
|
|
290
|
-
return null;
|
|
291
|
-
const conf = pathway($bridgeKey, isProd);
|
|
292
|
-
const defaultAssetIn = _.get(conf, ['bridgedNativeAssetOut']);
|
|
293
|
-
return defaultAssetIn;
|
|
294
|
-
};
|
|
295
|
-
/**
|
|
296
|
-
* Returns whether the given asset is the native asset for the given bridge key
|
|
297
|
-
* @param asset - the asset
|
|
298
|
-
* @param bridgeKey - the bridge key
|
|
299
|
-
* @returns whether the given asset is the native asset for the given bridge key
|
|
300
|
-
*/
|
|
301
|
-
export const isNative = (asset, bridgeKey) => {
|
|
302
|
-
if (!bridgeKey || !asset) {
|
|
303
|
-
return false;
|
|
304
|
-
}
|
|
305
|
-
const path = pathway(bridgeKey, false);
|
|
306
|
-
return (getAddress(asset.address) === getAddress(path.bridgedNativeAssetOut) ||
|
|
307
|
-
(asset.address === zeroAddress ||
|
|
308
|
-
nativeAssetOut[toChain(asset.chainId)]?.toLowerCase() === asset.address?.toLowerCase()) &&
|
|
309
|
-
!asset.name.includes(' from Pulsechain'));
|
|
310
|
-
};
|
|
311
|
-
/**
|
|
312
|
-
* Returns whether the given asset is unwrappable for the given bridge key
|
|
313
|
-
* @param bridgeKey - the bridge key
|
|
314
|
-
* @param assetIn - the asset in
|
|
315
|
-
* @returns whether the given asset is unwrappable for the given bridge key
|
|
316
|
-
*/
|
|
317
|
-
export const isUnwrappable = (bridgeKey, assetIn) => {
|
|
318
|
-
if (!bridgeKey || !assetIn) {
|
|
319
|
-
return false;
|
|
320
|
-
}
|
|
321
|
-
const addr = getAddress(assetIn.address);
|
|
322
|
-
const path = pathway(bridgeKey, false);
|
|
323
|
-
if (!path)
|
|
324
|
-
return false;
|
|
325
|
-
return path.bridgedNativeAssetOut === getAddress(addr);
|
|
326
|
-
};
|
|
327
|
-
/**
|
|
328
|
-
* Returns whether the given asset can be unwrapped for the given bridge key
|
|
329
|
-
* @param bridgeKey - the bridge key
|
|
330
|
-
* @param assetIn - the asset in
|
|
331
|
-
* @returns boolean
|
|
332
|
-
*/
|
|
333
|
-
export const canChangeUnwrap = (bridgeKey, assetIn) => {
|
|
334
|
-
return !!assetIn && isUnwrappable(bridgeKey, assetIn);
|
|
335
|
-
};
|
|
336
|
-
export const chains = {
|
|
337
|
-
ethereum: 1,
|
|
338
|
-
bsc: 56,
|
|
339
|
-
pulsechain: 369,
|
|
340
|
-
pulsechainV4: 943,
|
|
341
|
-
sepolia: 11155111,
|
|
342
|
-
};
|
|
343
|
-
export const chainIds = Object.values(chains);
|
|
344
|
-
// provider -> home -> foreign
|
|
345
|
-
export const bridgeConfigs = {
|
|
346
|
-
[Providers.PULSECHAIN]: {
|
|
347
|
-
[chains.pulsechain]: {
|
|
348
|
-
[chains.ethereum]: [{
|
|
349
|
-
pair: 'mainnet',
|
|
350
|
-
key: 'erc20',
|
|
351
|
-
home: '0x4fD0aaa7506f3d9cB8274bdB946Ec42A1b8751Ef',
|
|
352
|
-
foreign: '0x1715a3e4a142d8b698131108995174f37aeba10d',
|
|
353
|
-
}, {
|
|
354
|
-
pair: 'mainnet',
|
|
355
|
-
key: 'native',
|
|
356
|
-
home: '0x0e18d0d556b652794EF12Bf68B2dC857EF5f3996',
|
|
357
|
-
foreign: '0xe20E337DB2a00b1C37139c873B92a0AAd3F468bF',
|
|
358
|
-
}],
|
|
359
|
-
},
|
|
360
|
-
[chains.pulsechainV4]: {
|
|
361
|
-
[chains.sepolia]: [{
|
|
362
|
-
pair: 'v4',
|
|
363
|
-
key: 'erc20',
|
|
364
|
-
home: '0x6B08a50865aDeCe6e3869D9AfbB316d0a0436B6c',
|
|
365
|
-
foreign: '0x546e37DAA15cdb82fd1a717E5dEEa4AF08D4349A',
|
|
366
|
-
}, {
|
|
367
|
-
pair: 'v4',
|
|
368
|
-
key: 'native',
|
|
369
|
-
home: '0x81c10846F40fA2B173FC47958D0a892529983F50',
|
|
370
|
-
foreign: '0x5e238ef968467cf443ef5ecb683b76c5a04a0421',
|
|
371
|
-
}],
|
|
372
|
-
},
|
|
373
|
-
},
|
|
374
|
-
[Providers.TOKENSEX]: {
|
|
375
|
-
[chains.pulsechain]: {
|
|
376
|
-
[chains.bsc]: [{
|
|
377
|
-
pair: 'bsctokensex',
|
|
378
|
-
key: 'erc20',
|
|
379
|
-
home: '0xf1DFc63e10fF01b8c3d307529b47AefaD2154C0e',
|
|
380
|
-
foreign: '0xb4005881e81a6ecd2c1f75d58e8e41f28d59c6b1',
|
|
381
|
-
}],
|
|
382
|
-
},
|
|
383
|
-
},
|
|
384
|
-
};
|
|
385
|
-
export const HOME_TO_FOREIGN_FEE = keccak256(stringToHex("homeToForeignFee"));
|
|
386
|
-
export const FOREIGN_TO_HOME_FEE = keccak256(stringToHex("foreignToHomeFee"));
|
package/dist/src/fee-type.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/** The type of fee to use for the bridge */
|
|
2
|
-
export declare enum FeeType {
|
|
3
|
-
PERCENT = "%",
|
|
4
|
-
GAS_TIP = "gas+%",
|
|
5
|
-
FIXED = "fixed"
|
|
6
|
-
}
|
|
7
|
-
/** The keys of the fee type */
|
|
8
|
-
export type FeeTypeKeys = keyof typeof FeeType;
|
|
9
|
-
/** A map of fee type values to keys */
|
|
10
|
-
export declare const feeTypeValToKeyMap: Map<FeeType, "PERCENT" | "GAS_TIP" | "FIXED">;
|
package/dist/src/fee-type.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/** The type of fee to use for the bridge */
|
|
2
|
-
export var FeeType;
|
|
3
|
-
(function (FeeType) {
|
|
4
|
-
FeeType["PERCENT"] = "%";
|
|
5
|
-
FeeType["GAS_TIP"] = "gas+%";
|
|
6
|
-
FeeType["FIXED"] = "fixed";
|
|
7
|
-
})(FeeType || (FeeType = {}));
|
|
8
|
-
/** A map of fee type values to keys */
|
|
9
|
-
export const feeTypeValToKeyMap = new Map(Object.keys(FeeType).map((key) => [FeeType[key], key]));
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sets the image root for the bridge
|
|
3
|
-
* @param root - the root
|
|
4
|
-
*/
|
|
5
|
-
export declare const setImageRoot: (root: string) => void;
|
|
6
|
-
/**
|
|
7
|
-
* Returns the image root for the bridge
|
|
8
|
-
* @returns the image root
|
|
9
|
-
*/
|
|
10
|
-
export declare const getImageRoot: () => string;
|
|
11
|
-
/** The minimal token info */
|
|
12
|
-
interface MinimalTokenInfo {
|
|
13
|
-
chainId: number;
|
|
14
|
-
address: string;
|
|
15
|
-
logoURI?: string | null;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Returns the list image for the given path
|
|
19
|
-
* @param path - the path
|
|
20
|
-
* @returns the list image
|
|
21
|
-
*/
|
|
22
|
-
export declare const list: (path: string) => string;
|
|
23
|
-
/**
|
|
24
|
-
* Returns the network image for the given chain id
|
|
25
|
-
* @param chainId - the chain id
|
|
26
|
-
* @returns the network image
|
|
27
|
-
*/
|
|
28
|
-
export declare const network: (chainId: number) => string;
|
|
29
|
-
/**
|
|
30
|
-
* Returns the image url for the given token info
|
|
31
|
-
* @param t - the token info
|
|
32
|
-
* @returns the image url
|
|
33
|
-
*/
|
|
34
|
-
export declare const image: (t: MinimalTokenInfo) => string;
|
|
35
|
-
/**
|
|
36
|
-
* Returns a url that will lookup all sources for the given array
|
|
37
|
-
* @param sources - the sources
|
|
38
|
-
* @returns the images
|
|
39
|
-
*/
|
|
40
|
-
export declare const images: (sources: string[]) => string;
|
|
41
|
-
export {};
|
package/dist/src/image-links.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { getAddress } from 'viem';
|
|
2
|
-
let imageRoot = 'https://gib.show';
|
|
3
|
-
/**
|
|
4
|
-
* Sets the image root for the bridge
|
|
5
|
-
* @param root - the root
|
|
6
|
-
*/
|
|
7
|
-
export const setImageRoot = (root) => {
|
|
8
|
-
imageRoot = root;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Returns the image root for the bridge
|
|
12
|
-
* @returns the image root
|
|
13
|
-
*/
|
|
14
|
-
export const getImageRoot = () => imageRoot;
|
|
15
|
-
/**
|
|
16
|
-
* Returns the list image for the given path
|
|
17
|
-
* @param path - the path
|
|
18
|
-
* @returns the list image
|
|
19
|
-
*/
|
|
20
|
-
export const list = (path) => {
|
|
21
|
-
return `${imageRoot}/list${path}`;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Returns the network image for the given chain id
|
|
25
|
-
* @param chainId - the chain id
|
|
26
|
-
* @returns the network image
|
|
27
|
-
*/
|
|
28
|
-
export const network = (chainId) => {
|
|
29
|
-
if (!chainId) {
|
|
30
|
-
console.trace('network image');
|
|
31
|
-
}
|
|
32
|
-
return `${imageRoot}/image/${Number(chainId)}`;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Returns the image url for the given token info
|
|
36
|
-
* @param t - the token info
|
|
37
|
-
* @returns the image url
|
|
38
|
-
*/
|
|
39
|
-
export const image = (t) => t.logoURI || `${network(t.chainId)}/${getAddress(t.address)}`;
|
|
40
|
-
/**
|
|
41
|
-
* Returns a url that will lookup all sources for the given array
|
|
42
|
-
* @param sources - the sources
|
|
43
|
-
* @returns the images
|
|
44
|
-
*/
|
|
45
|
-
export const images = (sources) => `${imageRoot}/image/?${sources.map((s) => `i=${s}`).join('&')}`;
|
package/dist/src/index.d.ts
DELETED
package/dist/src/index.js
DELETED