@cowprotocol/sdk-bridging 1.1.2 → 1.3.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/dist/index.d.mts +20 -4
- package/dist/index.d.ts +20 -4
- package/dist/index.js +35 -13
- package/dist/index.mjs +36 -14
- package/package.json +8 -8
package/dist/index.d.mts
CHANGED
|
@@ -49,6 +49,14 @@ interface BridgeQuoteResult {
|
|
|
49
49
|
* Provider who implement ReceiverAccountBridgeProvider must return a signature of a quote than will be used to verify the quote deposit address validity
|
|
50
50
|
*/
|
|
51
51
|
signature?: string;
|
|
52
|
+
/**
|
|
53
|
+
* For ReceiverAccountBridgeProvider, this is the attestation signature from the bridge provider that validates the deposit address. Empty for other provider types.
|
|
54
|
+
*/
|
|
55
|
+
attestationSignature?: string;
|
|
56
|
+
/**
|
|
57
|
+
* A stringified JSON of quote which is associated with the order.
|
|
58
|
+
*/
|
|
59
|
+
quoteBody?: string;
|
|
52
60
|
/**
|
|
53
61
|
* Whether the quote is a sell or buy order.
|
|
54
62
|
*/
|
|
@@ -1270,8 +1278,16 @@ declare class NearIntentsApi {
|
|
|
1270
1278
|
getAttestation(request: GetAttestationRequest): Promise<GetAttestationResponse>;
|
|
1271
1279
|
}
|
|
1272
1280
|
|
|
1281
|
+
interface DepositAddressContext {
|
|
1282
|
+
address: Address$1;
|
|
1283
|
+
quoteHash: string;
|
|
1284
|
+
stringifiedQuote: string;
|
|
1285
|
+
attestationSignature: string;
|
|
1286
|
+
}
|
|
1273
1287
|
interface NearIntentsQuoteResult extends BridgeQuoteResult {
|
|
1274
1288
|
depositAddress: Hex;
|
|
1289
|
+
attestationSignature: string;
|
|
1290
|
+
quoteBody: string;
|
|
1275
1291
|
}
|
|
1276
1292
|
interface NearIntentsBridgeProviderOptions {
|
|
1277
1293
|
cowShedOptions?: CowShedSdkOptions;
|
|
@@ -1295,10 +1311,10 @@ declare class NearIntentsBridgeProvider implements ReceiverAccountBridgeProvider
|
|
|
1295
1311
|
getStatus(bridgingId: string, _originChainId: SupportedChainId): Promise<BridgeStatusResult>;
|
|
1296
1312
|
getCancelBridgingTx(_bridgingId: string): Promise<EvmCall>;
|
|
1297
1313
|
getRefundBridgingTx(_bridgingId: string): Promise<EvmCall>;
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
} | null>;
|
|
1314
|
+
/**
|
|
1315
|
+
* A script to verify depositAddress from appData: https://codesandbox.io/p/sandbox/h7tngy
|
|
1316
|
+
*/
|
|
1317
|
+
recoverDepositAddress({ quote, quoteRequest, timestamp, }: QuoteResponse): Promise<DepositAddressContext | null>;
|
|
1302
1318
|
}
|
|
1303
1319
|
|
|
1304
1320
|
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, BridgeQuoteErrorPriorities, 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_BRIDGE_SLIPPAGE_BPS, 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 MultiQuoteContext, 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
|
@@ -49,6 +49,14 @@ interface BridgeQuoteResult {
|
|
|
49
49
|
* Provider who implement ReceiverAccountBridgeProvider must return a signature of a quote than will be used to verify the quote deposit address validity
|
|
50
50
|
*/
|
|
51
51
|
signature?: string;
|
|
52
|
+
/**
|
|
53
|
+
* For ReceiverAccountBridgeProvider, this is the attestation signature from the bridge provider that validates the deposit address. Empty for other provider types.
|
|
54
|
+
*/
|
|
55
|
+
attestationSignature?: string;
|
|
56
|
+
/**
|
|
57
|
+
* A stringified JSON of quote which is associated with the order.
|
|
58
|
+
*/
|
|
59
|
+
quoteBody?: string;
|
|
52
60
|
/**
|
|
53
61
|
* Whether the quote is a sell or buy order.
|
|
54
62
|
*/
|
|
@@ -1270,8 +1278,16 @@ declare class NearIntentsApi {
|
|
|
1270
1278
|
getAttestation(request: GetAttestationRequest): Promise<GetAttestationResponse>;
|
|
1271
1279
|
}
|
|
1272
1280
|
|
|
1281
|
+
interface DepositAddressContext {
|
|
1282
|
+
address: Address$1;
|
|
1283
|
+
quoteHash: string;
|
|
1284
|
+
stringifiedQuote: string;
|
|
1285
|
+
attestationSignature: string;
|
|
1286
|
+
}
|
|
1273
1287
|
interface NearIntentsQuoteResult extends BridgeQuoteResult {
|
|
1274
1288
|
depositAddress: Hex;
|
|
1289
|
+
attestationSignature: string;
|
|
1290
|
+
quoteBody: string;
|
|
1275
1291
|
}
|
|
1276
1292
|
interface NearIntentsBridgeProviderOptions {
|
|
1277
1293
|
cowShedOptions?: CowShedSdkOptions;
|
|
@@ -1295,10 +1311,10 @@ declare class NearIntentsBridgeProvider implements ReceiverAccountBridgeProvider
|
|
|
1295
1311
|
getStatus(bridgingId: string, _originChainId: SupportedChainId): Promise<BridgeStatusResult>;
|
|
1296
1312
|
getCancelBridgingTx(_bridgingId: string): Promise<EvmCall>;
|
|
1297
1313
|
getRefundBridgingTx(_bridgingId: string): Promise<EvmCall>;
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
} | null>;
|
|
1314
|
+
/**
|
|
1315
|
+
* A script to verify depositAddress from appData: https://codesandbox.io/p/sandbox/h7tngy
|
|
1316
|
+
*/
|
|
1317
|
+
recoverDepositAddress({ quote, quoteRequest, timestamp, }: QuoteResponse): Promise<DepositAddressContext | null>;
|
|
1302
1318
|
}
|
|
1303
1319
|
|
|
1304
1320
|
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, BridgeQuoteErrorPriorities, 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_BRIDGE_SLIPPAGE_BPS, 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 MultiQuoteContext, 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.js
CHANGED
|
@@ -772,6 +772,8 @@ async function getAccountBridgeResult(provider, context) {
|
|
|
772
772
|
const bridgeResult = {
|
|
773
773
|
id: bridgingQuote.id,
|
|
774
774
|
signature: bridgingQuote.signature,
|
|
775
|
+
attestationSignature: bridgingQuote.attestationSignature,
|
|
776
|
+
quoteBody: bridgingQuote.quoteBody,
|
|
775
777
|
providerInfo: provider.info,
|
|
776
778
|
tradeParameters: bridgeRequest,
|
|
777
779
|
// Just the bridge (not the swap & bridge)
|
|
@@ -812,6 +814,10 @@ async function getHookBridgeResult(provider, context) {
|
|
|
812
814
|
});
|
|
813
815
|
const bridgeResult = {
|
|
814
816
|
providerInfo: provider.info,
|
|
817
|
+
id: bridgingQuote.id,
|
|
818
|
+
signature: bridgingQuote.signature,
|
|
819
|
+
attestationSignature: bridgingQuote.attestationSignature,
|
|
820
|
+
quoteBody: bridgingQuote.quoteBody,
|
|
815
821
|
tradeParameters: bridgeRequest,
|
|
816
822
|
// Just the bridge (not the swap & bridge)
|
|
817
823
|
bridgeCallDetails: {
|
|
@@ -833,7 +839,9 @@ function overrideAppDataWithBridgingQuoteDetails(bridgingMetaData, quote) {
|
|
|
833
839
|
return {
|
|
834
840
|
...bridgingMetaData,
|
|
835
841
|
...quote.id ? { quoteId: quote.id } : void 0,
|
|
836
|
-
...quote.signature ? { quoteSignature: quote.signature } : void 0
|
|
842
|
+
...quote.signature ? { quoteSignature: quote.signature } : void 0,
|
|
843
|
+
...quote.attestationSignature ? { attestationSignature: quote.attestationSignature } : void 0,
|
|
844
|
+
...quote.quoteBody ? { quoteBody: quote.quoteBody } : void 0
|
|
837
845
|
};
|
|
838
846
|
}
|
|
839
847
|
|
|
@@ -1580,6 +1588,7 @@ var ACROSS_MATH_CONTRACT_ADDRESSES = {
|
|
|
1580
1588
|
var import_sdk_config5 = require("@cowprotocol/sdk-config");
|
|
1581
1589
|
var import_sdk_order_book4 = require("@cowprotocol/sdk-order-book");
|
|
1582
1590
|
var import_sdk_common8 = require("@cowprotocol/sdk-common");
|
|
1591
|
+
var import_json_stable_stringify = __toESM(require("json-stable-stringify"));
|
|
1583
1592
|
var PCT_100_PERCENT = 10n ** 18n;
|
|
1584
1593
|
function toBridgeQuoteResult(request, slippageBps, suggestedFees) {
|
|
1585
1594
|
const { kind } = request;
|
|
@@ -1587,6 +1596,7 @@ function toBridgeQuoteResult(request, slippageBps, suggestedFees) {
|
|
|
1587
1596
|
isSell: kind === import_sdk_order_book4.OrderKind.SELL,
|
|
1588
1597
|
amountsAndCosts: toAmountsAndCosts(request, slippageBps, suggestedFees),
|
|
1589
1598
|
quoteTimestamp: Number(suggestedFees.timestamp),
|
|
1599
|
+
quoteBody: (0, import_json_stable_stringify.default)(suggestedFees),
|
|
1590
1600
|
expectedFillTimeSeconds: Number(suggestedFees.estimatedFillTimeSec),
|
|
1591
1601
|
fees: {
|
|
1592
1602
|
bridgeFee: BigInt(suggestedFees.relayerCapitalFee.total),
|
|
@@ -3889,6 +3899,7 @@ var BungeeBridgeNames = {
|
|
|
3889
3899
|
|
|
3890
3900
|
// src/providers/bungee/util.ts
|
|
3891
3901
|
var import_sdk_order_book6 = require("@cowprotocol/sdk-order-book");
|
|
3902
|
+
var import_json_stable_stringify2 = __toESM(require("json-stable-stringify"));
|
|
3892
3903
|
function toBridgeQuoteResult2(request, slippageBps, bungeeQuoteWithBuildTx) {
|
|
3893
3904
|
const { kind } = request;
|
|
3894
3905
|
const { bungeeQuote, buildTx } = bungeeQuoteWithBuildTx;
|
|
@@ -3898,6 +3909,7 @@ function toBridgeQuoteResult2(request, slippageBps, bungeeQuoteWithBuildTx) {
|
|
|
3898
3909
|
amountsAndCosts: toAmountsAndCosts2(request, slippageBps, bungeeQuote),
|
|
3899
3910
|
quoteTimestamp: Number(bungeeQuote.quoteTimestamp),
|
|
3900
3911
|
expectedFillTimeSeconds: Number(bungeeQuote.route.estimatedTime),
|
|
3912
|
+
quoteBody: (0, import_json_stable_stringify2.default)(bungeeQuote),
|
|
3901
3913
|
fees: {
|
|
3902
3914
|
// @note routeFee is taken in the src chain intermediate token
|
|
3903
3915
|
bridgeFee: BigInt(bungeeQuote.route.routeDetails.routeFee.amount),
|
|
@@ -5009,7 +5021,8 @@ var NEAR_INTENTS_SUPPORTED_NETWORKS = [
|
|
|
5009
5021
|
import_sdk_config10.gnosisChain,
|
|
5010
5022
|
import_sdk_config10.mainnet,
|
|
5011
5023
|
import_sdk_config10.optimism,
|
|
5012
|
-
import_sdk_config10.polygon
|
|
5024
|
+
import_sdk_config10.polygon,
|
|
5025
|
+
import_sdk_config10.plasma
|
|
5013
5026
|
];
|
|
5014
5027
|
var NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS = {
|
|
5015
5028
|
arb: import_sdk_config10.arbitrumOne.id,
|
|
@@ -5019,7 +5032,8 @@ var NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS = {
|
|
|
5019
5032
|
eth: import_sdk_config10.mainnet.id,
|
|
5020
5033
|
gnosis: import_sdk_config10.gnosisChain.id,
|
|
5021
5034
|
op: import_sdk_config10.optimism.id,
|
|
5022
|
-
pol: import_sdk_config10.polygon.id
|
|
5035
|
+
pol: import_sdk_config10.polygon.id,
|
|
5036
|
+
plasma: import_sdk_config10.plasma.id
|
|
5023
5037
|
};
|
|
5024
5038
|
var NEAR_INTENTS_STATUS_TO_COW_STATUS = {
|
|
5025
5039
|
KNOWN_DEPOSIT_TX: "in_progress" /* IN_PROGRESS */,
|
|
@@ -5035,7 +5049,7 @@ var ATTESTION_VERSION_BYTE = "0x00";
|
|
|
5035
5049
|
var ATTESTATOR_ADDRESS = "0x0073DD100b51C555E41B2a452E5933ef76F42790";
|
|
5036
5050
|
|
|
5037
5051
|
// src/providers/near-intents/util.ts
|
|
5038
|
-
var
|
|
5052
|
+
var import_json_stable_stringify3 = __toESM(require("json-stable-stringify"));
|
|
5039
5053
|
var import_sdk_common16 = require("@cowprotocol/sdk-common");
|
|
5040
5054
|
var import_sdk_config11 = require("@cowprotocol/sdk-config");
|
|
5041
5055
|
var calculateDeadline = (seconds) => {
|
|
@@ -5087,7 +5101,7 @@ var hashQuote = ({
|
|
|
5087
5101
|
timestamp
|
|
5088
5102
|
}) => {
|
|
5089
5103
|
const adapter = (0, import_sdk_common16.getGlobalAdapter)();
|
|
5090
|
-
const
|
|
5104
|
+
const stringifiedQuote = (0, import_json_stable_stringify3.default)({
|
|
5091
5105
|
dry: false,
|
|
5092
5106
|
swapType: quoteRequest.swapType,
|
|
5093
5107
|
slippageTolerance: quoteRequest.slippageTolerance,
|
|
@@ -5100,10 +5114,10 @@ var hashQuote = ({
|
|
|
5100
5114
|
recipient: quoteRequest.recipient,
|
|
5101
5115
|
recipientType: quoteRequest.recipientType,
|
|
5102
5116
|
deadline: quoteRequest.deadline,
|
|
5103
|
-
quoteWaitingTimeMs:
|
|
5104
|
-
referral:
|
|
5105
|
-
virtualChainRecipient:
|
|
5106
|
-
virtualChainRefundRecipient:
|
|
5117
|
+
quoteWaitingTimeMs: quoteRequest.quoteWaitingTimeMs ? quoteRequest.quoteWaitingTimeMs : void 0,
|
|
5118
|
+
referral: quoteRequest.referral ? quoteRequest.referral : void 0,
|
|
5119
|
+
virtualChainRecipient: quoteRequest.virtualChainRecipient ? quoteRequest.virtualChainRecipient : void 0,
|
|
5120
|
+
virtualChainRefundRecipient: quoteRequest.virtualChainRefundRecipient ? quoteRequest.virtualChainRefundRecipient : void 0,
|
|
5107
5121
|
customRecipientMsg: void 0,
|
|
5108
5122
|
sessionId: void 0,
|
|
5109
5123
|
connectedWallets: void 0,
|
|
@@ -5118,10 +5132,11 @@ var hashQuote = ({
|
|
|
5118
5132
|
minAmountOut: quote.minAmountOut,
|
|
5119
5133
|
timestamp
|
|
5120
5134
|
});
|
|
5121
|
-
if (!
|
|
5135
|
+
if (!stringifiedQuote) {
|
|
5122
5136
|
throw new Error("Failed to serialize quote data: quote or quoteRequest may be undefined or invalid");
|
|
5123
5137
|
}
|
|
5124
|
-
|
|
5138
|
+
const hash = adapter.utils.sha256(adapter.utils.toUtf8Bytes(stringifiedQuote));
|
|
5139
|
+
return { hash, stringifiedQuote };
|
|
5125
5140
|
};
|
|
5126
5141
|
|
|
5127
5142
|
// src/providers/near-intents/NearIntentsBridgeProvider.ts
|
|
@@ -5232,6 +5247,8 @@ var NearIntentsBridgeProvider = class {
|
|
|
5232
5247
|
return {
|
|
5233
5248
|
id: recoveredDepositAddress.quoteHash,
|
|
5234
5249
|
signature: quoteResponse.signature,
|
|
5250
|
+
attestationSignature: recoveredDepositAddress.attestationSignature,
|
|
5251
|
+
quoteBody: recoveredDepositAddress.stringifiedQuote,
|
|
5235
5252
|
isSell: request.kind === import_sdk_order_book8.OrderKind.SELL,
|
|
5236
5253
|
depositAddress: quote.depositAddress,
|
|
5237
5254
|
quoteTimestamp: new Date(isoDate).getTime(),
|
|
@@ -5339,6 +5356,9 @@ var NearIntentsBridgeProvider = class {
|
|
|
5339
5356
|
getRefundBridgingTx(_bridgingId) {
|
|
5340
5357
|
throw new Error("Not implemented");
|
|
5341
5358
|
}
|
|
5359
|
+
/**
|
|
5360
|
+
* A script to verify depositAddress from appData: https://codesandbox.io/p/sandbox/h7tngy
|
|
5361
|
+
*/
|
|
5342
5362
|
async recoverDepositAddress({
|
|
5343
5363
|
quote,
|
|
5344
5364
|
quoteRequest,
|
|
@@ -5348,7 +5368,7 @@ var NearIntentsBridgeProvider = class {
|
|
|
5348
5368
|
if (!quote?.depositAddress)
|
|
5349
5369
|
return null;
|
|
5350
5370
|
const utils = (0, import_sdk_common17.getGlobalAdapter)().utils;
|
|
5351
|
-
const quoteHash = hashQuote({ quote, quoteRequest, timestamp });
|
|
5371
|
+
const { hash: quoteHash, stringifiedQuote } = hashQuote({ quote, quoteRequest, timestamp });
|
|
5352
5372
|
const depositAddr = utils.getChecksumAddress(quote.depositAddress);
|
|
5353
5373
|
const { signature } = await this.api.getAttestation({
|
|
5354
5374
|
quoteHash,
|
|
@@ -5361,7 +5381,9 @@ var NearIntentsBridgeProvider = class {
|
|
|
5361
5381
|
const hash = utils.keccak256(messageBytes);
|
|
5362
5382
|
return {
|
|
5363
5383
|
address: await utils.recoverAddress(hash, signature),
|
|
5364
|
-
quoteHash
|
|
5384
|
+
quoteHash,
|
|
5385
|
+
stringifiedQuote,
|
|
5386
|
+
attestationSignature: signature
|
|
5365
5387
|
};
|
|
5366
5388
|
} catch {
|
|
5367
5389
|
return null;
|
package/dist/index.mjs
CHANGED
|
@@ -715,6 +715,8 @@ async function getAccountBridgeResult(provider, context) {
|
|
|
715
715
|
const bridgeResult = {
|
|
716
716
|
id: bridgingQuote.id,
|
|
717
717
|
signature: bridgingQuote.signature,
|
|
718
|
+
attestationSignature: bridgingQuote.attestationSignature,
|
|
719
|
+
quoteBody: bridgingQuote.quoteBody,
|
|
718
720
|
providerInfo: provider.info,
|
|
719
721
|
tradeParameters: bridgeRequest,
|
|
720
722
|
// Just the bridge (not the swap & bridge)
|
|
@@ -755,6 +757,10 @@ async function getHookBridgeResult(provider, context) {
|
|
|
755
757
|
});
|
|
756
758
|
const bridgeResult = {
|
|
757
759
|
providerInfo: provider.info,
|
|
760
|
+
id: bridgingQuote.id,
|
|
761
|
+
signature: bridgingQuote.signature,
|
|
762
|
+
attestationSignature: bridgingQuote.attestationSignature,
|
|
763
|
+
quoteBody: bridgingQuote.quoteBody,
|
|
758
764
|
tradeParameters: bridgeRequest,
|
|
759
765
|
// Just the bridge (not the swap & bridge)
|
|
760
766
|
bridgeCallDetails: {
|
|
@@ -776,7 +782,9 @@ function overrideAppDataWithBridgingQuoteDetails(bridgingMetaData, quote) {
|
|
|
776
782
|
return {
|
|
777
783
|
...bridgingMetaData,
|
|
778
784
|
...quote.id ? { quoteId: quote.id } : void 0,
|
|
779
|
-
...quote.signature ? { quoteSignature: quote.signature } : void 0
|
|
785
|
+
...quote.signature ? { quoteSignature: quote.signature } : void 0,
|
|
786
|
+
...quote.attestationSignature ? { attestationSignature: quote.attestationSignature } : void 0,
|
|
787
|
+
...quote.quoteBody ? { quoteBody: quote.quoteBody } : void 0
|
|
780
788
|
};
|
|
781
789
|
}
|
|
782
790
|
|
|
@@ -1523,6 +1531,7 @@ var ACROSS_MATH_CONTRACT_ADDRESSES = {
|
|
|
1523
1531
|
import { COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS } from "@cowprotocol/sdk-config";
|
|
1524
1532
|
import { getBigNumber, OrderKind as OrderKind2 } from "@cowprotocol/sdk-order-book";
|
|
1525
1533
|
import { getGlobalAdapter as getGlobalAdapter5 } from "@cowprotocol/sdk-common";
|
|
1534
|
+
import stringify from "json-stable-stringify";
|
|
1526
1535
|
var PCT_100_PERCENT = 10n ** 18n;
|
|
1527
1536
|
function toBridgeQuoteResult(request, slippageBps, suggestedFees) {
|
|
1528
1537
|
const { kind } = request;
|
|
@@ -1530,6 +1539,7 @@ function toBridgeQuoteResult(request, slippageBps, suggestedFees) {
|
|
|
1530
1539
|
isSell: kind === OrderKind2.SELL,
|
|
1531
1540
|
amountsAndCosts: toAmountsAndCosts(request, slippageBps, suggestedFees),
|
|
1532
1541
|
quoteTimestamp: Number(suggestedFees.timestamp),
|
|
1542
|
+
quoteBody: stringify(suggestedFees),
|
|
1533
1543
|
expectedFillTimeSeconds: Number(suggestedFees.estimatedFillTimeSec),
|
|
1534
1544
|
fees: {
|
|
1535
1545
|
bridgeFee: BigInt(suggestedFees.relayerCapitalFee.total),
|
|
@@ -3838,6 +3848,7 @@ var BungeeBridgeNames = {
|
|
|
3838
3848
|
|
|
3839
3849
|
// src/providers/bungee/util.ts
|
|
3840
3850
|
import { getBigNumber as getBigNumber2, OrderKind as OrderKind4 } from "@cowprotocol/sdk-order-book";
|
|
3851
|
+
import stringify2 from "json-stable-stringify";
|
|
3841
3852
|
function toBridgeQuoteResult2(request, slippageBps, bungeeQuoteWithBuildTx) {
|
|
3842
3853
|
const { kind } = request;
|
|
3843
3854
|
const { bungeeQuote, buildTx } = bungeeQuoteWithBuildTx;
|
|
@@ -3847,6 +3858,7 @@ function toBridgeQuoteResult2(request, slippageBps, bungeeQuoteWithBuildTx) {
|
|
|
3847
3858
|
amountsAndCosts: toAmountsAndCosts2(request, slippageBps, bungeeQuote),
|
|
3848
3859
|
quoteTimestamp: Number(bungeeQuote.quoteTimestamp),
|
|
3849
3860
|
expectedFillTimeSeconds: Number(bungeeQuote.route.estimatedTime),
|
|
3861
|
+
quoteBody: stringify2(bungeeQuote),
|
|
3850
3862
|
fees: {
|
|
3851
3863
|
// @note routeFee is taken in the src chain intermediate token
|
|
3852
3864
|
bridgeFee: BigInt(bungeeQuote.route.routeDetails.routeFee.amount),
|
|
@@ -4957,7 +4969,7 @@ var NearIntentsApi = class {
|
|
|
4957
4969
|
};
|
|
4958
4970
|
|
|
4959
4971
|
// src/providers/near-intents/const/index.ts
|
|
4960
|
-
import { arbitrumOne as arbitrumOne3, avalanche as avalanche2, base as base3, bnb, gnosisChain as gnosisChain2, mainnet as mainnet3, optimism as optimism3, polygon as polygon3 } from "@cowprotocol/sdk-config";
|
|
4972
|
+
import { arbitrumOne as arbitrumOne3, avalanche as avalanche2, base as base3, bnb, gnosisChain as gnosisChain2, mainnet as mainnet3, optimism as optimism3, polygon as polygon3, plasma } from "@cowprotocol/sdk-config";
|
|
4961
4973
|
var NEAR_INTENTS_HOOK_DAPP_ID = `${HOOK_DAPP_BRIDGE_PROVIDER_PREFIX}/near-intents`;
|
|
4962
4974
|
var NEAR_INTENTS_SUPPORTED_NETWORKS = [
|
|
4963
4975
|
arbitrumOne3,
|
|
@@ -4967,7 +4979,8 @@ var NEAR_INTENTS_SUPPORTED_NETWORKS = [
|
|
|
4967
4979
|
gnosisChain2,
|
|
4968
4980
|
mainnet3,
|
|
4969
4981
|
optimism3,
|
|
4970
|
-
polygon3
|
|
4982
|
+
polygon3,
|
|
4983
|
+
plasma
|
|
4971
4984
|
];
|
|
4972
4985
|
var NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS = {
|
|
4973
4986
|
arb: arbitrumOne3.id,
|
|
@@ -4977,7 +4990,8 @@ var NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS = {
|
|
|
4977
4990
|
eth: mainnet3.id,
|
|
4978
4991
|
gnosis: gnosisChain2.id,
|
|
4979
4992
|
op: optimism3.id,
|
|
4980
|
-
pol: polygon3.id
|
|
4993
|
+
pol: polygon3.id,
|
|
4994
|
+
plasma: plasma.id
|
|
4981
4995
|
};
|
|
4982
4996
|
var NEAR_INTENTS_STATUS_TO_COW_STATUS = {
|
|
4983
4997
|
KNOWN_DEPOSIT_TX: "in_progress" /* IN_PROGRESS */,
|
|
@@ -4993,7 +5007,7 @@ var ATTESTION_VERSION_BYTE = "0x00";
|
|
|
4993
5007
|
var ATTESTATOR_ADDRESS = "0x0073DD100b51C555E41B2a452E5933ef76F42790";
|
|
4994
5008
|
|
|
4995
5009
|
// src/providers/near-intents/util.ts
|
|
4996
|
-
import
|
|
5010
|
+
import stringify3 from "json-stable-stringify";
|
|
4997
5011
|
import { getGlobalAdapter as getGlobalAdapter11 } from "@cowprotocol/sdk-common";
|
|
4998
5012
|
import { ETH_ADDRESS as ETH_ADDRESS2 } from "@cowprotocol/sdk-config";
|
|
4999
5013
|
var calculateDeadline = (seconds) => {
|
|
@@ -5045,7 +5059,7 @@ var hashQuote = ({
|
|
|
5045
5059
|
timestamp
|
|
5046
5060
|
}) => {
|
|
5047
5061
|
const adapter = getGlobalAdapter11();
|
|
5048
|
-
const
|
|
5062
|
+
const stringifiedQuote = stringify3({
|
|
5049
5063
|
dry: false,
|
|
5050
5064
|
swapType: quoteRequest.swapType,
|
|
5051
5065
|
slippageTolerance: quoteRequest.slippageTolerance,
|
|
@@ -5058,10 +5072,10 @@ var hashQuote = ({
|
|
|
5058
5072
|
recipient: quoteRequest.recipient,
|
|
5059
5073
|
recipientType: quoteRequest.recipientType,
|
|
5060
5074
|
deadline: quoteRequest.deadline,
|
|
5061
|
-
quoteWaitingTimeMs:
|
|
5062
|
-
referral:
|
|
5063
|
-
virtualChainRecipient:
|
|
5064
|
-
virtualChainRefundRecipient:
|
|
5075
|
+
quoteWaitingTimeMs: quoteRequest.quoteWaitingTimeMs ? quoteRequest.quoteWaitingTimeMs : void 0,
|
|
5076
|
+
referral: quoteRequest.referral ? quoteRequest.referral : void 0,
|
|
5077
|
+
virtualChainRecipient: quoteRequest.virtualChainRecipient ? quoteRequest.virtualChainRecipient : void 0,
|
|
5078
|
+
virtualChainRefundRecipient: quoteRequest.virtualChainRefundRecipient ? quoteRequest.virtualChainRefundRecipient : void 0,
|
|
5065
5079
|
customRecipientMsg: void 0,
|
|
5066
5080
|
sessionId: void 0,
|
|
5067
5081
|
connectedWallets: void 0,
|
|
@@ -5076,10 +5090,11 @@ var hashQuote = ({
|
|
|
5076
5090
|
minAmountOut: quote.minAmountOut,
|
|
5077
5091
|
timestamp
|
|
5078
5092
|
});
|
|
5079
|
-
if (!
|
|
5093
|
+
if (!stringifiedQuote) {
|
|
5080
5094
|
throw new Error("Failed to serialize quote data: quote or quoteRequest may be undefined or invalid");
|
|
5081
5095
|
}
|
|
5082
|
-
|
|
5096
|
+
const hash = adapter.utils.sha256(adapter.utils.toUtf8Bytes(stringifiedQuote));
|
|
5097
|
+
return { hash, stringifiedQuote };
|
|
5083
5098
|
};
|
|
5084
5099
|
|
|
5085
5100
|
// src/providers/near-intents/NearIntentsBridgeProvider.ts
|
|
@@ -5190,6 +5205,8 @@ var NearIntentsBridgeProvider = class {
|
|
|
5190
5205
|
return {
|
|
5191
5206
|
id: recoveredDepositAddress.quoteHash,
|
|
5192
5207
|
signature: quoteResponse.signature,
|
|
5208
|
+
attestationSignature: recoveredDepositAddress.attestationSignature,
|
|
5209
|
+
quoteBody: recoveredDepositAddress.stringifiedQuote,
|
|
5193
5210
|
isSell: request.kind === OrderKind6.SELL,
|
|
5194
5211
|
depositAddress: quote.depositAddress,
|
|
5195
5212
|
quoteTimestamp: new Date(isoDate).getTime(),
|
|
@@ -5297,6 +5314,9 @@ var NearIntentsBridgeProvider = class {
|
|
|
5297
5314
|
getRefundBridgingTx(_bridgingId) {
|
|
5298
5315
|
throw new Error("Not implemented");
|
|
5299
5316
|
}
|
|
5317
|
+
/**
|
|
5318
|
+
* A script to verify depositAddress from appData: https://codesandbox.io/p/sandbox/h7tngy
|
|
5319
|
+
*/
|
|
5300
5320
|
async recoverDepositAddress({
|
|
5301
5321
|
quote,
|
|
5302
5322
|
quoteRequest,
|
|
@@ -5306,7 +5326,7 @@ var NearIntentsBridgeProvider = class {
|
|
|
5306
5326
|
if (!quote?.depositAddress)
|
|
5307
5327
|
return null;
|
|
5308
5328
|
const utils = getGlobalAdapter12().utils;
|
|
5309
|
-
const quoteHash = hashQuote({ quote, quoteRequest, timestamp });
|
|
5329
|
+
const { hash: quoteHash, stringifiedQuote } = hashQuote({ quote, quoteRequest, timestamp });
|
|
5310
5330
|
const depositAddr = utils.getChecksumAddress(quote.depositAddress);
|
|
5311
5331
|
const { signature } = await this.api.getAttestation({
|
|
5312
5332
|
quoteHash,
|
|
@@ -5319,7 +5339,9 @@ var NearIntentsBridgeProvider = class {
|
|
|
5319
5339
|
const hash = utils.keccak256(messageBytes);
|
|
5320
5340
|
return {
|
|
5321
5341
|
address: await utils.recoverAddress(hash, signature),
|
|
5322
|
-
quoteHash
|
|
5342
|
+
quoteHash,
|
|
5343
|
+
stringifiedQuote,
|
|
5344
|
+
attestationSignature: signature
|
|
5323
5345
|
};
|
|
5324
5346
|
} catch {
|
|
5325
5347
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cowprotocol/sdk-bridging",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Bridging for CoW Protocol",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@defuse-protocol/one-click-sdk-typescript": "0.1.1-0.2",
|
|
18
18
|
"json-stable-stringify": "^1.3.0",
|
|
19
|
-
"@cowprotocol/sdk-app-data": "4.
|
|
19
|
+
"@cowprotocol/sdk-app-data": "4.5.0",
|
|
20
20
|
"@cowprotocol/sdk-common": "0.4.0",
|
|
21
21
|
"@cowprotocol/sdk-config": "0.6.2",
|
|
22
22
|
"@cowprotocol/sdk-contracts-ts": "1.0.0",
|
|
23
|
-
"@cowprotocol/sdk-weiroll": "0.1.11",
|
|
24
23
|
"@cowprotocol/sdk-cow-shed": "0.2.9",
|
|
25
|
-
"@cowprotocol/sdk-
|
|
26
|
-
"@cowprotocol/sdk-
|
|
24
|
+
"@cowprotocol/sdk-order-book": "0.5.0",
|
|
25
|
+
"@cowprotocol/sdk-trading": "0.8.0",
|
|
26
|
+
"@cowprotocol/sdk-weiroll": "0.1.11"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/jest": "^29.4.0",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"typescript": "^5.2.2",
|
|
40
40
|
"viem": "^2.28.4",
|
|
41
41
|
"@cow-sdk/typescript-config": "0.0.0-beta.0",
|
|
42
|
-
"@cowprotocol/sdk-ethers-v6-adapter": "0.3.0",
|
|
43
|
-
"@cowprotocol/sdk-order-signing": "0.1.23",
|
|
44
42
|
"@cowprotocol/sdk-ethers-v5-adapter": "0.3.0",
|
|
45
|
-
"@cowprotocol/sdk-
|
|
43
|
+
"@cowprotocol/sdk-ethers-v6-adapter": "0.3.0",
|
|
44
|
+
"@cowprotocol/sdk-viem-adapter": "0.3.0",
|
|
45
|
+
"@cowprotocol/sdk-order-signing": "0.1.23"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|