@gibs/bridge-sdk 1.7.3 → 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.
@@ -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)']);
@@ -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<`0x${string}`[]>) & _.MemoizedFunction;
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
@@ -46,7 +46,7 @@ export const chainsMetadata = {
46
46
  alt: 'a gold cube with slits in the middle of each side',
47
47
  rpcUrls: {
48
48
  default: {
49
- http: ['https://bsc-pokt.nodies.app'],
49
+ http: ['https://bsc-rpc.publicnode.com'],
50
50
  },
51
51
  },
52
52
  },
@@ -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
- /** The provider of an omnibridge */
30
- export declare enum Provider {
31
- PULSECHAIN = "pulsechain",
32
- TOKENSEX = "tokensex"
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}`;
@@ -1,4 +1,4 @@
1
- import { getAddress, zeroAddress } from "viem";
1
+ import { getAddress, keccak256, stringToHex, zeroAddress } from "viem";
2
2
  import _ from 'lodash';
3
3
  /**
4
4
  * Add here your chain id as hex, be sure to add your chain in the chainsMetadata object too
@@ -27,12 +27,15 @@ export const toChain = (chainId) => `0x${Number(chainId).toString(16)}`;
27
27
  * @returns the chain key
28
28
  */
29
29
  export const toChainKey = (chainId) => chainIdToKey.get(toChain(chainId));
30
- /** The provider of an omnibridge */
31
- export var Provider;
32
- (function (Provider) {
33
- Provider["PULSECHAIN"] = "pulsechain";
34
- Provider["TOKENSEX"] = "tokensex";
35
- })(Provider || (Provider = {}));
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
+ };
36
39
  /** A map of chains to native asset out addresses */
37
40
  export const nativeAssetOut = {
38
41
  [Chains.ETH]: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
@@ -83,7 +86,7 @@ const pulsechainPLSETHSettings = {
83
86
  nativeRouter: '0xE66877Cfe4CEc10ffBbBB3092B7001321AB5809D',
84
87
  };
85
88
  export const pathways = {
86
- [Provider.PULSECHAIN]: {
89
+ [Providers.PULSECHAIN]: {
87
90
  [Chains.PLS]: {
88
91
  [Chains.ETH]: {
89
92
  from: '0x4fD0aaa7506f3d9cB8274bdB946Ec42A1b8751Ef',
@@ -127,7 +130,7 @@ export const pathways = {
127
130
  },
128
131
  },
129
132
  },
130
- [Provider.TOKENSEX]: {
133
+ [Providers.TOKENSEX]: {
131
134
  [Chains.PLS]: {
132
135
  [Chains.BNB]: {
133
136
  from: '0xf1DFc63e10fF01b8c3d307529b47AefaD2154C0e',
@@ -161,7 +164,7 @@ export const pathways = {
161
164
  },
162
165
  };
163
166
  export const testnetPathways = {
164
- [Provider.TOKENSEX]: {
167
+ [Providers.TOKENSEX]: {
165
168
  // plsv4 to bnb home omnibridge: 0xfd0c07C376D27EA0E9fA64Ac5D2481439e36CF9C
166
169
  // [Chains.BNB]: {
167
170
  // [Chains.V4PLS]: {
@@ -184,7 +187,7 @@ export const testnetPathways = {
184
187
  // },
185
188
  // },
186
189
  },
187
- [Provider.PULSECHAIN]: {
190
+ [Providers.PULSECHAIN]: {
188
191
  [Chains.V4PLS]: {
189
192
  [Chains.SEP]: {
190
193
  from: '0x6B08a50865aDeCe6e3869D9AfbB316d0a0436B6c',
@@ -217,15 +220,15 @@ export const testnetPathways = {
217
220
  };
218
221
  /** The mainnet bridge keys */
219
222
  const mainnetBridgeKeys = [
220
- [Provider.PULSECHAIN, Chains.PLS, Chains.ETH],
221
- [Provider.PULSECHAIN, Chains.ETH, Chains.PLS],
222
- [Provider.TOKENSEX, Chains.PLS, Chains.BNB],
223
- [Provider.TOKENSEX, Chains.BNB, Chains.PLS],
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],
224
227
  ];
225
228
  /** The testnet bridge keys */
226
229
  const testnetBridgeKeys = [
227
- [Provider.PULSECHAIN, Chains.SEP, Chains.V4PLS],
228
- [Provider.PULSECHAIN, Chains.V4PLS, Chains.SEP],
230
+ [Providers.PULSECHAIN, Chains.SEP, Chains.V4PLS],
231
+ [Providers.PULSECHAIN, Chains.V4PLS, Chains.SEP],
229
232
  ];
230
233
  /** Returns the valid bridge keys for the given is prod */
231
234
  export const validBridgeKeys = (isProd) => [
@@ -330,3 +333,54 @@ export const isUnwrappable = (bridgeKey, assetIn) => {
330
333
  export const canChangeUnwrap = (bridgeKey, assetIn) => {
331
334
  return !!assetIn && isUnwrappable(bridgeKey, assetIn);
332
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"));