@defuse-protocol/intents-sdk 0.17.1 → 0.19.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 +26 -0
- package/dist/index.cjs +483 -110
- package/dist/index.d.cts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +487 -99
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -30,28 +30,28 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
AssertionError: () =>
|
|
34
|
-
BaseError: () =>
|
|
33
|
+
AssertionError: () => import_internal_utils27.AssertionError,
|
|
34
|
+
BaseError: () => import_internal_utils24.BaseError,
|
|
35
35
|
BridgeNameEnum: () => BridgeNameEnum,
|
|
36
36
|
Chains: () => Chains,
|
|
37
37
|
FeeExceedsAmountError: () => FeeExceedsAmountError,
|
|
38
38
|
HotWithdrawalCancelledError: () => HotWithdrawalCancelledError,
|
|
39
39
|
HotWithdrawalNotFoundError: () => HotWithdrawalNotFoundError,
|
|
40
40
|
HotWithdrawalPendingError: () => HotWithdrawalPendingError,
|
|
41
|
-
HttpRequestError: () =>
|
|
42
|
-
IntentSettlementError: () =>
|
|
41
|
+
HttpRequestError: () => import_internal_utils26.HttpRequestError,
|
|
42
|
+
IntentSettlementError: () => import_internal_utils28.IntentSettlementError,
|
|
43
43
|
IntentsSDK: () => IntentsSDK,
|
|
44
44
|
MinWithdrawalAmountError: () => MinWithdrawalAmountError,
|
|
45
45
|
OmniTransferDestinationChainHashNotFoundError: () => OmniTransferDestinationChainHashNotFoundError,
|
|
46
46
|
OmniTransferNotFoundError: () => OmniTransferNotFoundError,
|
|
47
|
-
PoaWithdrawalInvariantError: () =>
|
|
48
|
-
PoaWithdrawalNotFoundError: () =>
|
|
49
|
-
PoaWithdrawalPendingError: () =>
|
|
50
|
-
QuoteError: () =>
|
|
51
|
-
RelayPublishError: () =>
|
|
47
|
+
PoaWithdrawalInvariantError: () => import_internal_utils25.PoaWithdrawalInvariantError,
|
|
48
|
+
PoaWithdrawalNotFoundError: () => import_internal_utils25.PoaWithdrawalNotFoundError,
|
|
49
|
+
PoaWithdrawalPendingError: () => import_internal_utils25.PoaWithdrawalPendingError,
|
|
50
|
+
QuoteError: () => import_internal_utils28.QuoteError,
|
|
51
|
+
RelayPublishError: () => import_internal_utils28.RelayPublishError,
|
|
52
52
|
RouteEnum: () => RouteEnum,
|
|
53
|
-
RpcRequestError: () =>
|
|
54
|
-
TimeoutError: () =>
|
|
53
|
+
RpcRequestError: () => import_internal_utils26.RpcRequestError,
|
|
54
|
+
TimeoutError: () => import_internal_utils26.TimeoutError,
|
|
55
55
|
TokenNotFoundInDestinationChainError: () => TokenNotFoundInDestinationChainError,
|
|
56
56
|
TokenNotSupportedByOmniRelayerError: () => TokenNotSupportedByOmniRelayerError,
|
|
57
57
|
TrustlineNotFoundError: () => TrustlineNotFoundError,
|
|
@@ -71,7 +71,7 @@ __export(index_exports, {
|
|
|
71
71
|
module.exports = __toCommonJS(index_exports);
|
|
72
72
|
|
|
73
73
|
// src/sdk.ts
|
|
74
|
-
var
|
|
74
|
+
var import_internal_utils22 = require("@defuse-protocol/internal-utils");
|
|
75
75
|
var import_omni_sdk4 = __toESM(require("@hot-labs/omni-sdk"), 1);
|
|
76
76
|
var import_viem2 = require("viem");
|
|
77
77
|
|
|
@@ -958,14 +958,432 @@ var IntentsBridge = class {
|
|
|
958
958
|
}
|
|
959
959
|
};
|
|
960
960
|
|
|
961
|
-
// src/bridges/
|
|
962
|
-
var
|
|
961
|
+
// src/bridges/omni-bridge/omni-bridge.ts
|
|
962
|
+
var import_internal_utils15 = require("@defuse-protocol/internal-utils");
|
|
963
963
|
var import_ttlcache = __toESM(require("@isaacs/ttlcache"), 1);
|
|
964
|
+
var import_attempt2 = require("@lifeomic/attempt");
|
|
965
|
+
var import_omni_bridge_sdk2 = require("omni-bridge-sdk");
|
|
964
966
|
|
|
965
|
-
// src/bridges/
|
|
967
|
+
// src/bridges/omni-bridge/error.ts
|
|
966
968
|
var import_internal_utils13 = require("@defuse-protocol/internal-utils");
|
|
969
|
+
var OmniTransferNotFoundError = class extends import_internal_utils13.BaseError {
|
|
970
|
+
constructor(txHash) {
|
|
971
|
+
super("Omni transfer with given hash is not found in the relayer.", {
|
|
972
|
+
metaMessages: [`OriginTxHash: ${txHash}`],
|
|
973
|
+
name: "OmniTransferNotFoundError"
|
|
974
|
+
});
|
|
975
|
+
this.txHash = txHash;
|
|
976
|
+
}
|
|
977
|
+
};
|
|
978
|
+
var OmniTransferDestinationChainHashNotFoundError = class extends import_internal_utils13.BaseError {
|
|
979
|
+
constructor(txHash, destinationChain) {
|
|
980
|
+
super("Relayer did not return destination chain hash for a transfer.", {
|
|
981
|
+
metaMessages: [
|
|
982
|
+
`OriginTxHash: ${txHash}`,
|
|
983
|
+
`DestinationChain: ${destinationChain}`
|
|
984
|
+
],
|
|
985
|
+
name: "OmniTransferDestinationChainHashNotFoundError"
|
|
986
|
+
});
|
|
987
|
+
this.txHash = txHash;
|
|
988
|
+
this.destinationChain = destinationChain;
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
var TokenNotFoundInDestinationChainError = class extends import_internal_utils13.BaseError {
|
|
992
|
+
constructor(token, destinationChain) {
|
|
993
|
+
super(
|
|
994
|
+
`The token ${token} doesn't exist in destination chain ${destinationChain}`,
|
|
995
|
+
{
|
|
996
|
+
metaMessages: [
|
|
997
|
+
`Token: ${token}`,
|
|
998
|
+
`Destination Chain: ${destinationChain}`
|
|
999
|
+
],
|
|
1000
|
+
name: "TokenNotFoundInDestinationChainError"
|
|
1001
|
+
}
|
|
1002
|
+
);
|
|
1003
|
+
this.token = token;
|
|
1004
|
+
this.destinationChain = destinationChain;
|
|
1005
|
+
}
|
|
1006
|
+
};
|
|
1007
|
+
var TokenNotSupportedByOmniRelayerError = class extends import_internal_utils13.BaseError {
|
|
1008
|
+
constructor(token) {
|
|
1009
|
+
super(`Omni Relayer doesn't accept fee in the transferred token ${token}`, {
|
|
1010
|
+
metaMessages: [`Token: ${token}`],
|
|
1011
|
+
name: "TokenNotSupportedByOmniRelayerError"
|
|
1012
|
+
});
|
|
1013
|
+
this.token = token;
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
|
|
1017
|
+
// src/bridges/omni-bridge/omni-bridge-constants.ts
|
|
1018
|
+
var NEAR_NATIVE_ASSET_ID3 = "nep141:wrap.near";
|
|
1019
|
+
var OMNI_BRIDGE_CONTRACT = "omni.bridge.near";
|
|
1020
|
+
|
|
1021
|
+
// src/bridges/omni-bridge/omni-bridge-utils.ts
|
|
1022
|
+
var import_internal_utils14 = require("@defuse-protocol/internal-utils");
|
|
1023
|
+
var import_omni_bridge_sdk = require("omni-bridge-sdk");
|
|
967
1024
|
function createWithdrawIntentPrimitive3(params) {
|
|
968
|
-
const { contractId: tokenAccountId } =
|
|
1025
|
+
const { contractId: tokenAccountId, standard } = import_internal_utils14.utils.parseDefuseAssetId(
|
|
1026
|
+
params.assetId
|
|
1027
|
+
);
|
|
1028
|
+
(0, import_internal_utils14.assert)(standard === "nep141", "Only NEP-141 is supported");
|
|
1029
|
+
return {
|
|
1030
|
+
intent: "ft_withdraw",
|
|
1031
|
+
token: tokenAccountId,
|
|
1032
|
+
receiver_id: OMNI_BRIDGE_CONTRACT,
|
|
1033
|
+
amount: params.amount.toString(),
|
|
1034
|
+
storage_deposit: params.storageDeposit > 0n ? params.storageDeposit.toString() : null,
|
|
1035
|
+
msg: JSON.stringify({
|
|
1036
|
+
recipient: (0, import_omni_bridge_sdk.omniAddress)(params.omniChainKind, params.destinationAddress),
|
|
1037
|
+
fee: params.transferredTokenFee.toString(),
|
|
1038
|
+
native_token_fee: "0"
|
|
1039
|
+
})
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
function caip2ToChainKind(network) {
|
|
1043
|
+
switch (network) {
|
|
1044
|
+
case Chains.Ethereum:
|
|
1045
|
+
return import_omni_bridge_sdk.ChainKind.Eth;
|
|
1046
|
+
case Chains.Base:
|
|
1047
|
+
return import_omni_bridge_sdk.ChainKind.Base;
|
|
1048
|
+
case Chains.Arbitrum:
|
|
1049
|
+
return import_omni_bridge_sdk.ChainKind.Arb;
|
|
1050
|
+
case Chains.Solana:
|
|
1051
|
+
return import_omni_bridge_sdk.ChainKind.Sol;
|
|
1052
|
+
// case Chains.Bitcoin:
|
|
1053
|
+
// return ChainKind.Btc;
|
|
1054
|
+
default:
|
|
1055
|
+
return null;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
function chainKindToCaip2(network) {
|
|
1059
|
+
switch (network) {
|
|
1060
|
+
case import_omni_bridge_sdk.ChainKind.Eth:
|
|
1061
|
+
return Chains.Ethereum;
|
|
1062
|
+
case import_omni_bridge_sdk.ChainKind.Base:
|
|
1063
|
+
return Chains.Base;
|
|
1064
|
+
case import_omni_bridge_sdk.ChainKind.Arb:
|
|
1065
|
+
return Chains.Arbitrum;
|
|
1066
|
+
case import_omni_bridge_sdk.ChainKind.Sol:
|
|
1067
|
+
return Chains.Solana;
|
|
1068
|
+
// case ChainKind.Btc:
|
|
1069
|
+
// return Chains.Bitcoin;
|
|
1070
|
+
default:
|
|
1071
|
+
return null;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
var CHAIN_PATTERNS = {
|
|
1075
|
+
"nbtc.bridge.near": import_omni_bridge_sdk.ChainKind.Btc,
|
|
1076
|
+
"eth.bridge.near": import_omni_bridge_sdk.ChainKind.Eth,
|
|
1077
|
+
"sol.omdep.near": import_omni_bridge_sdk.ChainKind.Sol,
|
|
1078
|
+
"base.omdep.near": import_omni_bridge_sdk.ChainKind.Base,
|
|
1079
|
+
"arb.omdep.near": import_omni_bridge_sdk.ChainKind.Arb
|
|
1080
|
+
};
|
|
1081
|
+
function validateOmniToken(nearAddress) {
|
|
1082
|
+
return nearAddress in CHAIN_PATTERNS || /\.(omdep\.near|factory\.bridge\.near)$/.test(nearAddress);
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
// src/bridges/omni-bridge/omni-bridge.ts
|
|
1086
|
+
var OmniBridge = class {
|
|
1087
|
+
// 10800000 - 3 hours
|
|
1088
|
+
constructor({
|
|
1089
|
+
env,
|
|
1090
|
+
nearProvider
|
|
1091
|
+
}) {
|
|
1092
|
+
this.storageDepositCache = new import_ttlcache.default({ ttl: 108e5 });
|
|
1093
|
+
// 10800000 - 3 hours
|
|
1094
|
+
this.destinationChainAddressCache = new import_ttlcache.default({ ttl: 108e5 });
|
|
1095
|
+
this.env = env;
|
|
1096
|
+
this.nearProvider = nearProvider;
|
|
1097
|
+
this.omniBridgeAPI = new import_omni_bridge_sdk2.OmniBridgeAPI();
|
|
1098
|
+
}
|
|
1099
|
+
is(routeConfig) {
|
|
1100
|
+
return routeConfig.route === RouteEnum.OmniBridge;
|
|
1101
|
+
}
|
|
1102
|
+
async supports(params) {
|
|
1103
|
+
if (params.routeConfig && !this.is(params.routeConfig)) {
|
|
1104
|
+
return false;
|
|
1105
|
+
}
|
|
1106
|
+
const parsed = parseDefuseAssetId(params.assetId);
|
|
1107
|
+
const omniBridgeSetWithNoChain = Boolean(
|
|
1108
|
+
params.routeConfig && params.routeConfig.route === RouteEnum.OmniBridge && params.routeConfig.chain === void 0
|
|
1109
|
+
);
|
|
1110
|
+
const targetChainSpecified = this.targetChainSpecified(params.routeConfig);
|
|
1111
|
+
const nonValidStandard = parsed.standard !== "nep141";
|
|
1112
|
+
if (nonValidStandard && (omniBridgeSetWithNoChain || targetChainSpecified)) {
|
|
1113
|
+
throw new UnsupportedAssetIdError(
|
|
1114
|
+
params.assetId,
|
|
1115
|
+
`Only NEP-141 tokens are supported by Omni Bridge.`
|
|
1116
|
+
);
|
|
1117
|
+
}
|
|
1118
|
+
if (nonValidStandard) return false;
|
|
1119
|
+
const nonValidToken = validateOmniToken(parsed.contractId) === false;
|
|
1120
|
+
if (nonValidToken && omniBridgeSetWithNoChain) {
|
|
1121
|
+
throw new UnsupportedAssetIdError(
|
|
1122
|
+
params.assetId,
|
|
1123
|
+
`Non valid omni contract id ${parsed.contractId}`
|
|
1124
|
+
);
|
|
1125
|
+
}
|
|
1126
|
+
if (!targetChainSpecified && nonValidToken) return false;
|
|
1127
|
+
let omniChainKind = null;
|
|
1128
|
+
let caip2Chain = null;
|
|
1129
|
+
if (this.targetChainSpecified(params.routeConfig)) {
|
|
1130
|
+
omniChainKind = caip2ToChainKind(params.routeConfig.chain);
|
|
1131
|
+
if (omniChainKind === null) {
|
|
1132
|
+
throw new UnsupportedAssetIdError(
|
|
1133
|
+
params.assetId,
|
|
1134
|
+
`Chain ${params.routeConfig.chain} is not supported in Omni Bridge.`
|
|
1135
|
+
);
|
|
1136
|
+
}
|
|
1137
|
+
caip2Chain = params.routeConfig.chain;
|
|
1138
|
+
} else {
|
|
1139
|
+
omniChainKind = (0, import_omni_bridge_sdk2.parseOriginChain)(parsed.contractId);
|
|
1140
|
+
if (omniChainKind === null) {
|
|
1141
|
+
throw new UnsupportedAssetIdError(
|
|
1142
|
+
params.assetId,
|
|
1143
|
+
`Withdrawal of ${parsed.contractId} to its origin chain is not supported in Omni Bridge.`
|
|
1144
|
+
);
|
|
1145
|
+
}
|
|
1146
|
+
caip2Chain = chainKindToCaip2(omniChainKind);
|
|
1147
|
+
if (caip2Chain === null) {
|
|
1148
|
+
throw new UnsupportedAssetIdError(
|
|
1149
|
+
params.assetId,
|
|
1150
|
+
`Withdrawal of ${parsed.contractId} to its origin chain is not supported in Omni Bridge.`
|
|
1151
|
+
);
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
const tokenOnDestinationNetwork = await this.getCachedDestinationTokenAddress(
|
|
1155
|
+
parsed.contractId,
|
|
1156
|
+
omniChainKind
|
|
1157
|
+
);
|
|
1158
|
+
if (tokenOnDestinationNetwork === null) {
|
|
1159
|
+
throw new TokenNotFoundInDestinationChainError(
|
|
1160
|
+
params.assetId,
|
|
1161
|
+
caip2Chain
|
|
1162
|
+
);
|
|
1163
|
+
}
|
|
1164
|
+
return true;
|
|
1165
|
+
}
|
|
1166
|
+
targetChainSpecified(routeConfig) {
|
|
1167
|
+
return Boolean(
|
|
1168
|
+
routeConfig?.route && routeConfig.route === RouteEnum.OmniBridge && routeConfig.chain
|
|
1169
|
+
);
|
|
1170
|
+
}
|
|
1171
|
+
parseAssetId(assetId) {
|
|
1172
|
+
const parsed = parseDefuseAssetId(assetId);
|
|
1173
|
+
if (parsed.standard !== "nep141") return null;
|
|
1174
|
+
const omniChainKind = (0, import_omni_bridge_sdk2.parseOriginChain)(parsed.contractId);
|
|
1175
|
+
if (omniChainKind === null) return null;
|
|
1176
|
+
const blockchain = chainKindToCaip2(omniChainKind);
|
|
1177
|
+
if (blockchain === null) return null;
|
|
1178
|
+
return Object.assign(parsed, {
|
|
1179
|
+
blockchain,
|
|
1180
|
+
bridgeName: BridgeNameEnum.Omni,
|
|
1181
|
+
address: parsed.contractId
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
makeAssetInfo(assetId, routeConfig) {
|
|
1185
|
+
const parsed = parseDefuseAssetId(assetId);
|
|
1186
|
+
if (parsed.standard !== "nep141") return null;
|
|
1187
|
+
let omniChainKind = null;
|
|
1188
|
+
let blockchain = null;
|
|
1189
|
+
if (this.targetChainSpecified(routeConfig)) {
|
|
1190
|
+
omniChainKind = caip2ToChainKind(routeConfig.chain);
|
|
1191
|
+
blockchain = routeConfig.chain;
|
|
1192
|
+
} else {
|
|
1193
|
+
omniChainKind = (0, import_omni_bridge_sdk2.parseOriginChain)(parsed.contractId);
|
|
1194
|
+
if (omniChainKind === null) return null;
|
|
1195
|
+
blockchain = chainKindToCaip2(omniChainKind);
|
|
1196
|
+
}
|
|
1197
|
+
if (omniChainKind === null || blockchain === null) return null;
|
|
1198
|
+
return Object.assign(parsed, {
|
|
1199
|
+
blockchain,
|
|
1200
|
+
bridgeName: BridgeNameEnum.Omni,
|
|
1201
|
+
address: parsed.contractId
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
async createWithdrawalIntents(args) {
|
|
1205
|
+
const assetInfo = this.makeAssetInfo(
|
|
1206
|
+
args.withdrawalParams.assetId,
|
|
1207
|
+
args.withdrawalParams.routeConfig
|
|
1208
|
+
);
|
|
1209
|
+
(0, import_internal_utils15.assert)(
|
|
1210
|
+
assetInfo !== null,
|
|
1211
|
+
`Asset ${args.withdrawalParams.assetId} is not supported by Omni Bridge`
|
|
1212
|
+
);
|
|
1213
|
+
const intents = [];
|
|
1214
|
+
if (args.feeEstimation.quote !== null) {
|
|
1215
|
+
intents.push({
|
|
1216
|
+
intent: "token_diff",
|
|
1217
|
+
diff: {
|
|
1218
|
+
[args.feeEstimation.quote.defuse_asset_identifier_in]: `-${args.feeEstimation.quote.amount_in}`,
|
|
1219
|
+
[args.feeEstimation.quote.defuse_asset_identifier_out]: args.feeEstimation.quote.amount_out
|
|
1220
|
+
},
|
|
1221
|
+
referral: args.referral
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
const omniChainKind = caip2ToChainKind(assetInfo.blockchain);
|
|
1225
|
+
(0, import_internal_utils15.assert)(
|
|
1226
|
+
omniChainKind !== null,
|
|
1227
|
+
`Chain ${assetInfo.blockchain} is not supported by Omni Bridge`
|
|
1228
|
+
);
|
|
1229
|
+
const intent = createWithdrawIntentPrimitive3({
|
|
1230
|
+
assetId: args.withdrawalParams.assetId,
|
|
1231
|
+
destinationAddress: args.withdrawalParams.destinationAddress,
|
|
1232
|
+
amount: args.withdrawalParams.amount + args.feeEstimation.amount,
|
|
1233
|
+
omniChainKind,
|
|
1234
|
+
storageDeposit: args.feeEstimation.quote ? BigInt(args.feeEstimation.quote.amount_out) : 0n,
|
|
1235
|
+
transferredTokenFee: args.feeEstimation.amount
|
|
1236
|
+
});
|
|
1237
|
+
intents.push(intent);
|
|
1238
|
+
return Promise.resolve(intents);
|
|
1239
|
+
}
|
|
1240
|
+
async validateWithdrawal(args) {
|
|
1241
|
+
(0, import_internal_utils15.assert)(
|
|
1242
|
+
args.feeEstimation.amount > 0n,
|
|
1243
|
+
`Fee must be greater than zero. Current fee is ${args.feeEstimation.amount}.`
|
|
1244
|
+
);
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1247
|
+
async estimateWithdrawalFee(args) {
|
|
1248
|
+
const assetInfo = this.makeAssetInfo(
|
|
1249
|
+
args.withdrawalParams.assetId,
|
|
1250
|
+
args.withdrawalParams.routeConfig
|
|
1251
|
+
);
|
|
1252
|
+
(0, import_internal_utils15.assert)(
|
|
1253
|
+
assetInfo !== null,
|
|
1254
|
+
`Asset ${args.withdrawalParams.assetId} is not supported by Omni Bridge`
|
|
1255
|
+
);
|
|
1256
|
+
const omniChainKind = caip2ToChainKind(assetInfo.blockchain);
|
|
1257
|
+
(0, import_internal_utils15.assert)(
|
|
1258
|
+
omniChainKind !== null,
|
|
1259
|
+
`Chain ${assetInfo.blockchain} is not supported by Omni Bridge`
|
|
1260
|
+
);
|
|
1261
|
+
const fee = await this.omniBridgeAPI.getFee(
|
|
1262
|
+
(0, import_omni_bridge_sdk2.omniAddress)(import_omni_bridge_sdk2.ChainKind.Near, import_internal_utils15.configsByEnvironment[this.env].contractID),
|
|
1263
|
+
(0, import_omni_bridge_sdk2.omniAddress)(omniChainKind, args.withdrawalParams.destinationAddress),
|
|
1264
|
+
(0, import_omni_bridge_sdk2.omniAddress)(import_omni_bridge_sdk2.ChainKind.Near, assetInfo.contractId)
|
|
1265
|
+
);
|
|
1266
|
+
if (fee.transferred_token_fee === null) {
|
|
1267
|
+
throw new TokenNotSupportedByOmniRelayerError(
|
|
1268
|
+
args.withdrawalParams.assetId
|
|
1269
|
+
);
|
|
1270
|
+
}
|
|
1271
|
+
const [minStorageBalance, userStorageBalance] = await this.getCachedStorageDepositValue(assetInfo.contractId);
|
|
1272
|
+
if (minStorageBalance <= userStorageBalance) {
|
|
1273
|
+
return {
|
|
1274
|
+
amount: BigInt(fee.transferred_token_fee),
|
|
1275
|
+
quote: null
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
const feeAmount = minStorageBalance - userStorageBalance;
|
|
1279
|
+
const feeQuote = await import_internal_utils15.solverRelay.getQuote({
|
|
1280
|
+
quoteParams: {
|
|
1281
|
+
defuse_asset_identifier_in: args.withdrawalParams.assetId,
|
|
1282
|
+
defuse_asset_identifier_out: NEAR_NATIVE_ASSET_ID3,
|
|
1283
|
+
exact_amount_out: feeAmount.toString(),
|
|
1284
|
+
wait_ms: args.quoteOptions?.waitMs
|
|
1285
|
+
},
|
|
1286
|
+
config: {
|
|
1287
|
+
baseURL: import_internal_utils15.configsByEnvironment[this.env].solverRelayBaseURL,
|
|
1288
|
+
logBalanceSufficient: false,
|
|
1289
|
+
logger: args.logger
|
|
1290
|
+
}
|
|
1291
|
+
});
|
|
1292
|
+
return {
|
|
1293
|
+
amount: BigInt(fee.transferred_token_fee) + BigInt(feeQuote.amount_in),
|
|
1294
|
+
quote: feeQuote
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
async waitForWithdrawalCompletion(args) {
|
|
1298
|
+
return (0, import_attempt2.retry)(
|
|
1299
|
+
async () => {
|
|
1300
|
+
if (args.signal?.aborted) {
|
|
1301
|
+
throw args.signal.reason;
|
|
1302
|
+
}
|
|
1303
|
+
const transfer = (await this.omniBridgeAPI.findOmniTransfers({
|
|
1304
|
+
transaction_id: args.tx.hash,
|
|
1305
|
+
offset: args.index,
|
|
1306
|
+
limit: 1
|
|
1307
|
+
}))[0];
|
|
1308
|
+
if (!transfer) throw new OmniTransferNotFoundError(args.tx.hash);
|
|
1309
|
+
const destinationChain = (0, import_omni_bridge_sdk2.getChain)(
|
|
1310
|
+
transfer.transfer_message.recipient
|
|
1311
|
+
);
|
|
1312
|
+
let txHash = null;
|
|
1313
|
+
if ((0, import_omni_bridge_sdk2.isEvmChain)(destinationChain)) {
|
|
1314
|
+
txHash = transfer.finalised?.EVMLog?.transaction_hash;
|
|
1315
|
+
} else if (destinationChain === import_omni_bridge_sdk2.ChainKind.Sol) {
|
|
1316
|
+
txHash = transfer.finalised?.Solana?.signature;
|
|
1317
|
+
} else {
|
|
1318
|
+
return { hash: null };
|
|
1319
|
+
}
|
|
1320
|
+
if (!txHash)
|
|
1321
|
+
throw new OmniTransferDestinationChainHashNotFoundError(
|
|
1322
|
+
args.tx.hash,
|
|
1323
|
+
import_omni_bridge_sdk2.ChainKind[destinationChain].toLowerCase()
|
|
1324
|
+
);
|
|
1325
|
+
return { hash: txHash };
|
|
1326
|
+
},
|
|
1327
|
+
{
|
|
1328
|
+
...args.retryOptions ?? import_internal_utils15.RETRY_CONFIGS.FIVE_MINS_STEADY,
|
|
1329
|
+
handleError: (err, ctx) => {
|
|
1330
|
+
if (err instanceof OmniTransferNotFoundError || err === args.signal?.reason) {
|
|
1331
|
+
ctx.abort();
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
);
|
|
1336
|
+
}
|
|
1337
|
+
/**
|
|
1338
|
+
* Gets storage deposit for a token to avoid frequent RPC calls.
|
|
1339
|
+
* Cache expires after one day using TTL cache.
|
|
1340
|
+
*/
|
|
1341
|
+
async getCachedStorageDepositValue(contractId) {
|
|
1342
|
+
const cached = this.storageDepositCache.get(contractId);
|
|
1343
|
+
if (cached !== void 0) {
|
|
1344
|
+
return cached;
|
|
1345
|
+
}
|
|
1346
|
+
const data = await Promise.all([
|
|
1347
|
+
(0, import_internal_utils15.getNearNep141MinStorageBalance)({
|
|
1348
|
+
contractId,
|
|
1349
|
+
nearProvider: this.nearProvider
|
|
1350
|
+
}),
|
|
1351
|
+
(0, import_internal_utils15.getNearNep141StorageBalance)({
|
|
1352
|
+
contractId,
|
|
1353
|
+
accountId: OMNI_BRIDGE_CONTRACT,
|
|
1354
|
+
nearProvider: this.nearProvider
|
|
1355
|
+
})
|
|
1356
|
+
]);
|
|
1357
|
+
this.storageDepositCache.set(contractId, data);
|
|
1358
|
+
return data;
|
|
1359
|
+
}
|
|
1360
|
+
/**
|
|
1361
|
+
* Gets cached token address on destination chain.
|
|
1362
|
+
* Cache expires after one day using TTL cache.
|
|
1363
|
+
*/
|
|
1364
|
+
async getCachedDestinationTokenAddress(contractId, omniChainKind) {
|
|
1365
|
+
const key = `${omniChainKind}:${contractId}`;
|
|
1366
|
+
const cached = this.destinationChainAddressCache.get(key);
|
|
1367
|
+
if (cached !== void 0) {
|
|
1368
|
+
return cached;
|
|
1369
|
+
}
|
|
1370
|
+
const tokenOnDestinationNetwork = await (0, import_omni_bridge_sdk2.getBridgedToken)(
|
|
1371
|
+
(0, import_omni_bridge_sdk2.omniAddress)(import_omni_bridge_sdk2.ChainKind.Near, contractId),
|
|
1372
|
+
omniChainKind
|
|
1373
|
+
);
|
|
1374
|
+
this.destinationChainAddressCache.set(key, tokenOnDestinationNetwork);
|
|
1375
|
+
return tokenOnDestinationNetwork;
|
|
1376
|
+
}
|
|
1377
|
+
};
|
|
1378
|
+
|
|
1379
|
+
// src/bridges/poa-bridge/poa-bridge.ts
|
|
1380
|
+
var import_internal_utils17 = require("@defuse-protocol/internal-utils");
|
|
1381
|
+
var import_ttlcache2 = __toESM(require("@isaacs/ttlcache"), 1);
|
|
1382
|
+
|
|
1383
|
+
// src/bridges/poa-bridge/poa-bridge-utils.ts
|
|
1384
|
+
var import_internal_utils16 = require("@defuse-protocol/internal-utils");
|
|
1385
|
+
function createWithdrawIntentPrimitive4(params) {
|
|
1386
|
+
const { contractId: tokenAccountId } = import_internal_utils16.utils.parseDefuseAssetId(
|
|
969
1387
|
params.assetId
|
|
970
1388
|
);
|
|
971
1389
|
return {
|
|
@@ -1040,7 +1458,7 @@ function contractIdToCaip2(contractId) {
|
|
|
1040
1458
|
var PoaBridge = class {
|
|
1041
1459
|
constructor({ env }) {
|
|
1042
1460
|
// TTL cache for supported tokens with 30-second TTL
|
|
1043
|
-
this.supportedTokensCache = new
|
|
1461
|
+
this.supportedTokensCache = new import_ttlcache2.default({ ttl: 30 * 1e3 });
|
|
1044
1462
|
this.env = env;
|
|
1045
1463
|
}
|
|
1046
1464
|
is(routeConfig) {
|
|
@@ -1063,7 +1481,7 @@ var PoaBridge = class {
|
|
|
1063
1481
|
parseAssetId(assetId) {
|
|
1064
1482
|
const parsed = parseDefuseAssetId(assetId);
|
|
1065
1483
|
const contractIdSatisfies = parsed.contractId.endsWith(
|
|
1066
|
-
`.${
|
|
1484
|
+
`.${import_internal_utils17.configsByEnvironment[this.env].poaTokenFactoryContractID}`
|
|
1067
1485
|
);
|
|
1068
1486
|
if (!contractIdSatisfies) {
|
|
1069
1487
|
return null;
|
|
@@ -1085,7 +1503,7 @@ var PoaBridge = class {
|
|
|
1085
1503
|
});
|
|
1086
1504
|
}
|
|
1087
1505
|
createWithdrawalIntents(args) {
|
|
1088
|
-
const intent =
|
|
1506
|
+
const intent = createWithdrawIntentPrimitive4({
|
|
1089
1507
|
...args.withdrawalParams,
|
|
1090
1508
|
amount: args.withdrawalParams.amount + args.feeEstimation.amount,
|
|
1091
1509
|
destinationMemo: args.withdrawalParams.destinationMemo
|
|
@@ -1100,7 +1518,7 @@ var PoaBridge = class {
|
|
|
1100
1518
|
*/
|
|
1101
1519
|
async validateWithdrawal(args) {
|
|
1102
1520
|
const assetInfo = this.parseAssetId(args.assetId);
|
|
1103
|
-
(0,
|
|
1521
|
+
(0, import_internal_utils17.assert)(assetInfo != null, "Asset is not supported");
|
|
1104
1522
|
const { tokens: tokens2 } = await this.getCachedSupportedTokens(
|
|
1105
1523
|
[toPoaNetwork(assetInfo.blockchain)],
|
|
1106
1524
|
args.logger
|
|
@@ -1121,16 +1539,16 @@ var PoaBridge = class {
|
|
|
1121
1539
|
}
|
|
1122
1540
|
async estimateWithdrawalFee(args) {
|
|
1123
1541
|
const assetInfo = this.parseAssetId(args.withdrawalParams.assetId);
|
|
1124
|
-
(0,
|
|
1125
|
-
const estimation = await
|
|
1542
|
+
(0, import_internal_utils17.assert)(assetInfo != null, "Asset is not supported");
|
|
1543
|
+
const estimation = await import_internal_utils17.poaBridge.httpClient.getWithdrawalEstimate(
|
|
1126
1544
|
{
|
|
1127
|
-
token:
|
|
1545
|
+
token: import_internal_utils17.utils.getTokenAccountId(args.withdrawalParams.assetId),
|
|
1128
1546
|
address: args.withdrawalParams.destinationAddress,
|
|
1129
1547
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
1130
1548
|
chain: toPoaNetwork(assetInfo.blockchain)
|
|
1131
1549
|
},
|
|
1132
1550
|
{
|
|
1133
|
-
baseURL:
|
|
1551
|
+
baseURL: import_internal_utils17.configsByEnvironment[this.env].poaBridgeBaseURL,
|
|
1134
1552
|
logger: args.logger
|
|
1135
1553
|
}
|
|
1136
1554
|
);
|
|
@@ -1140,12 +1558,12 @@ var PoaBridge = class {
|
|
|
1140
1558
|
};
|
|
1141
1559
|
}
|
|
1142
1560
|
async waitForWithdrawalCompletion(args) {
|
|
1143
|
-
const withdrawalStatus = await
|
|
1561
|
+
const withdrawalStatus = await import_internal_utils17.poaBridge.waitForWithdrawalCompletion({
|
|
1144
1562
|
txHash: args.tx.hash,
|
|
1145
1563
|
index: args.index,
|
|
1146
1564
|
signal: args.signal ?? new AbortController().signal,
|
|
1147
1565
|
retryOptions: args.retryOptions,
|
|
1148
|
-
baseURL:
|
|
1566
|
+
baseURL: import_internal_utils17.configsByEnvironment[this.env].poaBridgeBaseURL,
|
|
1149
1567
|
logger: args.logger
|
|
1150
1568
|
});
|
|
1151
1569
|
return { hash: withdrawalStatus.destinationTxHash };
|
|
@@ -1160,10 +1578,10 @@ var PoaBridge = class {
|
|
|
1160
1578
|
if (cached != null) {
|
|
1161
1579
|
return cached;
|
|
1162
1580
|
}
|
|
1163
|
-
const data = await
|
|
1581
|
+
const data = await import_internal_utils17.poaBridge.httpClient.getSupportedTokens(
|
|
1164
1582
|
{ chains },
|
|
1165
1583
|
{
|
|
1166
|
-
baseURL:
|
|
1584
|
+
baseURL: import_internal_utils17.configsByEnvironment[this.env].poaBridgeBaseURL,
|
|
1167
1585
|
logger
|
|
1168
1586
|
}
|
|
1169
1587
|
);
|
|
@@ -1185,7 +1603,7 @@ var PUBLIC_STELLAR_RPC_URLS = {
|
|
|
1185
1603
|
};
|
|
1186
1604
|
|
|
1187
1605
|
// src/intents/intent-executer-impl/intent-executer.ts
|
|
1188
|
-
var
|
|
1606
|
+
var import_internal_utils18 = require("@defuse-protocol/internal-utils");
|
|
1189
1607
|
|
|
1190
1608
|
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_u64.js
|
|
1191
1609
|
var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
@@ -1506,6 +1924,7 @@ async function computeIntentHashBytes(multiPayload) {
|
|
|
1506
1924
|
multiPayload
|
|
1507
1925
|
);
|
|
1508
1926
|
case "erc191":
|
|
1927
|
+
case "tip191":
|
|
1509
1928
|
return computeErc191Hash(
|
|
1510
1929
|
multiPayload
|
|
1511
1930
|
);
|
|
@@ -1566,7 +1985,7 @@ var IntentExecuter = class {
|
|
|
1566
1985
|
relayParams: relayParamsFactory,
|
|
1567
1986
|
...intentParams
|
|
1568
1987
|
}) {
|
|
1569
|
-
const verifyingContract =
|
|
1988
|
+
const verifyingContract = import_internal_utils18.configsByEnvironment[this.env].contractID;
|
|
1570
1989
|
let intentPayload = defaultIntentPayloadFactory({
|
|
1571
1990
|
verifying_contract: verifyingContract,
|
|
1572
1991
|
...intentParams
|
|
@@ -1616,7 +2035,7 @@ async function mergeIntentPayloads(basePayload, intentPayloadFactory) {
|
|
|
1616
2035
|
}
|
|
1617
2036
|
|
|
1618
2037
|
// src/intents/intent-relayer-impl/intent-relayer-public.ts
|
|
1619
|
-
var
|
|
2038
|
+
var import_internal_utils19 = require("@defuse-protocol/internal-utils");
|
|
1620
2039
|
var IntentRelayerPublic = class {
|
|
1621
2040
|
constructor({ env }) {
|
|
1622
2041
|
this.env = env;
|
|
@@ -1638,13 +2057,13 @@ var IntentRelayerPublic = class {
|
|
|
1638
2057
|
multiPayloads,
|
|
1639
2058
|
quoteHashes
|
|
1640
2059
|
}, ctx = {}) {
|
|
1641
|
-
const a = await
|
|
2060
|
+
const a = await import_internal_utils19.solverRelay.publishIntents(
|
|
1642
2061
|
{
|
|
1643
2062
|
quote_hashes: quoteHashes,
|
|
1644
2063
|
signed_datas: multiPayloads
|
|
1645
2064
|
},
|
|
1646
2065
|
{
|
|
1647
|
-
baseURL:
|
|
2066
|
+
baseURL: import_internal_utils19.configsByEnvironment[this.env].solverRelayBaseURL,
|
|
1648
2067
|
logger: ctx.logger
|
|
1649
2068
|
}
|
|
1650
2069
|
);
|
|
@@ -1654,10 +2073,10 @@ var IntentRelayerPublic = class {
|
|
|
1654
2073
|
throw a.unwrapErr();
|
|
1655
2074
|
}
|
|
1656
2075
|
async waitForSettlement(ticket, ctx = {}) {
|
|
1657
|
-
const result = await
|
|
2076
|
+
const result = await import_internal_utils19.solverRelay.waitForIntentSettlement({
|
|
1658
2077
|
intentHash: ticket,
|
|
1659
2078
|
signal: new AbortController().signal,
|
|
1660
|
-
baseURL:
|
|
2079
|
+
baseURL: import_internal_utils19.configsByEnvironment[this.env].solverRelayBaseURL,
|
|
1661
2080
|
logger: ctx.logger
|
|
1662
2081
|
});
|
|
1663
2082
|
return {
|
|
@@ -1665,7 +2084,7 @@ var IntentRelayerPublic = class {
|
|
|
1665
2084
|
hash: result.txHash,
|
|
1666
2085
|
// Usually relayer's account id is the verifying contract (`intents.near`),
|
|
1667
2086
|
// but it is not set in stone and may change in the future.
|
|
1668
|
-
accountId:
|
|
2087
|
+
accountId: import_internal_utils19.configsByEnvironment[this.env].contractID
|
|
1669
2088
|
}
|
|
1670
2089
|
};
|
|
1671
2090
|
}
|
|
@@ -1679,14 +2098,14 @@ var noopIntentSigner = {
|
|
|
1679
2098
|
};
|
|
1680
2099
|
|
|
1681
2100
|
// src/lib/array.ts
|
|
1682
|
-
var
|
|
2101
|
+
var import_internal_utils20 = require("@defuse-protocol/internal-utils");
|
|
1683
2102
|
function zip(arr1, arr2) {
|
|
1684
|
-
(0,
|
|
2103
|
+
(0, import_internal_utils20.assert)(arr1.length === arr2.length, "Arrays must have the same length");
|
|
1685
2104
|
return arr1.map((v, i) => [v, arr2[i]]);
|
|
1686
2105
|
}
|
|
1687
2106
|
|
|
1688
2107
|
// src/lib/configure-rpc-config.ts
|
|
1689
|
-
var
|
|
2108
|
+
var import_internal_utils21 = require("@defuse-protocol/internal-utils");
|
|
1690
2109
|
|
|
1691
2110
|
// src/lib/object.ts
|
|
1692
2111
|
function pick(obj, keys) {
|
|
@@ -1710,7 +2129,7 @@ function configureEvmRpcUrls(defaultRpcUrls, userRpcUrls, supportedChains) {
|
|
|
1710
2129
|
).map(([caip2, urls]) => [getEIP155ChainId(caip2), urls])
|
|
1711
2130
|
);
|
|
1712
2131
|
for (const [chainId, urls] of Object.entries(evmRpcUrls)) {
|
|
1713
|
-
(0,
|
|
2132
|
+
(0, import_internal_utils21.assert)(
|
|
1714
2133
|
urls.length > 0,
|
|
1715
2134
|
`EVM RPC URLs for chain ${chainId} are not provided`
|
|
1716
2135
|
);
|
|
@@ -1724,7 +2143,7 @@ function configureStellarRpcUrls(defaultRpcUrls, userRpcUrls) {
|
|
|
1724
2143
|
userRpcUrls?.[Chains.Stellar] ?? {}
|
|
1725
2144
|
);
|
|
1726
2145
|
for (const [key, value] of Object.entries(stellarRpcUrls)) {
|
|
1727
|
-
(0,
|
|
2146
|
+
(0, import_internal_utils21.assert)(value.length > 0, `Stellar RPC URL for ${key} is not provided`);
|
|
1728
2147
|
}
|
|
1729
2148
|
return stellarRpcUrls;
|
|
1730
2149
|
}
|
|
@@ -1736,8 +2155,10 @@ function createInternalTransferRoute() {
|
|
|
1736
2155
|
function createNearWithdrawalRoute(msg) {
|
|
1737
2156
|
return { route: RouteEnum.NearWithdrawal, msg };
|
|
1738
2157
|
}
|
|
1739
|
-
function createOmniBridgeRoute() {
|
|
1740
|
-
|
|
2158
|
+
function createOmniBridgeRoute(chain) {
|
|
2159
|
+
const routeConfig = { route: RouteEnum.OmniBridge };
|
|
2160
|
+
if (chain) routeConfig.chain = chain;
|
|
2161
|
+
return routeConfig;
|
|
1741
2162
|
}
|
|
1742
2163
|
function createVirtualChainRoute(auroraEngineContractId, proxyTokenContractId) {
|
|
1743
2164
|
return {
|
|
@@ -1774,7 +2195,7 @@ function determineRouteConfig(sdk, withdrawalParams) {
|
|
|
1774
2195
|
case BridgeNameEnum.Poa:
|
|
1775
2196
|
return createPoaBridgeRoute(parseAssetId.blockchain);
|
|
1776
2197
|
case BridgeNameEnum.Omni:
|
|
1777
|
-
return createOmniBridgeRoute();
|
|
2198
|
+
return createOmniBridgeRoute(parseAssetId.blockchain);
|
|
1778
2199
|
case BridgeNameEnum.None:
|
|
1779
2200
|
return createNearWithdrawalRoute();
|
|
1780
2201
|
default:
|
|
@@ -1788,9 +2209,9 @@ var IntentsSDK = class {
|
|
|
1788
2209
|
constructor(args) {
|
|
1789
2210
|
this.env = args.env ?? "production";
|
|
1790
2211
|
this.referral = args.referral;
|
|
1791
|
-
const nearRpcUrls = args.rpc?.[Chains.Near] ??
|
|
1792
|
-
(0,
|
|
1793
|
-
const nearProvider = (0,
|
|
2212
|
+
const nearRpcUrls = args.rpc?.[Chains.Near] ?? import_internal_utils22.PUBLIC_NEAR_RPC_URLS;
|
|
2213
|
+
(0, import_internal_utils22.assert)(nearRpcUrls.length > 0, "NEAR RPC URLs are not provided");
|
|
2214
|
+
const nearProvider = (0, import_internal_utils22.nearFailoverRpcProvider)({ urls: nearRpcUrls });
|
|
1794
2215
|
const stellarRpcUrls = configureStellarRpcUrls(
|
|
1795
2216
|
PUBLIC_STELLAR_RPC_URLS,
|
|
1796
2217
|
args.rpc
|
|
@@ -1822,10 +2243,10 @@ var IntentsSDK = class {
|
|
|
1822
2243
|
}
|
|
1823
2244
|
})
|
|
1824
2245
|
}),
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
2246
|
+
new OmniBridge({
|
|
2247
|
+
env: this.env,
|
|
2248
|
+
nearProvider
|
|
2249
|
+
}),
|
|
1829
2250
|
new DirectBridge({
|
|
1830
2251
|
env: this.env,
|
|
1831
2252
|
nearProvider
|
|
@@ -1916,7 +2337,7 @@ var IntentsSDK = class {
|
|
|
1916
2337
|
const routeConfig = determineRouteConfig(this, w);
|
|
1917
2338
|
const route = routeConfig.route;
|
|
1918
2339
|
const index = indexes.get(route);
|
|
1919
|
-
(0,
|
|
2340
|
+
(0, import_internal_utils22.assert)(index != null, "Index is not found for route");
|
|
1920
2341
|
indexes.set(route, index + 1);
|
|
1921
2342
|
return {
|
|
1922
2343
|
routeConfig,
|
|
@@ -1950,7 +2371,7 @@ var IntentsSDK = class {
|
|
|
1950
2371
|
if (Array.isArray(args.withdrawalParams)) {
|
|
1951
2372
|
return result;
|
|
1952
2373
|
}
|
|
1953
|
-
(0,
|
|
2374
|
+
(0, import_internal_utils22.assert)(result.length === 1, "Unexpected result length");
|
|
1954
2375
|
return result[0];
|
|
1955
2376
|
}
|
|
1956
2377
|
parseAssetId(assetId) {
|
|
@@ -1964,7 +2385,7 @@ var IntentsSDK = class {
|
|
|
1964
2385
|
}
|
|
1965
2386
|
async signAndSendIntent(args) {
|
|
1966
2387
|
const intentSigner = args.signer ?? this.intentSigner;
|
|
1967
|
-
(0,
|
|
2388
|
+
(0, import_internal_utils22.assert)(intentSigner != null, "Intent signer is not provided");
|
|
1968
2389
|
const intentExecuter = new IntentExecuter({
|
|
1969
2390
|
env: this.env,
|
|
1970
2391
|
logger: args.logger,
|
|
@@ -2033,12 +2454,12 @@ var IntentsSDK = class {
|
|
|
2033
2454
|
intentHash,
|
|
2034
2455
|
logger
|
|
2035
2456
|
}) {
|
|
2036
|
-
return
|
|
2457
|
+
return import_internal_utils22.solverRelay.getStatus(
|
|
2037
2458
|
{
|
|
2038
2459
|
intent_hash: intentHash
|
|
2039
2460
|
},
|
|
2040
2461
|
{
|
|
2041
|
-
baseURL:
|
|
2462
|
+
baseURL: import_internal_utils22.configsByEnvironment[this.env].solverRelayBaseURL,
|
|
2042
2463
|
logger
|
|
2043
2464
|
}
|
|
2044
2465
|
);
|
|
@@ -2069,7 +2490,7 @@ var IntentsSDK = class {
|
|
|
2069
2490
|
withdrawalParams,
|
|
2070
2491
|
intentTx,
|
|
2071
2492
|
logger: args.logger,
|
|
2072
|
-
retryOptions:
|
|
2493
|
+
retryOptions: import_internal_utils22.RETRY_CONFIGS.FIVE_MINS_STEADY
|
|
2073
2494
|
});
|
|
2074
2495
|
if (!Array.isArray(args.withdrawalParams)) {
|
|
2075
2496
|
return {
|
|
@@ -2148,14 +2569,14 @@ var IntentSignerNearKeypair = class extends IntentSignerNEP413 {
|
|
|
2148
2569
|
};
|
|
2149
2570
|
|
|
2150
2571
|
// src/intents/intent-signer-impl/intent-signer-viem.ts
|
|
2151
|
-
var
|
|
2572
|
+
var import_internal_utils23 = require("@defuse-protocol/internal-utils");
|
|
2152
2573
|
var IntentSignerViem = class {
|
|
2153
2574
|
constructor(account) {
|
|
2154
2575
|
this.account = account;
|
|
2155
2576
|
}
|
|
2156
2577
|
async signIntent(intent) {
|
|
2157
2578
|
const payload = JSON.stringify({
|
|
2158
|
-
signer_id: intent.signer_id ??
|
|
2579
|
+
signer_id: intent.signer_id ?? import_internal_utils23.utils.authHandleToIntentsUserId({
|
|
2159
2580
|
identifier: this.account.address,
|
|
2160
2581
|
method: "evm"
|
|
2161
2582
|
}),
|
|
@@ -2173,7 +2594,7 @@ var IntentSignerViem = class {
|
|
|
2173
2594
|
return {
|
|
2174
2595
|
standard: "erc191",
|
|
2175
2596
|
payload,
|
|
2176
|
-
signature:
|
|
2597
|
+
signature: import_internal_utils23.utils.transformERC191Signature(signature)
|
|
2177
2598
|
};
|
|
2178
2599
|
}
|
|
2179
2600
|
};
|
|
@@ -2190,59 +2611,11 @@ function createIntentSignerViem(config) {
|
|
|
2190
2611
|
}
|
|
2191
2612
|
|
|
2192
2613
|
// index.ts
|
|
2193
|
-
var import_internal_utils22 = require("@defuse-protocol/internal-utils");
|
|
2194
|
-
|
|
2195
|
-
// src/bridges/omni-bridge/error.ts
|
|
2196
|
-
var import_internal_utils21 = require("@defuse-protocol/internal-utils");
|
|
2197
|
-
var OmniTransferNotFoundError = class extends import_internal_utils21.BaseError {
|
|
2198
|
-
constructor(txHash) {
|
|
2199
|
-
super("Omni transfer with given hash is not found in the relayer.", {
|
|
2200
|
-
metaMessages: [`OriginTxHash: ${txHash}`],
|
|
2201
|
-
name: "OmniTransferNotFoundError"
|
|
2202
|
-
});
|
|
2203
|
-
this.txHash = txHash;
|
|
2204
|
-
}
|
|
2205
|
-
};
|
|
2206
|
-
var OmniTransferDestinationChainHashNotFoundError = class extends import_internal_utils21.BaseError {
|
|
2207
|
-
constructor(txHash, destinationChain) {
|
|
2208
|
-
super("Relayer did not return destination chain hash for a transfer.", {
|
|
2209
|
-
metaMessages: [
|
|
2210
|
-
`OriginTxHash: ${txHash}`,
|
|
2211
|
-
`DestinationChain: ${destinationChain}`
|
|
2212
|
-
],
|
|
2213
|
-
name: "OmniTransferDestinationChainHashNotFoundError"
|
|
2214
|
-
});
|
|
2215
|
-
this.txHash = txHash;
|
|
2216
|
-
this.destinationChain = destinationChain;
|
|
2217
|
-
}
|
|
2218
|
-
};
|
|
2219
|
-
var TokenNotSupportedByOmniRelayerError = class extends import_internal_utils21.BaseError {
|
|
2220
|
-
constructor(token) {
|
|
2221
|
-
super(`Omni Relayer doesn't accept fee in the transferred token ${token}`, {
|
|
2222
|
-
metaMessages: [`Token: ${token}`],
|
|
2223
|
-
name: "TokenNotSupportedByOmniRelayerError"
|
|
2224
|
-
});
|
|
2225
|
-
this.token = token;
|
|
2226
|
-
}
|
|
2227
|
-
};
|
|
2228
|
-
var TokenNotFoundInDestinationChainError = class extends import_internal_utils21.BaseError {
|
|
2229
|
-
constructor(token, chainKind) {
|
|
2230
|
-
super(
|
|
2231
|
-
`The token ${token} doesn't exist in destination network ${chainKind}`,
|
|
2232
|
-
{
|
|
2233
|
-
metaMessages: [`Token: ${token}`, `Destination Chain: ${chainKind}`],
|
|
2234
|
-
name: "TokenNotFoundInDestinationChainError"
|
|
2235
|
-
}
|
|
2236
|
-
);
|
|
2237
|
-
this.token = token;
|
|
2238
|
-
}
|
|
2239
|
-
};
|
|
2240
|
-
|
|
2241
|
-
// index.ts
|
|
2242
|
-
var import_internal_utils23 = require("@defuse-protocol/internal-utils");
|
|
2243
2614
|
var import_internal_utils24 = require("@defuse-protocol/internal-utils");
|
|
2244
2615
|
var import_internal_utils25 = require("@defuse-protocol/internal-utils");
|
|
2245
2616
|
var import_internal_utils26 = require("@defuse-protocol/internal-utils");
|
|
2617
|
+
var import_internal_utils27 = require("@defuse-protocol/internal-utils");
|
|
2618
|
+
var import_internal_utils28 = require("@defuse-protocol/internal-utils");
|
|
2246
2619
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2247
2620
|
0 && (module.exports = {
|
|
2248
2621
|
AssertionError,
|