@cowprotocol/sdk-bridging 0.6.1 → 0.8.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 CHANGED
@@ -132,7 +132,7 @@ const parameters: QuoteBridgeRequest = {
132
132
  appCode: 'YOUR_APP_CODE',
133
133
  }
134
134
 
135
- const quoteResult = await sdk.bridging.getQuote(parameters)
135
+ const quoteResult = await bridgingSdk.getQuote(parameters)
136
136
  assertIsBridgeQuoteAndPost(quoteResult)
137
137
  const { swap, bridge, postSwapOrderFromQuote } = quoteResult
138
138
 
@@ -171,7 +171,7 @@ const multiQuoteRequest: MultiQuoteRequest = {
171
171
  }
172
172
 
173
173
  // Get quotes from all providers
174
- const results = await sdk.bridging.getMultiQuotes(multiQuoteRequest)
174
+ const results = await bridgingSdk.getMultiQuotes(multiQuoteRequest)
175
175
 
176
176
  results.forEach((result) => {
177
177
  if (result.quote) {
@@ -210,7 +210,7 @@ const multiQuoteRequest: MultiQuoteRequest = {
210
210
  }
211
211
 
212
212
  // This will return all results once completed (or timed out)
213
- const finalResults = await sdk.bridging.getMultiQuotes(multiQuoteRequest)
213
+ const finalResults = await bridgingSdk.getMultiQuotes(multiQuoteRequest)
214
214
 
215
215
  console.log(`Received ${finalResults.filter(r => r.quote).length} successful quotes out of ${finalResults.length} providers`)
216
216
  ```
@@ -227,7 +227,7 @@ const fetchQuotes = async () => {
227
227
  setQuotes([])
228
228
 
229
229
  try {
230
- const results = await sdk.bridging.getMultiQuotes({
230
+ const results = await bridgingSdk.getMultiQuotes({
231
231
  quoteBridgeRequest: parameters,
232
232
  options: {
233
233
  onQuoteResult: (result) => {
@@ -280,7 +280,7 @@ const isBestQuote = (result: MultiQuoteResult): boolean => {
280
280
  The `getMultiQuotes()` method supports two types of timeouts for fine-grained control:
281
281
 
282
282
  ```typescript
283
- const results = await sdk.bridging.getMultiQuotes({
283
+ const results = await bridgingSdk.getMultiQuotes({
284
284
  quoteBridgeRequest: parameters,
285
285
  options: {
286
286
  // Global timeout: Maximum time to wait for all providers to complete
@@ -312,7 +312,7 @@ The `getBestQuote()` method provides an optimized way to get only the best quote
312
312
  import { MultiQuoteRequest } from '@cowprotocol/sdk-bridging'
313
313
 
314
314
  // Get the best quote from all available providers
315
- const bestQuote = await sdk.bridging.getBestQuote({
315
+ const bestQuote = await bridgingSdk.getBestQuote({
316
316
  quoteBridgeRequest: parameters, // Same parameters as above
317
317
  providerDappIds: ['provider1', 'provider2'], // Optional: specify which providers to query
318
318
  advancedSettings: {
@@ -342,7 +342,7 @@ For real-time updates, you can receive notifications each time a better quote is
342
342
  ```typescript
343
343
  let currentBest: MultiQuoteResult | null = null
344
344
 
345
- const bestQuote = await sdk.bridging.getBestQuote({
345
+ const bestQuote = await bridgingSdk.getBestQuote({
346
346
  quoteBridgeRequest: parameters,
347
347
  options: {
348
348
  // Called whenever a better quote is found
@@ -371,7 +371,7 @@ console.log('Final best quote:', bestQuote)
371
371
  When all providers fail, `getBestQuote()` returns the first provider's error:
372
372
 
373
373
  ```typescript
374
- const bestQuote = await sdk.bridging.getBestQuote({
374
+ const bestQuote = await bridgingSdk.getBestQuote({
375
375
  quoteBridgeRequest: parameters,
376
376
  options: {
377
377
  onQuoteResult: (result) => {
@@ -414,6 +414,75 @@ Choose `getMultiQuotes()` when:
414
414
  - You want to analyze all provider responses
415
415
  - You need to show provider-specific errors or statuses
416
416
 
417
+ ## Provider Management
418
+
419
+ The BridgingSdk provides methods to manage which bridge providers are actively used for quotes and operations.
420
+
421
+ ### Getting Available Providers
422
+
423
+ Use `getAvailableProviders()` to retrieve the list of currently active providers:
424
+
425
+ ```typescript
426
+ // Get all active providers
427
+ const providers = bridgingSdk.getAvailableProviders()
428
+
429
+ providers.forEach((provider) => {
430
+ console.log(`Provider: ${provider.info.name}`)
431
+ console.log(`Dapp ID: ${provider.info.dappId}`)
432
+ console.log(`Networks: ${provider.info.supportedChains.join(', ')}`)
433
+ })
434
+ ```
435
+
436
+ ### Filtering Active Providers
437
+
438
+ Use `setAvailableProviders()` to dynamically filter which providers should be used for bridge operations:
439
+
440
+ ```typescript
441
+ // Initially, all configured providers are available
442
+ const allProviders = bridgingSdk.getAvailableProviders()
443
+ console.log(`Total providers: ${allProviders.length}`)
444
+
445
+ // Filter to use only specific providers
446
+ bridgingSdk.setAvailableProviders(['across', 'hop-protocol'])
447
+
448
+ // Now only the specified providers will be used
449
+ const filteredProviders = bridgingSdk.getAvailableProviders()
450
+ console.log(`Active providers: ${filteredProviders.length}`)
451
+
452
+ // Reset to use all providers again
453
+ bridgingSdk.setAvailableProviders([])
454
+ const resetProviders = bridgingSdk.getAvailableProviders()
455
+ console.log(`Reset to all providers: ${resetProviders.length}`)
456
+ ```
457
+
458
+ ### Dynamic Provider Selection Example
459
+
460
+ ```typescript
461
+ // Example: Let users select their preferred bridge providers
462
+ const [selectedProviders, setSelectedProviders] = useState<string[]>([])
463
+
464
+ // Function to update active providers based on user selection
465
+ const updateActiveProviders = (providerIds: string[]) => {
466
+ bridgingSdk.setAvailableProviders(providerIds)
467
+ setSelectedProviders(providerIds)
468
+
469
+ console.log(`Updated to use ${providerIds.length} provider(s)`)
470
+ }
471
+
472
+ // Get quotes only from selected providers
473
+ const getQuotesFromSelectedProviders = async () => {
474
+ // The SDK will automatically use only the providers set via setAvailableProviders
475
+ const quote = await bridgingSdk.getQuote(parameters)
476
+ // Or for multi-provider quotes
477
+ const multiQuotes = await bridgingSdk.getMultiQuotes({
478
+ quoteBridgeRequest: parameters
479
+ // No need to specify providerDappIds, setAvailableProviders already filtered them
480
+ })
481
+
482
+ return quote
483
+ }
484
+ ```
485
+
417
486
  ## Supported Bridge Providers
418
487
 
419
488
  - Additional bridge providers are being integrated
package/dist/index.d.mts CHANGED
@@ -4,12 +4,16 @@ import { ChainInfo, TargetChainId, SupportedChainId, TokenInfo, ChainId, EvmCall
4
4
  import { QuoterParameters, TraderParameters, TradeOptionalParameters, QuoteAndPost, QuoteResults, SwapAdvancedSettings, SigningStepManager, OrderPostingResult, TradingSdk } from '@cowprotocol/sdk-trading';
5
5
  import { AccountAddress, SignerLike, TTLCache, AbstractProviderAdapter } from '@cowprotocol/sdk-common';
6
6
  import { CowShedSdk, CowShedSdkOptions } from '@cowprotocol/sdk-cow-shed';
7
+ import { TokenResponse, QuoteRequest, QuoteResponse, GetExecutionStatusResponse } from '@defuse-protocol/one-click-sdk-typescript';
8
+ import { Address as Address$1, Hex } from 'viem';
7
9
 
10
+ type BridgeProviderType = 'ReceiverAccountBridgeProvider' | 'HookBridgeProvider';
8
11
  interface BridgeProviderInfo {
9
12
  name: string;
10
13
  logoUrl: string;
11
14
  dappId: string;
12
15
  website: string;
16
+ type: BridgeProviderType;
13
17
  }
14
18
  interface WithSellToken {
15
19
  sellTokenChainId: SupportedChainId;
@@ -33,6 +37,14 @@ type QuoteBridgeRequest = {
33
37
  } & WithSellToken & WithBuyToken & WithQuoter & WithTrader & TradeOptionalParameters;
34
38
  type QuoteBridgeRequestWithoutAmount = Omit<QuoteBridgeRequest, 'amount'>;
35
39
  interface BridgeQuoteResult {
40
+ /**
41
+ * Unique ID of a quote
42
+ */
43
+ id?: string;
44
+ /**
45
+ * Provider who implement ReceiverAccountBridgeProvider must return a signature of a quote than will be used to verify the quote deposit address validity
46
+ */
47
+ signature?: string;
36
48
  /**
37
49
  * Whether the quote is a sell or buy order.
38
50
  */
@@ -128,7 +140,7 @@ interface BridgeDeposit extends Omit<QuoteBridgeRequest, 'amount'> {
128
140
  * It contains the main information about the provider, and the methods to get the quote, the bridging params, the status, the cancelling and the refunding of the bridging.
129
141
  */
130
142
  interface BridgeProvider<Q extends BridgeQuoteResult> {
131
- type: 'ReceiverAccountBridgeProvider' | 'HookBridgeProvider';
143
+ type: BridgeProviderType;
132
144
  info: BridgeProviderInfo;
133
145
  /**
134
146
  * Get basic supported chains
@@ -156,10 +168,10 @@ interface BridgeProvider<Q extends BridgeQuoteResult> {
156
168
  /**
157
169
  * Get the identifier of the bridging transaction from the settlement transaction.
158
170
  * @param chainId
159
- * @param orderUid - The unique identifier of the order
171
+ * @param order - CoW Protocol order
160
172
  * @param txHash - The hash of the settlement transaction in which the bridging post-hook was executed
161
173
  */
162
- getBridgingParams(chainId: ChainId, orderUid: string, txHash: string): Promise<{
174
+ getBridgingParams(chainId: ChainId, order: EnrichedOrder, txHash: string): Promise<{
163
175
  params: BridgingDepositParams;
164
176
  status: BridgeStatusResult;
165
177
  } | null>;
@@ -420,6 +432,7 @@ interface BestQuoteProviderContext extends MultiQuoteContext {
420
432
  current: MultiQuoteResult | null;
421
433
  };
422
434
  }
435
+ type DefaultBridgeProvider = BridgeProvider<BridgeQuoteResult>;
423
436
 
424
437
  declare enum BridgeQuoteErrors {
425
438
  NO_INTERMEDIATE_TOKENS = "NO_INTERMEDIATE_TOKENS",
@@ -429,7 +442,8 @@ declare enum BridgeQuoteErrors {
429
442
  TX_BUILD_ERROR = "TX_BUILD_ERROR",
430
443
  QUOTE_ERROR = "QUOTE_ERROR",
431
444
  NO_ROUTES = "NO_ROUTES",
432
- INVALID_BRIDGE = "INVALID_BRIDGE"
445
+ INVALID_BRIDGE = "INVALID_BRIDGE",
446
+ QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS = "QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS"
433
447
  }
434
448
  declare class BridgeProviderQuoteError extends Error {
435
449
  readonly context?: unknown | undefined;
@@ -448,7 +462,7 @@ declare function isBridgeQuoteAndPost(quote: CrossChainQuoteAndPost): quote is B
448
462
  declare function isQuoteAndPost(quote: CrossChainQuoteAndPost): quote is QuoteAndPost;
449
463
  declare function assertIsBridgeQuoteAndPost(quote: CrossChainQuoteAndPost): asserts quote is BridgeQuoteAndPost;
450
464
  declare function assertIsQuoteAndPost(quote: CrossChainQuoteAndPost): asserts quote is QuoteAndPost;
451
- declare function getPostHooks(fullAppData?: string): cowAppDataLatestScheme.CoWHook[];
465
+ declare function getPostHooks(fullAppData?: string | object): cowAppDataLatestScheme.CoWHook[];
452
466
  declare function isAppDoc(appData: unknown): appData is cowAppDataLatestScheme.AppDataRootSchema;
453
467
  declare function isHookBridgeProvider<Q extends BridgeQuoteResult>(provider: BridgeProvider<Q>): provider is HookBridgeProvider<Q>;
454
468
  declare function isReceiverAccountBridgeProvider<Q extends BridgeQuoteResult>(provider: BridgeProvider<Q>): provider is ReceiverAccountBridgeProvider<Q>;
@@ -523,12 +537,13 @@ declare class BridgingSdk {
523
537
  private singleQuoteStrategy;
524
538
  private multiQuoteStrategy;
525
539
  private bestQuoteStrategy;
540
+ private availableProvidersIds;
526
541
  constructor(options: BridgingSdkOptions, adapter?: AbstractProviderAdapter);
527
- private get provider();
542
+ setAvailableProviders(ids: string[]): void;
528
543
  /**
529
544
  * Get the providers for the bridging.
530
545
  */
531
- getProviders(): BridgeProvider<BridgeQuoteResult>[];
546
+ getAvailableProviders(): DefaultBridgeProvider[];
532
547
  /**
533
548
  * Get the available sources networks for the bridging.
534
549
  */
@@ -592,8 +607,7 @@ declare class BridgingSdk {
592
607
  */
593
608
  getBestQuote(request: MultiQuoteRequest): Promise<MultiQuoteResult | null>;
594
609
  getOrder(params: GetOrderParams): Promise<CrossChainOrder | null>;
595
- getOrderBridgingStatus(bridgingId: string, originChainId: SupportedChainId): Promise<BridgeStatusResult>;
596
- getProviderFromAppData(fullAppData: string): BridgeProvider<BridgeQuoteResult> | undefined;
610
+ getProviderFromAppData(fullAppData: string): DefaultBridgeProvider | undefined;
597
611
  /**
598
612
  * Clear all caches. Useful for testing and debugging.
599
613
  */
@@ -609,7 +623,8 @@ declare class BridgingSdk {
609
623
  intermediateTokens: number;
610
624
  buyTokens: number;
611
625
  };
612
- getProviderByDappId(dappId: string): BridgeProvider<BridgeQuoteResult> | undefined;
626
+ getProviderByDappId(dappId: string): DefaultBridgeProvider | undefined;
627
+ private getBuyTokensFromProvider;
613
628
  }
614
629
 
615
630
  declare const RAW_PROVIDERS_FILES_PATH = "https://raw.githubusercontent.com/cowprotocol/cow-sdk/refs/heads/main/src/bridging/providers";
@@ -900,7 +915,7 @@ declare class AcrossBridgeProvider implements HookBridgeProvider<AcrossQuoteResu
900
915
  getGasLimitEstimationForHook(request: QuoteBridgeRequest): Promise<number>;
901
916
  getSignedHook(chainId: SupportedChainId, unsignedCall: EvmCall, bridgeHookNonce: string, deadline: bigint, hookGasLimit: number, signer?: SignerLike): Promise<BridgeHook>;
902
917
  decodeBridgeHook(_hook: cowAppDataLatestScheme.CoWHook): Promise<BridgeDeposit>;
903
- getBridgingParams(chainId: ChainId, orderUid: string, txHash: string): Promise<{
918
+ getBridgingParams(chainId: ChainId, order: EnrichedOrder, txHash: string): Promise<{
904
919
  params: BridgingDepositParams;
905
920
  status: BridgeStatusResult;
906
921
  } | null>;
@@ -1220,7 +1235,7 @@ declare class BungeeBridgeProvider implements HookBridgeProvider<BungeeQuoteResu
1220
1235
  getUnsignedBridgeCall(request: QuoteBridgeRequest, quote: BungeeQuoteResult): Promise<EvmCall>;
1221
1236
  getGasLimitEstimationForHook(request: QuoteBridgeRequest): Promise<number>;
1222
1237
  getSignedHook(chainId: SupportedChainId, unsignedCall: EvmCall, bridgeHookNonce: string, deadline: bigint, hookGasLimit: number, signer?: SignerLike): Promise<BridgeHook>;
1223
- getBridgingParams(_chainId: ChainId, orderId: string, _txHash: string): Promise<{
1238
+ getBridgingParams(_chainId: ChainId, order: EnrichedOrder, _txHash: string): Promise<{
1224
1239
  params: BridgingDepositParams;
1225
1240
  status: BridgeStatusResult;
1226
1241
  } | null>;
@@ -1232,4 +1247,51 @@ declare class BungeeBridgeProvider implements HookBridgeProvider<BungeeQuoteResu
1232
1247
  private isExtraGasRequired;
1233
1248
  }
1234
1249
 
1235
- export { AcrossBridgeProvider, type AcrossBridgeProviderOptions, type AcrossQuoteResult, type BestQuoteProgressCallback, type BestQuoteProviderContext, type BridgeCallDetails, type BridgeCosts, type BridgeDeposit, type BridgeHook, BridgeOrderParsingError, type BridgeProvider, BridgeProviderError, type BridgeProviderInfo, BridgeProviderQuoteError, type BridgeQuoteAmountsAndCosts, type BridgeQuoteAndPost, BridgeQuoteErrors, type BridgeQuoteResult, type BridgeQuoteResults, BridgeStatus, type BridgeStatusResult, type BridgingDepositParams, BridgingSdk, BungeeBridgeProvider, type BungeeBridgeProviderOptions, type BungeeQuoteResult, type BuyTokensParams, COW_SHED_PROXY_CREATION_GAS, type CrossChainOrder, type CrossChainQuoteAndPost, DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION, DEFAULT_EXTRA_GAS_PROXY_CREATION, DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION, type GetProviderBuyTokens, HOOK_DAPP_BRIDGE_PROVIDER_PREFIX, type HookBridgeProvider, type MultiQuoteOptions, type MultiQuoteProgressCallback, type MultiQuoteRequest, type MultiQuoteResult, type ProviderQuoteContext, type QuoteBridgeRequest, type QuoteBridgeRequestWithoutAmount, RAW_PROVIDERS_FILES_PATH, type ReceiverAccountBridgeProvider, assertIsBridgeQuoteAndPost, assertIsQuoteAndPost, getCrossChainOrder, getPostHooks, isAppDoc, isBridgeQuoteAndPost, isHookBridgeProvider, isQuoteAndPost, isReceiverAccountBridgeProvider };
1250
+ interface GetAttestationRequest {
1251
+ depositAddress: Address$1;
1252
+ quoteHash: Hex;
1253
+ }
1254
+ interface GetAttestationResponse {
1255
+ signature: Hex;
1256
+ version: number;
1257
+ }
1258
+ declare class NearIntentsApi {
1259
+ private cachedTokens;
1260
+ getTokens(): Promise<TokenResponse[]>;
1261
+ getQuote(request: QuoteRequest): Promise<QuoteResponse>;
1262
+ getStatus(depositAddress: string): Promise<GetExecutionStatusResponse>;
1263
+ getAttestation(request: GetAttestationRequest): Promise<GetAttestationResponse>;
1264
+ }
1265
+
1266
+ interface NearIntentsQuoteResult extends BridgeQuoteResult {
1267
+ depositAddress: Hex;
1268
+ }
1269
+ interface NearIntentsBridgeProviderOptions {
1270
+ cowShedOptions?: CowShedSdkOptions;
1271
+ }
1272
+ declare class NearIntentsBridgeProvider implements ReceiverAccountBridgeProvider<NearIntentsQuoteResult> {
1273
+ type: "ReceiverAccountBridgeProvider";
1274
+ protected api: NearIntentsApi;
1275
+ protected cowShedSdk: CowShedSdk;
1276
+ info: BridgeProviderInfo;
1277
+ constructor(options?: NearIntentsBridgeProviderOptions, _adapter?: AbstractProviderAdapter);
1278
+ getNetworks(): Promise<ChainInfo[]>;
1279
+ getBuyTokens(params: BuyTokensParams): Promise<GetProviderBuyTokens>;
1280
+ getIntermediateTokens(request: QuoteBridgeRequest): Promise<TokenInfo[]>;
1281
+ getQuote(request: QuoteBridgeRequest): Promise<NearIntentsQuoteResult>;
1282
+ getBridgeReceiverOverride(_request: QuoteBridgeRequest, quote: NearIntentsQuoteResult): Promise<string>;
1283
+ getBridgingParams(_chainId: ChainId, order: EnrichedOrder, _txHash: string): Promise<{
1284
+ params: BridgingDepositParams;
1285
+ status: BridgeStatusResult;
1286
+ } | null>;
1287
+ getExplorerUrl(bridgingId: string): string;
1288
+ getStatus(bridgingId: string, _originChainId: SupportedChainId): Promise<BridgeStatusResult>;
1289
+ getCancelBridgingTx(_bridgingId: string): Promise<EvmCall>;
1290
+ getRefundBridgingTx(_bridgingId: string): Promise<EvmCall>;
1291
+ recoverDepositAddress({ quote, quoteRequest, timestamp, }: QuoteResponse): Promise<{
1292
+ address: Address$1;
1293
+ quoteHash: string;
1294
+ } | null>;
1295
+ }
1296
+
1297
+ export { AcrossBridgeProvider, type AcrossBridgeProviderOptions, type AcrossQuoteResult, type BestQuoteProgressCallback, type BestQuoteProviderContext, type BridgeCallDetails, type BridgeCosts, type BridgeDeposit, type BridgeHook, BridgeOrderParsingError, type BridgeProvider, BridgeProviderError, type BridgeProviderInfo, BridgeProviderQuoteError, type BridgeProviderType, type BridgeQuoteAmountsAndCosts, type BridgeQuoteAndPost, BridgeQuoteErrors, type BridgeQuoteResult, type BridgeQuoteResults, BridgeStatus, type BridgeStatusResult, type BridgingDepositParams, BridgingSdk, BungeeBridgeProvider, type BungeeBridgeProviderOptions, type BungeeQuoteResult, type BuyTokensParams, COW_SHED_PROXY_CREATION_GAS, type CrossChainOrder, type CrossChainQuoteAndPost, DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION, DEFAULT_EXTRA_GAS_PROXY_CREATION, DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION, type DefaultBridgeProvider, type GetProviderBuyTokens, HOOK_DAPP_BRIDGE_PROVIDER_PREFIX, type HookBridgeProvider, type MultiQuoteOptions, type MultiQuoteProgressCallback, type MultiQuoteRequest, type MultiQuoteResult, NearIntentsBridgeProvider, type NearIntentsBridgeProviderOptions, type NearIntentsQuoteResult, type ProviderQuoteContext, type QuoteBridgeRequest, type QuoteBridgeRequestWithoutAmount, RAW_PROVIDERS_FILES_PATH, type ReceiverAccountBridgeProvider, assertIsBridgeQuoteAndPost, assertIsQuoteAndPost, getCrossChainOrder, getPostHooks, isAppDoc, isBridgeQuoteAndPost, isHookBridgeProvider, isQuoteAndPost, isReceiverAccountBridgeProvider };
package/dist/index.d.ts CHANGED
@@ -4,12 +4,16 @@ import { ChainInfo, TargetChainId, SupportedChainId, TokenInfo, ChainId, EvmCall
4
4
  import { QuoterParameters, TraderParameters, TradeOptionalParameters, QuoteAndPost, QuoteResults, SwapAdvancedSettings, SigningStepManager, OrderPostingResult, TradingSdk } from '@cowprotocol/sdk-trading';
5
5
  import { AccountAddress, SignerLike, TTLCache, AbstractProviderAdapter } from '@cowprotocol/sdk-common';
6
6
  import { CowShedSdk, CowShedSdkOptions } from '@cowprotocol/sdk-cow-shed';
7
+ import { TokenResponse, QuoteRequest, QuoteResponse, GetExecutionStatusResponse } from '@defuse-protocol/one-click-sdk-typescript';
8
+ import { Address as Address$1, Hex } from 'viem';
7
9
 
10
+ type BridgeProviderType = 'ReceiverAccountBridgeProvider' | 'HookBridgeProvider';
8
11
  interface BridgeProviderInfo {
9
12
  name: string;
10
13
  logoUrl: string;
11
14
  dappId: string;
12
15
  website: string;
16
+ type: BridgeProviderType;
13
17
  }
14
18
  interface WithSellToken {
15
19
  sellTokenChainId: SupportedChainId;
@@ -33,6 +37,14 @@ type QuoteBridgeRequest = {
33
37
  } & WithSellToken & WithBuyToken & WithQuoter & WithTrader & TradeOptionalParameters;
34
38
  type QuoteBridgeRequestWithoutAmount = Omit<QuoteBridgeRequest, 'amount'>;
35
39
  interface BridgeQuoteResult {
40
+ /**
41
+ * Unique ID of a quote
42
+ */
43
+ id?: string;
44
+ /**
45
+ * Provider who implement ReceiverAccountBridgeProvider must return a signature of a quote than will be used to verify the quote deposit address validity
46
+ */
47
+ signature?: string;
36
48
  /**
37
49
  * Whether the quote is a sell or buy order.
38
50
  */
@@ -128,7 +140,7 @@ interface BridgeDeposit extends Omit<QuoteBridgeRequest, 'amount'> {
128
140
  * It contains the main information about the provider, and the methods to get the quote, the bridging params, the status, the cancelling and the refunding of the bridging.
129
141
  */
130
142
  interface BridgeProvider<Q extends BridgeQuoteResult> {
131
- type: 'ReceiverAccountBridgeProvider' | 'HookBridgeProvider';
143
+ type: BridgeProviderType;
132
144
  info: BridgeProviderInfo;
133
145
  /**
134
146
  * Get basic supported chains
@@ -156,10 +168,10 @@ interface BridgeProvider<Q extends BridgeQuoteResult> {
156
168
  /**
157
169
  * Get the identifier of the bridging transaction from the settlement transaction.
158
170
  * @param chainId
159
- * @param orderUid - The unique identifier of the order
171
+ * @param order - CoW Protocol order
160
172
  * @param txHash - The hash of the settlement transaction in which the bridging post-hook was executed
161
173
  */
162
- getBridgingParams(chainId: ChainId, orderUid: string, txHash: string): Promise<{
174
+ getBridgingParams(chainId: ChainId, order: EnrichedOrder, txHash: string): Promise<{
163
175
  params: BridgingDepositParams;
164
176
  status: BridgeStatusResult;
165
177
  } | null>;
@@ -420,6 +432,7 @@ interface BestQuoteProviderContext extends MultiQuoteContext {
420
432
  current: MultiQuoteResult | null;
421
433
  };
422
434
  }
435
+ type DefaultBridgeProvider = BridgeProvider<BridgeQuoteResult>;
423
436
 
424
437
  declare enum BridgeQuoteErrors {
425
438
  NO_INTERMEDIATE_TOKENS = "NO_INTERMEDIATE_TOKENS",
@@ -429,7 +442,8 @@ declare enum BridgeQuoteErrors {
429
442
  TX_BUILD_ERROR = "TX_BUILD_ERROR",
430
443
  QUOTE_ERROR = "QUOTE_ERROR",
431
444
  NO_ROUTES = "NO_ROUTES",
432
- INVALID_BRIDGE = "INVALID_BRIDGE"
445
+ INVALID_BRIDGE = "INVALID_BRIDGE",
446
+ QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS = "QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS"
433
447
  }
434
448
  declare class BridgeProviderQuoteError extends Error {
435
449
  readonly context?: unknown | undefined;
@@ -448,7 +462,7 @@ declare function isBridgeQuoteAndPost(quote: CrossChainQuoteAndPost): quote is B
448
462
  declare function isQuoteAndPost(quote: CrossChainQuoteAndPost): quote is QuoteAndPost;
449
463
  declare function assertIsBridgeQuoteAndPost(quote: CrossChainQuoteAndPost): asserts quote is BridgeQuoteAndPost;
450
464
  declare function assertIsQuoteAndPost(quote: CrossChainQuoteAndPost): asserts quote is QuoteAndPost;
451
- declare function getPostHooks(fullAppData?: string): cowAppDataLatestScheme.CoWHook[];
465
+ declare function getPostHooks(fullAppData?: string | object): cowAppDataLatestScheme.CoWHook[];
452
466
  declare function isAppDoc(appData: unknown): appData is cowAppDataLatestScheme.AppDataRootSchema;
453
467
  declare function isHookBridgeProvider<Q extends BridgeQuoteResult>(provider: BridgeProvider<Q>): provider is HookBridgeProvider<Q>;
454
468
  declare function isReceiverAccountBridgeProvider<Q extends BridgeQuoteResult>(provider: BridgeProvider<Q>): provider is ReceiverAccountBridgeProvider<Q>;
@@ -523,12 +537,13 @@ declare class BridgingSdk {
523
537
  private singleQuoteStrategy;
524
538
  private multiQuoteStrategy;
525
539
  private bestQuoteStrategy;
540
+ private availableProvidersIds;
526
541
  constructor(options: BridgingSdkOptions, adapter?: AbstractProviderAdapter);
527
- private get provider();
542
+ setAvailableProviders(ids: string[]): void;
528
543
  /**
529
544
  * Get the providers for the bridging.
530
545
  */
531
- getProviders(): BridgeProvider<BridgeQuoteResult>[];
546
+ getAvailableProviders(): DefaultBridgeProvider[];
532
547
  /**
533
548
  * Get the available sources networks for the bridging.
534
549
  */
@@ -592,8 +607,7 @@ declare class BridgingSdk {
592
607
  */
593
608
  getBestQuote(request: MultiQuoteRequest): Promise<MultiQuoteResult | null>;
594
609
  getOrder(params: GetOrderParams): Promise<CrossChainOrder | null>;
595
- getOrderBridgingStatus(bridgingId: string, originChainId: SupportedChainId): Promise<BridgeStatusResult>;
596
- getProviderFromAppData(fullAppData: string): BridgeProvider<BridgeQuoteResult> | undefined;
610
+ getProviderFromAppData(fullAppData: string): DefaultBridgeProvider | undefined;
597
611
  /**
598
612
  * Clear all caches. Useful for testing and debugging.
599
613
  */
@@ -609,7 +623,8 @@ declare class BridgingSdk {
609
623
  intermediateTokens: number;
610
624
  buyTokens: number;
611
625
  };
612
- getProviderByDappId(dappId: string): BridgeProvider<BridgeQuoteResult> | undefined;
626
+ getProviderByDappId(dappId: string): DefaultBridgeProvider | undefined;
627
+ private getBuyTokensFromProvider;
613
628
  }
614
629
 
615
630
  declare const RAW_PROVIDERS_FILES_PATH = "https://raw.githubusercontent.com/cowprotocol/cow-sdk/refs/heads/main/src/bridging/providers";
@@ -900,7 +915,7 @@ declare class AcrossBridgeProvider implements HookBridgeProvider<AcrossQuoteResu
900
915
  getGasLimitEstimationForHook(request: QuoteBridgeRequest): Promise<number>;
901
916
  getSignedHook(chainId: SupportedChainId, unsignedCall: EvmCall, bridgeHookNonce: string, deadline: bigint, hookGasLimit: number, signer?: SignerLike): Promise<BridgeHook>;
902
917
  decodeBridgeHook(_hook: cowAppDataLatestScheme.CoWHook): Promise<BridgeDeposit>;
903
- getBridgingParams(chainId: ChainId, orderUid: string, txHash: string): Promise<{
918
+ getBridgingParams(chainId: ChainId, order: EnrichedOrder, txHash: string): Promise<{
904
919
  params: BridgingDepositParams;
905
920
  status: BridgeStatusResult;
906
921
  } | null>;
@@ -1220,7 +1235,7 @@ declare class BungeeBridgeProvider implements HookBridgeProvider<BungeeQuoteResu
1220
1235
  getUnsignedBridgeCall(request: QuoteBridgeRequest, quote: BungeeQuoteResult): Promise<EvmCall>;
1221
1236
  getGasLimitEstimationForHook(request: QuoteBridgeRequest): Promise<number>;
1222
1237
  getSignedHook(chainId: SupportedChainId, unsignedCall: EvmCall, bridgeHookNonce: string, deadline: bigint, hookGasLimit: number, signer?: SignerLike): Promise<BridgeHook>;
1223
- getBridgingParams(_chainId: ChainId, orderId: string, _txHash: string): Promise<{
1238
+ getBridgingParams(_chainId: ChainId, order: EnrichedOrder, _txHash: string): Promise<{
1224
1239
  params: BridgingDepositParams;
1225
1240
  status: BridgeStatusResult;
1226
1241
  } | null>;
@@ -1232,4 +1247,51 @@ declare class BungeeBridgeProvider implements HookBridgeProvider<BungeeQuoteResu
1232
1247
  private isExtraGasRequired;
1233
1248
  }
1234
1249
 
1235
- export { AcrossBridgeProvider, type AcrossBridgeProviderOptions, type AcrossQuoteResult, type BestQuoteProgressCallback, type BestQuoteProviderContext, type BridgeCallDetails, type BridgeCosts, type BridgeDeposit, type BridgeHook, BridgeOrderParsingError, type BridgeProvider, BridgeProviderError, type BridgeProviderInfo, BridgeProviderQuoteError, type BridgeQuoteAmountsAndCosts, type BridgeQuoteAndPost, BridgeQuoteErrors, type BridgeQuoteResult, type BridgeQuoteResults, BridgeStatus, type BridgeStatusResult, type BridgingDepositParams, BridgingSdk, BungeeBridgeProvider, type BungeeBridgeProviderOptions, type BungeeQuoteResult, type BuyTokensParams, COW_SHED_PROXY_CREATION_GAS, type CrossChainOrder, type CrossChainQuoteAndPost, DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION, DEFAULT_EXTRA_GAS_PROXY_CREATION, DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION, type GetProviderBuyTokens, HOOK_DAPP_BRIDGE_PROVIDER_PREFIX, type HookBridgeProvider, type MultiQuoteOptions, type MultiQuoteProgressCallback, type MultiQuoteRequest, type MultiQuoteResult, type ProviderQuoteContext, type QuoteBridgeRequest, type QuoteBridgeRequestWithoutAmount, RAW_PROVIDERS_FILES_PATH, type ReceiverAccountBridgeProvider, assertIsBridgeQuoteAndPost, assertIsQuoteAndPost, getCrossChainOrder, getPostHooks, isAppDoc, isBridgeQuoteAndPost, isHookBridgeProvider, isQuoteAndPost, isReceiverAccountBridgeProvider };
1250
+ interface GetAttestationRequest {
1251
+ depositAddress: Address$1;
1252
+ quoteHash: Hex;
1253
+ }
1254
+ interface GetAttestationResponse {
1255
+ signature: Hex;
1256
+ version: number;
1257
+ }
1258
+ declare class NearIntentsApi {
1259
+ private cachedTokens;
1260
+ getTokens(): Promise<TokenResponse[]>;
1261
+ getQuote(request: QuoteRequest): Promise<QuoteResponse>;
1262
+ getStatus(depositAddress: string): Promise<GetExecutionStatusResponse>;
1263
+ getAttestation(request: GetAttestationRequest): Promise<GetAttestationResponse>;
1264
+ }
1265
+
1266
+ interface NearIntentsQuoteResult extends BridgeQuoteResult {
1267
+ depositAddress: Hex;
1268
+ }
1269
+ interface NearIntentsBridgeProviderOptions {
1270
+ cowShedOptions?: CowShedSdkOptions;
1271
+ }
1272
+ declare class NearIntentsBridgeProvider implements ReceiverAccountBridgeProvider<NearIntentsQuoteResult> {
1273
+ type: "ReceiverAccountBridgeProvider";
1274
+ protected api: NearIntentsApi;
1275
+ protected cowShedSdk: CowShedSdk;
1276
+ info: BridgeProviderInfo;
1277
+ constructor(options?: NearIntentsBridgeProviderOptions, _adapter?: AbstractProviderAdapter);
1278
+ getNetworks(): Promise<ChainInfo[]>;
1279
+ getBuyTokens(params: BuyTokensParams): Promise<GetProviderBuyTokens>;
1280
+ getIntermediateTokens(request: QuoteBridgeRequest): Promise<TokenInfo[]>;
1281
+ getQuote(request: QuoteBridgeRequest): Promise<NearIntentsQuoteResult>;
1282
+ getBridgeReceiverOverride(_request: QuoteBridgeRequest, quote: NearIntentsQuoteResult): Promise<string>;
1283
+ getBridgingParams(_chainId: ChainId, order: EnrichedOrder, _txHash: string): Promise<{
1284
+ params: BridgingDepositParams;
1285
+ status: BridgeStatusResult;
1286
+ } | null>;
1287
+ getExplorerUrl(bridgingId: string): string;
1288
+ getStatus(bridgingId: string, _originChainId: SupportedChainId): Promise<BridgeStatusResult>;
1289
+ getCancelBridgingTx(_bridgingId: string): Promise<EvmCall>;
1290
+ getRefundBridgingTx(_bridgingId: string): Promise<EvmCall>;
1291
+ recoverDepositAddress({ quote, quoteRequest, timestamp, }: QuoteResponse): Promise<{
1292
+ address: Address$1;
1293
+ quoteHash: string;
1294
+ } | null>;
1295
+ }
1296
+
1297
+ export { AcrossBridgeProvider, type AcrossBridgeProviderOptions, type AcrossQuoteResult, type BestQuoteProgressCallback, type BestQuoteProviderContext, type BridgeCallDetails, type BridgeCosts, type BridgeDeposit, type BridgeHook, BridgeOrderParsingError, type BridgeProvider, BridgeProviderError, type BridgeProviderInfo, BridgeProviderQuoteError, type BridgeProviderType, type BridgeQuoteAmountsAndCosts, type BridgeQuoteAndPost, BridgeQuoteErrors, type BridgeQuoteResult, type BridgeQuoteResults, BridgeStatus, type BridgeStatusResult, type BridgingDepositParams, BridgingSdk, BungeeBridgeProvider, type BungeeBridgeProviderOptions, type BungeeQuoteResult, type BuyTokensParams, COW_SHED_PROXY_CREATION_GAS, type CrossChainOrder, type CrossChainQuoteAndPost, DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION, DEFAULT_EXTRA_GAS_PROXY_CREATION, DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION, type DefaultBridgeProvider, type GetProviderBuyTokens, HOOK_DAPP_BRIDGE_PROVIDER_PREFIX, type HookBridgeProvider, type MultiQuoteOptions, type MultiQuoteProgressCallback, type MultiQuoteRequest, type MultiQuoteResult, NearIntentsBridgeProvider, type NearIntentsBridgeProviderOptions, type NearIntentsQuoteResult, type ProviderQuoteContext, type QuoteBridgeRequest, type QuoteBridgeRequestWithoutAmount, RAW_PROVIDERS_FILES_PATH, type ReceiverAccountBridgeProvider, assertIsBridgeQuoteAndPost, assertIsQuoteAndPost, getCrossChainOrder, getPostHooks, isAppDoc, isBridgeQuoteAndPost, isHookBridgeProvider, isQuoteAndPost, isReceiverAccountBridgeProvider };