@cowprotocol/sdk-bridging 4.1.1 → 4.1.3
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +30 -19
- package/dist/index.mjs +30 -19
- package/package.json +13 -13
package/dist/index.d.mts
CHANGED
|
@@ -1280,6 +1280,7 @@ interface GetAttestationResponse {
|
|
|
1280
1280
|
version: number;
|
|
1281
1281
|
}
|
|
1282
1282
|
declare class NearIntentsApi {
|
|
1283
|
+
private static readonly DEPRECATED_ASSET_IDS;
|
|
1283
1284
|
private cachedTokens;
|
|
1284
1285
|
constructor(apiKey?: string);
|
|
1285
1286
|
getTokens(): Promise<TokenResponse[]>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1280,6 +1280,7 @@ interface GetAttestationResponse {
|
|
|
1280
1280
|
version: number;
|
|
1281
1281
|
}
|
|
1282
1282
|
declare class NearIntentsApi {
|
|
1283
|
+
private static readonly DEPRECATED_ASSET_IDS;
|
|
1283
1284
|
private cachedTokens;
|
|
1284
1285
|
constructor(apiKey?: string);
|
|
1285
1286
|
getTokens(): Promise<TokenResponse[]>;
|
package/dist/index.js
CHANGED
|
@@ -4999,7 +4999,17 @@ var import_one_click_sdk_typescript2 = require("@defuse-protocol/one-click-sdk-t
|
|
|
4999
4999
|
|
|
5000
5000
|
// src/providers/near-intents/NearIntentsApi.ts
|
|
5001
5001
|
var import_one_click_sdk_typescript = require("@defuse-protocol/one-click-sdk-typescript");
|
|
5002
|
-
var NearIntentsApi = class {
|
|
5002
|
+
var NearIntentsApi = class _NearIntentsApi {
|
|
5003
|
+
// Upstream /v0/tokens still lists deprecated assets the attestation service
|
|
5004
|
+
// no longer signs. They share `blockchain: 'btc'` with the live token and
|
|
5005
|
+
// both resolve to BTC_CURRENCY_ADDRESS, so without this filter `tokens.find()`
|
|
5006
|
+
// picks the deprecated entry (it appears first) and /v0/attestation fails
|
|
5007
|
+
// with "Invalid quote hash".
|
|
5008
|
+
static DEPRECATED_ASSET_IDS = /* @__PURE__ */ new Set([
|
|
5009
|
+
// POA BTC bridge, replaced by `1cs_v1:btc:native:coin` (Omni migration).
|
|
5010
|
+
// https://partners.near-intents.org/omni-migration
|
|
5011
|
+
"nep141:btc.omft.near"
|
|
5012
|
+
]);
|
|
5003
5013
|
cachedTokens = [];
|
|
5004
5014
|
constructor(apiKey) {
|
|
5005
5015
|
if (apiKey) {
|
|
@@ -5009,7 +5019,7 @@ var NearIntentsApi = class {
|
|
|
5009
5019
|
async getTokens() {
|
|
5010
5020
|
if (this.cachedTokens.length === 0) {
|
|
5011
5021
|
const response = await import_one_click_sdk_typescript.OneClickService.getTokens();
|
|
5012
|
-
this.cachedTokens = response;
|
|
5022
|
+
this.cachedTokens = response.filter((t) => !_NearIntentsApi.DEPRECATED_ASSET_IDS.has(t.assetId));
|
|
5013
5023
|
}
|
|
5014
5024
|
return this.cachedTokens;
|
|
5015
5025
|
}
|
|
@@ -5107,11 +5117,23 @@ var calculateDeadline = (seconds) => {
|
|
|
5107
5117
|
const d = new Date(Date.now() + secs * 1e3);
|
|
5108
5118
|
return d.toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
5109
5119
|
};
|
|
5120
|
+
var resolveTokenAddress = (chainId, contractAddress) => {
|
|
5121
|
+
const isBtcNative = chainId === NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS.btc && (!contractAddress || contractAddress === "coin");
|
|
5122
|
+
if (isBtcNative)
|
|
5123
|
+
return import_sdk_config10.BTC_CURRENCY_ADDRESS;
|
|
5124
|
+
if (contractAddress)
|
|
5125
|
+
return contractAddress;
|
|
5126
|
+
if (chainId === NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS.sol)
|
|
5127
|
+
return import_sdk_config10.SOL_NATIVE_CURRENCY_ADDRESS;
|
|
5128
|
+
if ((0, import_sdk_config10.isEvmChain)(chainId))
|
|
5129
|
+
return import_sdk_config10.ETH_ADDRESS;
|
|
5130
|
+
return null;
|
|
5131
|
+
};
|
|
5110
5132
|
var adaptToken = (token) => {
|
|
5111
5133
|
const chainId = NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS[token.blockchain];
|
|
5112
5134
|
if (!chainId)
|
|
5113
5135
|
return null;
|
|
5114
|
-
const tokenAddress =
|
|
5136
|
+
const tokenAddress = resolveTokenAddress(chainId, token.contractAddress);
|
|
5115
5137
|
if (!tokenAddress)
|
|
5116
5138
|
return null;
|
|
5117
5139
|
return {
|
|
@@ -5133,21 +5155,10 @@ var adaptTokens = (tokens) => tokens.reduce((acc, token) => {
|
|
|
5133
5155
|
var getTokenByAddressAndChainId = (tokens, targetTokenAddress, targetTokenChainId) => {
|
|
5134
5156
|
return tokens.find((token) => {
|
|
5135
5157
|
const chainId = NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS[token.blockchain];
|
|
5136
|
-
if (!chainId)
|
|
5137
|
-
return false;
|
|
5138
|
-
if (chainId !== targetTokenChainId)
|
|
5158
|
+
if (!chainId || chainId !== targetTokenChainId)
|
|
5139
5159
|
return false;
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
return (0, import_sdk_common19.areAddressesEqual)(targetTokenAddress, import_sdk_config10.BTC_CURRENCY_ADDRESS) || (0, import_sdk_common19.areAddressesEqual)(targetTokenAddress, import_sdk_config10.SOL_NATIVE_CURRENCY_ADDRESS);
|
|
5143
|
-
}
|
|
5144
|
-
return (0, import_sdk_common19.areAddressesEqual)(token.contractAddress, targetTokenAddress);
|
|
5145
|
-
}
|
|
5146
|
-
if ((0, import_sdk_common19.areAddressesEqual)(targetTokenAddress, import_sdk_config10.ETH_ADDRESS)) {
|
|
5147
|
-
return !token.contractAddress;
|
|
5148
|
-
}
|
|
5149
|
-
const tokenAddress = token.contractAddress || import_sdk_config10.ETH_ADDRESS;
|
|
5150
|
-
return (0, import_sdk_common19.areAddressesEqual)(tokenAddress, targetTokenAddress);
|
|
5160
|
+
const tokenAddress = resolveTokenAddress(chainId, token.contractAddress);
|
|
5161
|
+
return tokenAddress ? (0, import_sdk_common19.areAddressesEqual)(tokenAddress, targetTokenAddress) : false;
|
|
5151
5162
|
});
|
|
5152
5163
|
};
|
|
5153
5164
|
var hashQuote = ({
|
|
@@ -5375,8 +5386,8 @@ var NearIntentsBridgeProvider = class {
|
|
|
5375
5386
|
fillTxHash: status.swapDetails?.destinationChainTxHashes?.[0]?.hash
|
|
5376
5387
|
},
|
|
5377
5388
|
params: {
|
|
5378
|
-
inputTokenAddress:
|
|
5379
|
-
outputTokenAddress:
|
|
5389
|
+
inputTokenAddress: adaptedInput.address,
|
|
5390
|
+
outputTokenAddress: adaptedOutput.address,
|
|
5380
5391
|
inputAmount: BigInt(quote.amountIn),
|
|
5381
5392
|
outputAmount: swapDetails.amountOut ? BigInt(swapDetails.amountOut) : BigInt(quote.amountOut),
|
|
5382
5393
|
owner: order.owner,
|
package/dist/index.mjs
CHANGED
|
@@ -4958,7 +4958,17 @@ import { QuoteRequest } from "@defuse-protocol/one-click-sdk-typescript";
|
|
|
4958
4958
|
|
|
4959
4959
|
// src/providers/near-intents/NearIntentsApi.ts
|
|
4960
4960
|
import { ApiError, OneClickService, OpenAPI } from "@defuse-protocol/one-click-sdk-typescript";
|
|
4961
|
-
var NearIntentsApi = class {
|
|
4961
|
+
var NearIntentsApi = class _NearIntentsApi {
|
|
4962
|
+
// Upstream /v0/tokens still lists deprecated assets the attestation service
|
|
4963
|
+
// no longer signs. They share `blockchain: 'btc'` with the live token and
|
|
4964
|
+
// both resolve to BTC_CURRENCY_ADDRESS, so without this filter `tokens.find()`
|
|
4965
|
+
// picks the deprecated entry (it appears first) and /v0/attestation fails
|
|
4966
|
+
// with "Invalid quote hash".
|
|
4967
|
+
static DEPRECATED_ASSET_IDS = /* @__PURE__ */ new Set([
|
|
4968
|
+
// POA BTC bridge, replaced by `1cs_v1:btc:native:coin` (Omni migration).
|
|
4969
|
+
// https://partners.near-intents.org/omni-migration
|
|
4970
|
+
"nep141:btc.omft.near"
|
|
4971
|
+
]);
|
|
4962
4972
|
cachedTokens = [];
|
|
4963
4973
|
constructor(apiKey) {
|
|
4964
4974
|
if (apiKey) {
|
|
@@ -4968,7 +4978,7 @@ var NearIntentsApi = class {
|
|
|
4968
4978
|
async getTokens() {
|
|
4969
4979
|
if (this.cachedTokens.length === 0) {
|
|
4970
4980
|
const response = await OneClickService.getTokens();
|
|
4971
|
-
this.cachedTokens = response;
|
|
4981
|
+
this.cachedTokens = response.filter((t) => !_NearIntentsApi.DEPRECATED_ASSET_IDS.has(t.assetId));
|
|
4972
4982
|
}
|
|
4973
4983
|
return this.cachedTokens;
|
|
4974
4984
|
}
|
|
@@ -5083,11 +5093,23 @@ var calculateDeadline = (seconds) => {
|
|
|
5083
5093
|
const d = new Date(Date.now() + secs * 1e3);
|
|
5084
5094
|
return d.toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
5085
5095
|
};
|
|
5096
|
+
var resolveTokenAddress = (chainId, contractAddress) => {
|
|
5097
|
+
const isBtcNative = chainId === NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS.btc && (!contractAddress || contractAddress === "coin");
|
|
5098
|
+
if (isBtcNative)
|
|
5099
|
+
return BTC_CURRENCY_ADDRESS;
|
|
5100
|
+
if (contractAddress)
|
|
5101
|
+
return contractAddress;
|
|
5102
|
+
if (chainId === NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS.sol)
|
|
5103
|
+
return SOL_NATIVE_CURRENCY_ADDRESS;
|
|
5104
|
+
if (isEvmChain(chainId))
|
|
5105
|
+
return ETH_ADDRESS2;
|
|
5106
|
+
return null;
|
|
5107
|
+
};
|
|
5086
5108
|
var adaptToken = (token) => {
|
|
5087
5109
|
const chainId = NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS[token.blockchain];
|
|
5088
5110
|
if (!chainId)
|
|
5089
5111
|
return null;
|
|
5090
|
-
const tokenAddress =
|
|
5112
|
+
const tokenAddress = resolveTokenAddress(chainId, token.contractAddress);
|
|
5091
5113
|
if (!tokenAddress)
|
|
5092
5114
|
return null;
|
|
5093
5115
|
return {
|
|
@@ -5109,21 +5131,10 @@ var adaptTokens = (tokens) => tokens.reduce((acc, token) => {
|
|
|
5109
5131
|
var getTokenByAddressAndChainId = (tokens, targetTokenAddress, targetTokenChainId) => {
|
|
5110
5132
|
return tokens.find((token) => {
|
|
5111
5133
|
const chainId = NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS[token.blockchain];
|
|
5112
|
-
if (!chainId)
|
|
5113
|
-
return false;
|
|
5114
|
-
if (chainId !== targetTokenChainId)
|
|
5134
|
+
if (!chainId || chainId !== targetTokenChainId)
|
|
5115
5135
|
return false;
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
return areAddressesEqual4(targetTokenAddress, BTC_CURRENCY_ADDRESS) || areAddressesEqual4(targetTokenAddress, SOL_NATIVE_CURRENCY_ADDRESS);
|
|
5119
|
-
}
|
|
5120
|
-
return areAddressesEqual4(token.contractAddress, targetTokenAddress);
|
|
5121
|
-
}
|
|
5122
|
-
if (areAddressesEqual4(targetTokenAddress, ETH_ADDRESS2)) {
|
|
5123
|
-
return !token.contractAddress;
|
|
5124
|
-
}
|
|
5125
|
-
const tokenAddress = token.contractAddress || ETH_ADDRESS2;
|
|
5126
|
-
return areAddressesEqual4(tokenAddress, targetTokenAddress);
|
|
5136
|
+
const tokenAddress = resolveTokenAddress(chainId, token.contractAddress);
|
|
5137
|
+
return tokenAddress ? areAddressesEqual4(tokenAddress, targetTokenAddress) : false;
|
|
5127
5138
|
});
|
|
5128
5139
|
};
|
|
5129
5140
|
var hashQuote = ({
|
|
@@ -5351,8 +5362,8 @@ var NearIntentsBridgeProvider = class {
|
|
|
5351
5362
|
fillTxHash: status.swapDetails?.destinationChainTxHashes?.[0]?.hash
|
|
5352
5363
|
},
|
|
5353
5364
|
params: {
|
|
5354
|
-
inputTokenAddress:
|
|
5355
|
-
outputTokenAddress:
|
|
5365
|
+
inputTokenAddress: adaptedInput.address,
|
|
5366
|
+
outputTokenAddress: adaptedOutput.address,
|
|
5356
5367
|
inputAmount: BigInt(quote.amountIn),
|
|
5357
5368
|
outputAmount: swapDetails.amountOut ? BigInt(swapDetails.amountOut) : BigInt(quote.amountOut),
|
|
5358
5369
|
owner: order.owner,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cowprotocol/sdk-bridging",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.3",
|
|
4
4
|
"description": "Bridging for CoW Protocol",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@defuse-protocol/one-click-sdk-typescript": "0.1.1-0.2",
|
|
23
23
|
"json-stable-stringify": "^1.3.0",
|
|
24
|
-
"@cowprotocol/sdk-
|
|
25
|
-
"@cowprotocol/sdk-
|
|
26
|
-
"@cowprotocol/sdk-
|
|
27
|
-
"@cowprotocol/sdk-
|
|
28
|
-
"@cowprotocol/sdk-
|
|
29
|
-
"@cowprotocol/sdk-
|
|
30
|
-
"@cowprotocol/sdk-trading": "2.1.
|
|
31
|
-
"@cowprotocol/sdk-
|
|
24
|
+
"@cowprotocol/sdk-app-data": "5.2.0",
|
|
25
|
+
"@cowprotocol/sdk-common": "0.11.2",
|
|
26
|
+
"@cowprotocol/sdk-config": "2.3.0",
|
|
27
|
+
"@cowprotocol/sdk-contracts-ts": "3.1.2",
|
|
28
|
+
"@cowprotocol/sdk-order-book": "3.2.2",
|
|
29
|
+
"@cowprotocol/sdk-weiroll": "0.1.35",
|
|
30
|
+
"@cowprotocol/sdk-trading": "2.1.2",
|
|
31
|
+
"@cowprotocol/sdk-cow-shed": "0.3.13"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/jest": "^29.4.0",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"typescript": "^5.2.2",
|
|
45
45
|
"viem": "^2.28.4",
|
|
46
46
|
"@cow-sdk/typescript-config": "0.0.0-beta.0",
|
|
47
|
-
"@cowprotocol/sdk-ethers-
|
|
48
|
-
"@cowprotocol/sdk-
|
|
49
|
-
"@cowprotocol/sdk-
|
|
50
|
-
"@cowprotocol/sdk-viem-adapter": "0.3.
|
|
47
|
+
"@cowprotocol/sdk-ethers-v6-adapter": "0.4.9",
|
|
48
|
+
"@cowprotocol/sdk-order-signing": "1.0.6",
|
|
49
|
+
"@cowprotocol/sdk-ethers-v5-adapter": "0.4.9",
|
|
50
|
+
"@cowprotocol/sdk-viem-adapter": "0.3.23"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|