@defuse-protocol/intents-sdk 0.14.0 → 0.16.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 +452 -345
- package/dist/index.cjs +472 -66
- package/dist/index.d.cts +18 -10
- package/dist/index.d.ts +18 -10
- package/dist/index.js +477 -55
- package/package.json +6 -2
package/dist/index.cjs
CHANGED
|
@@ -30,26 +30,26 @@ 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_utils24.AssertionError,
|
|
34
|
+
BaseError: () => import_internal_utils21.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_utils23.HttpRequestError,
|
|
42
|
+
IntentSettlementError: () => import_internal_utils25.IntentSettlementError,
|
|
43
43
|
IntentsSDK: () => IntentsSDK,
|
|
44
44
|
MinWithdrawalAmountError: () => MinWithdrawalAmountError,
|
|
45
|
-
PoaWithdrawalInvariantError: () =>
|
|
46
|
-
PoaWithdrawalNotFoundError: () =>
|
|
47
|
-
PoaWithdrawalPendingError: () =>
|
|
48
|
-
QuoteError: () =>
|
|
49
|
-
RelayPublishError: () =>
|
|
45
|
+
PoaWithdrawalInvariantError: () => import_internal_utils22.PoaWithdrawalInvariantError,
|
|
46
|
+
PoaWithdrawalNotFoundError: () => import_internal_utils22.PoaWithdrawalNotFoundError,
|
|
47
|
+
PoaWithdrawalPendingError: () => import_internal_utils22.PoaWithdrawalPendingError,
|
|
48
|
+
QuoteError: () => import_internal_utils25.QuoteError,
|
|
49
|
+
RelayPublishError: () => import_internal_utils25.RelayPublishError,
|
|
50
50
|
RouteEnum: () => RouteEnum,
|
|
51
|
-
RpcRequestError: () =>
|
|
52
|
-
TimeoutError: () =>
|
|
51
|
+
RpcRequestError: () => import_internal_utils23.RpcRequestError,
|
|
52
|
+
TimeoutError: () => import_internal_utils23.TimeoutError,
|
|
53
53
|
TrustlineNotFoundError: () => TrustlineNotFoundError,
|
|
54
54
|
UnsupportedDestinationMemoError: () => UnsupportedDestinationMemoError,
|
|
55
55
|
createDefaultRoute: () => createDefaultRoute,
|
|
@@ -65,7 +65,7 @@ __export(index_exports, {
|
|
|
65
65
|
module.exports = __toCommonJS(index_exports);
|
|
66
66
|
|
|
67
67
|
// src/sdk.ts
|
|
68
|
-
var
|
|
68
|
+
var import_internal_utils19 = require("@defuse-protocol/internal-utils");
|
|
69
69
|
var import_omni_sdk3 = __toESM(require("@hot-labs/omni-sdk"), 1);
|
|
70
70
|
var import_viem2 = require("viem");
|
|
71
71
|
|
|
@@ -76,6 +76,7 @@ var import_internal_utils2 = require("@defuse-protocol/internal-utils");
|
|
|
76
76
|
var RouteEnum = {
|
|
77
77
|
HotBridge: "hot_bridge",
|
|
78
78
|
PoaBridge: "poa_bridge",
|
|
79
|
+
OmniBridge: "omni_bridge",
|
|
79
80
|
NearWithdrawal: "near_withdrawal",
|
|
80
81
|
VirtualChain: "virtual_chain",
|
|
81
82
|
InternalTransfer: "internal_transfer"
|
|
@@ -229,6 +230,7 @@ var import_internal_utils5 = require("@defuse-protocol/internal-utils");
|
|
|
229
230
|
var BridgeNameEnum = {
|
|
230
231
|
Hot: "hot",
|
|
231
232
|
Poa: "poa",
|
|
233
|
+
Omni: "omni",
|
|
232
234
|
None: null
|
|
233
235
|
};
|
|
234
236
|
|
|
@@ -236,22 +238,22 @@ var BridgeNameEnum = {
|
|
|
236
238
|
var import_internal_utils3 = require("@defuse-protocol/internal-utils");
|
|
237
239
|
var Chains = {
|
|
238
240
|
Bitcoin: "bip122:000000000019d6689c085ae165831e93",
|
|
241
|
+
Zcash: "bip122:00040fe8ec8471911baa1db1266ea15d",
|
|
242
|
+
Dogecoin: "bip122:1a91e3dace36e2be3bf030a65679fe82",
|
|
239
243
|
Ethereum: "eip155:1",
|
|
240
|
-
|
|
241
|
-
Arbitrum: "eip155:42161",
|
|
244
|
+
Optimism: "eip155:10",
|
|
242
245
|
BNB: "eip155:56",
|
|
246
|
+
Gnosis: "eip155:100",
|
|
243
247
|
Polygon: "eip155:137",
|
|
248
|
+
Base: "eip155:8453",
|
|
249
|
+
Arbitrum: "eip155:42161",
|
|
250
|
+
Avalanche: "eip155:43114",
|
|
251
|
+
Berachain: "eip155:80085",
|
|
244
252
|
Near: "near:mainnet",
|
|
245
253
|
Solana: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
|
|
246
254
|
Tron: "tron:27Lqcw",
|
|
247
|
-
Gnosis: "eip155:100",
|
|
248
255
|
XRPL: "xrpl:0",
|
|
249
|
-
Dogecoin: "bip122:1a91e3dace36e2be3bf030a65679fe82",
|
|
250
|
-
Zcash: "zcash:0",
|
|
251
|
-
Berachain: "eip155:80085",
|
|
252
256
|
TON: "tvm:-239",
|
|
253
|
-
Optimism: "eip155:10",
|
|
254
|
-
Avalanche: "eip155:43114",
|
|
255
257
|
Sui: "sui:mainnet",
|
|
256
258
|
Aptos: "aptos:mainnet",
|
|
257
259
|
Stellar: "stellar:pubnet",
|
|
@@ -749,7 +751,7 @@ var HotBridge = class {
|
|
|
749
751
|
}
|
|
750
752
|
if (typeof status === "string") {
|
|
751
753
|
return {
|
|
752
|
-
hash: "chain" in args.routeConfig ? formatTxHash(status, args.routeConfig.chain) : status
|
|
754
|
+
hash: "chain" in args.routeConfig && args.routeConfig.chain !== void 0 ? formatTxHash(status, args.routeConfig.chain) : status
|
|
753
755
|
};
|
|
754
756
|
}
|
|
755
757
|
throw new HotWithdrawalPendingError(args.tx.hash, args.index);
|
|
@@ -809,14 +811,407 @@ var IntentsBridge = class {
|
|
|
809
811
|
}
|
|
810
812
|
};
|
|
811
813
|
|
|
812
|
-
// src/bridges/
|
|
813
|
-
var
|
|
814
|
+
// src/bridges/omni-bridge/omni-bridge.ts
|
|
815
|
+
var import_internal_utils12 = require("@defuse-protocol/internal-utils");
|
|
814
816
|
var import_ttlcache = __toESM(require("@isaacs/ttlcache"), 1);
|
|
817
|
+
var import_attempt2 = require("@lifeomic/attempt");
|
|
818
|
+
var import_omni_bridge_sdk2 = require("omni-bridge-sdk");
|
|
815
819
|
|
|
816
|
-
// src/bridges/
|
|
820
|
+
// src/bridges/omni-bridge/error.ts
|
|
817
821
|
var import_internal_utils10 = require("@defuse-protocol/internal-utils");
|
|
822
|
+
var OmniTransferNotFoundError = class extends import_internal_utils10.BaseError {
|
|
823
|
+
constructor(txHash) {
|
|
824
|
+
super("Omni transfer with given hash is not found in the relayer.", {
|
|
825
|
+
metaMessages: [`OriginTxHash: ${txHash}`],
|
|
826
|
+
name: "OmniTransferNotFoundError"
|
|
827
|
+
});
|
|
828
|
+
this.txHash = txHash;
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
var OmniTransferDestinationChainHashNotFoundError = class extends import_internal_utils10.BaseError {
|
|
832
|
+
constructor(txHash, destinationChain) {
|
|
833
|
+
super("Relayer did not return destination chain hash for a transfer.", {
|
|
834
|
+
metaMessages: [
|
|
835
|
+
`OriginTxHash: ${txHash}`,
|
|
836
|
+
`DestinationChain: ${destinationChain}`
|
|
837
|
+
],
|
|
838
|
+
name: "OmniTransferDestinationChainHashNotFoundError"
|
|
839
|
+
});
|
|
840
|
+
this.txHash = txHash;
|
|
841
|
+
this.destinationChain = destinationChain;
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
var TokenNotSupportedByOmniRelayerError = class extends import_internal_utils10.BaseError {
|
|
845
|
+
constructor(token) {
|
|
846
|
+
super(`Omni Relayer doesn't accept fee in the transferred token ${token}`, {
|
|
847
|
+
metaMessages: [`Token: ${token}`],
|
|
848
|
+
name: "TokenNotSupportedByOmniRelayerError"
|
|
849
|
+
});
|
|
850
|
+
this.token = token;
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
var TokenNotFoundInDestinationChainError = class extends import_internal_utils10.BaseError {
|
|
854
|
+
constructor(token, chainKind) {
|
|
855
|
+
super(
|
|
856
|
+
`The token ${token} doesn't exist in destination network ${chainKind}`,
|
|
857
|
+
{
|
|
858
|
+
metaMessages: [`Token: ${token}`, `Destination Chain: ${chainKind}`],
|
|
859
|
+
name: "TokenNotFoundInDestinationChainError"
|
|
860
|
+
}
|
|
861
|
+
);
|
|
862
|
+
this.token = token;
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
|
|
866
|
+
// src/bridges/omni-bridge/omni-bridge-constants.ts
|
|
867
|
+
var NEAR_NATIVE_ASSET_ID3 = "nep141:wrap.near";
|
|
868
|
+
var OMNI_BRIDGE_CONTRACT = "omni.bridge.near";
|
|
869
|
+
|
|
870
|
+
// src/bridges/omni-bridge/omni-bridge-utils.ts
|
|
871
|
+
var import_internal_utils11 = require("@defuse-protocol/internal-utils");
|
|
872
|
+
var import_omni_bridge_sdk = require("omni-bridge-sdk");
|
|
818
873
|
function createWithdrawIntentPrimitive3(params) {
|
|
819
|
-
const { contractId: tokenAccountId } =
|
|
874
|
+
const { contractId: tokenAccountId, standard } = import_internal_utils11.utils.parseDefuseAssetId(
|
|
875
|
+
params.assetId
|
|
876
|
+
);
|
|
877
|
+
(0, import_internal_utils11.assert)(standard === "nep141", "Only NEP-141 is supported");
|
|
878
|
+
return {
|
|
879
|
+
intent: "ft_withdraw",
|
|
880
|
+
token: tokenAccountId,
|
|
881
|
+
receiver_id: OMNI_BRIDGE_CONTRACT,
|
|
882
|
+
amount: params.amount.toString(),
|
|
883
|
+
storage_deposit: params.storageDeposit > 0n ? params.storageDeposit.toString() : null,
|
|
884
|
+
msg: JSON.stringify({
|
|
885
|
+
recipient: (0, import_omni_bridge_sdk.omniAddress)(
|
|
886
|
+
caip2ToChainKind(params.origin),
|
|
887
|
+
params.destinationAddress
|
|
888
|
+
),
|
|
889
|
+
fee: params.transferredTokenFee.toString(),
|
|
890
|
+
native_token_fee: "0"
|
|
891
|
+
})
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
function targetChainSupportedByOmniBridge(network) {
|
|
895
|
+
switch (network) {
|
|
896
|
+
case Chains.Ethereum:
|
|
897
|
+
return true;
|
|
898
|
+
case Chains.Base:
|
|
899
|
+
return true;
|
|
900
|
+
case Chains.Arbitrum:
|
|
901
|
+
return true;
|
|
902
|
+
case Chains.Solana:
|
|
903
|
+
return true;
|
|
904
|
+
case Chains.Bitcoin:
|
|
905
|
+
return true;
|
|
906
|
+
default:
|
|
907
|
+
return false;
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
function caip2ToChainKind(network) {
|
|
911
|
+
switch (network) {
|
|
912
|
+
case Chains.Ethereum:
|
|
913
|
+
return import_omni_bridge_sdk.ChainKind.Eth;
|
|
914
|
+
case Chains.Base:
|
|
915
|
+
return import_omni_bridge_sdk.ChainKind.Base;
|
|
916
|
+
case Chains.Arbitrum:
|
|
917
|
+
return import_omni_bridge_sdk.ChainKind.Arb;
|
|
918
|
+
case Chains.Solana:
|
|
919
|
+
return import_omni_bridge_sdk.ChainKind.Sol;
|
|
920
|
+
case Chains.Bitcoin:
|
|
921
|
+
return import_omni_bridge_sdk.ChainKind.Btc;
|
|
922
|
+
default:
|
|
923
|
+
throw new Error(`Unsupported Omni network = ${network}`);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
function chainKindToCaip2(network) {
|
|
927
|
+
switch (network) {
|
|
928
|
+
case import_omni_bridge_sdk.ChainKind.Eth:
|
|
929
|
+
return Chains.Ethereum;
|
|
930
|
+
case import_omni_bridge_sdk.ChainKind.Base:
|
|
931
|
+
return Chains.Base;
|
|
932
|
+
case import_omni_bridge_sdk.ChainKind.Arb:
|
|
933
|
+
return Chains.Arbitrum;
|
|
934
|
+
case import_omni_bridge_sdk.ChainKind.Sol:
|
|
935
|
+
return Chains.Solana;
|
|
936
|
+
case import_omni_bridge_sdk.ChainKind.Btc:
|
|
937
|
+
return Chains.Bitcoin;
|
|
938
|
+
default:
|
|
939
|
+
throw new Error(`Unsupported Caip2 network = ${network}`);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
// src/bridges/omni-bridge/omni-bridge.ts
|
|
944
|
+
var _OmniBridge = class _OmniBridge {
|
|
945
|
+
// 86400000 - 1 day
|
|
946
|
+
constructor({
|
|
947
|
+
env,
|
|
948
|
+
nearProvider
|
|
949
|
+
}) {
|
|
950
|
+
this.storageDepositCache = new import_ttlcache.default({ ttl: 864e5 });
|
|
951
|
+
// TTL cache for supported tokens with 30-second TTL
|
|
952
|
+
this.supportedTokensCache = new import_ttlcache.default({ ttl: 864e5 });
|
|
953
|
+
// 86400000 - 1 day
|
|
954
|
+
this.destinationChainAddressCache = new import_ttlcache.default({ ttl: 864e5 });
|
|
955
|
+
this.env = env;
|
|
956
|
+
this.nearProvider = nearProvider;
|
|
957
|
+
this.omniBridgeAPI = new import_omni_bridge_sdk2.OmniBridgeAPI();
|
|
958
|
+
}
|
|
959
|
+
is(routeConfig) {
|
|
960
|
+
return routeConfig.route === RouteEnum.OmniBridge;
|
|
961
|
+
}
|
|
962
|
+
supports(params) {
|
|
963
|
+
try {
|
|
964
|
+
if (this.targetChainSpecified(params.routeConfig)) {
|
|
965
|
+
return targetChainSupportedByOmniBridge(params.routeConfig.chain);
|
|
966
|
+
}
|
|
967
|
+
return this.parseAssetId(params.assetId) !== null;
|
|
968
|
+
} catch {
|
|
969
|
+
return false;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
targetChainSpecified(routeConfig) {
|
|
973
|
+
return Boolean(
|
|
974
|
+
routeConfig?.route && routeConfig.route === RouteEnum.OmniBridge && routeConfig.chain
|
|
975
|
+
);
|
|
976
|
+
}
|
|
977
|
+
parseAssetId(assetId) {
|
|
978
|
+
const parsed = import_internal_utils12.utils.parseDefuseAssetId(assetId);
|
|
979
|
+
if (parsed.standard !== "nep141") return null;
|
|
980
|
+
const chain = (0, import_omni_bridge_sdk2.parseOriginChain)(parsed.contractId);
|
|
981
|
+
if (chain === null) return null;
|
|
982
|
+
return Object.assign(parsed, {
|
|
983
|
+
blockchain: chainKindToCaip2(chain),
|
|
984
|
+
bridgeName: BridgeNameEnum.Omni,
|
|
985
|
+
address: parsed.contractId
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
async tokenSupported(assetId, routeConfig) {
|
|
989
|
+
const parsed = import_internal_utils12.utils.parseDefuseAssetId(assetId);
|
|
990
|
+
if (parsed.standard !== "nep141") return null;
|
|
991
|
+
if (this.targetChainSpecified(routeConfig)) {
|
|
992
|
+
const tokenOnDestinationNetwork = await this.getCachedDestinationTokenAddress(
|
|
993
|
+
parsed.contractId,
|
|
994
|
+
routeConfig.chain
|
|
995
|
+
);
|
|
996
|
+
if (tokenOnDestinationNetwork === null) {
|
|
997
|
+
throw new TokenNotFoundInDestinationChainError(
|
|
998
|
+
assetId,
|
|
999
|
+
routeConfig.chain
|
|
1000
|
+
);
|
|
1001
|
+
}
|
|
1002
|
+
return Object.assign(parsed, {
|
|
1003
|
+
blockchain: routeConfig.chain,
|
|
1004
|
+
bridgeName: BridgeNameEnum.Omni,
|
|
1005
|
+
address: parsed.contractId
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
const chain = (0, import_omni_bridge_sdk2.parseOriginChain)(parsed.contractId);
|
|
1009
|
+
if (chain === null) return null;
|
|
1010
|
+
return Object.assign(parsed, {
|
|
1011
|
+
blockchain: chainKindToCaip2(chain),
|
|
1012
|
+
bridgeName: BridgeNameEnum.Omni,
|
|
1013
|
+
address: parsed.contractId
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
async createWithdrawalIntents(args) {
|
|
1017
|
+
const assetInfo = await this.tokenSupported(
|
|
1018
|
+
args.withdrawalParams.assetId,
|
|
1019
|
+
args.withdrawalParams.routeConfig
|
|
1020
|
+
);
|
|
1021
|
+
(0, import_internal_utils12.assert)(
|
|
1022
|
+
assetInfo !== null,
|
|
1023
|
+
`Asset ${args.withdrawalParams.assetId} is not supported`
|
|
1024
|
+
);
|
|
1025
|
+
const intents = [];
|
|
1026
|
+
if (args.feeEstimation.quote !== null) {
|
|
1027
|
+
intents.push({
|
|
1028
|
+
intent: "token_diff",
|
|
1029
|
+
diff: {
|
|
1030
|
+
[args.feeEstimation.quote.defuse_asset_identifier_in]: `-${args.feeEstimation.quote.amount_in}`,
|
|
1031
|
+
[args.feeEstimation.quote.defuse_asset_identifier_out]: args.feeEstimation.quote.amount_out
|
|
1032
|
+
},
|
|
1033
|
+
referral: args.referral
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1036
|
+
const intent = createWithdrawIntentPrimitive3({
|
|
1037
|
+
assetId: args.withdrawalParams.assetId,
|
|
1038
|
+
destinationAddress: args.withdrawalParams.destinationAddress,
|
|
1039
|
+
amount: args.withdrawalParams.amount + args.feeEstimation.amount,
|
|
1040
|
+
origin: assetInfo.blockchain,
|
|
1041
|
+
storageDeposit: args.feeEstimation.quote ? BigInt(args.feeEstimation.quote.amount_out) : 0n,
|
|
1042
|
+
transferredTokenFee: args.feeEstimation.amount
|
|
1043
|
+
});
|
|
1044
|
+
intents.push(intent);
|
|
1045
|
+
return Promise.resolve(intents);
|
|
1046
|
+
}
|
|
1047
|
+
async validateWithdrawal(args) {
|
|
1048
|
+
const assetInfo = await this.tokenSupported(args.assetId, args.routeConfig);
|
|
1049
|
+
(0, import_internal_utils12.assert)(assetInfo !== null, `Asset ${args.assetId} is not supported`);
|
|
1050
|
+
const supportedTokens = await this.getCachedSupportedTokens();
|
|
1051
|
+
if (!supportedTokens[assetInfo.contractId]) {
|
|
1052
|
+
throw new TokenNotSupportedByOmniRelayerError(args.assetId);
|
|
1053
|
+
}
|
|
1054
|
+
(0, import_internal_utils12.assert)(
|
|
1055
|
+
args.feeEstimation.amount > 0n,
|
|
1056
|
+
`Fee must be greater than zero. Current fee is ${args.feeEstimation.amount}.`
|
|
1057
|
+
);
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
async estimateWithdrawalFee(args) {
|
|
1061
|
+
const assetInfo = await this.tokenSupported(
|
|
1062
|
+
args.withdrawalParams.assetId,
|
|
1063
|
+
args.withdrawalParams.routeConfig
|
|
1064
|
+
);
|
|
1065
|
+
(0, import_internal_utils12.assert)(
|
|
1066
|
+
assetInfo !== null,
|
|
1067
|
+
`Asset ${args.withdrawalParams.assetId} is not supported`
|
|
1068
|
+
);
|
|
1069
|
+
const fee = await this.omniBridgeAPI.getFee(
|
|
1070
|
+
(0, import_omni_bridge_sdk2.omniAddress)(import_omni_bridge_sdk2.ChainKind.Near, import_internal_utils12.configsByEnvironment[this.env].contractID),
|
|
1071
|
+
(0, import_omni_bridge_sdk2.omniAddress)(
|
|
1072
|
+
caip2ToChainKind(assetInfo.blockchain),
|
|
1073
|
+
args.withdrawalParams.destinationAddress
|
|
1074
|
+
),
|
|
1075
|
+
(0, import_omni_bridge_sdk2.omniAddress)(import_omni_bridge_sdk2.ChainKind.Near, assetInfo.contractId)
|
|
1076
|
+
);
|
|
1077
|
+
(0, import_internal_utils12.assert)(
|
|
1078
|
+
fee.transferred_token_fee !== null,
|
|
1079
|
+
`Asset ${args.withdrawalParams.assetId} is not supported by the relayer`
|
|
1080
|
+
);
|
|
1081
|
+
const [minStorageBalance, userStorageBalance] = await this.getCachedStorageDepositValue(assetInfo.contractId);
|
|
1082
|
+
if (minStorageBalance <= userStorageBalance) {
|
|
1083
|
+
return {
|
|
1084
|
+
amount: BigInt(fee.transferred_token_fee),
|
|
1085
|
+
quote: null
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
const feeAmount = minStorageBalance - userStorageBalance;
|
|
1089
|
+
const feeQuote = await import_internal_utils12.solverRelay.getQuote({
|
|
1090
|
+
quoteParams: {
|
|
1091
|
+
defuse_asset_identifier_in: args.withdrawalParams.assetId,
|
|
1092
|
+
defuse_asset_identifier_out: NEAR_NATIVE_ASSET_ID3,
|
|
1093
|
+
exact_amount_out: feeAmount.toString(),
|
|
1094
|
+
wait_ms: args.quoteOptions?.waitMs
|
|
1095
|
+
},
|
|
1096
|
+
config: {
|
|
1097
|
+
baseURL: import_internal_utils12.configsByEnvironment[this.env].solverRelayBaseURL,
|
|
1098
|
+
logBalanceSufficient: false,
|
|
1099
|
+
logger: args.logger
|
|
1100
|
+
}
|
|
1101
|
+
});
|
|
1102
|
+
return {
|
|
1103
|
+
amount: BigInt(fee.transferred_token_fee) + BigInt(feeQuote.amount_in),
|
|
1104
|
+
quote: feeQuote
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1107
|
+
async waitForWithdrawalCompletion(args) {
|
|
1108
|
+
return (0, import_attempt2.retry)(
|
|
1109
|
+
async () => {
|
|
1110
|
+
if (args.signal?.aborted) {
|
|
1111
|
+
throw args.signal.reason;
|
|
1112
|
+
}
|
|
1113
|
+
const transfer = (await this.omniBridgeAPI.findOmniTransfers({
|
|
1114
|
+
transaction_id: args.tx.hash,
|
|
1115
|
+
offset: args.index,
|
|
1116
|
+
limit: 1
|
|
1117
|
+
}))[0];
|
|
1118
|
+
if (!transfer) throw new OmniTransferNotFoundError(args.tx.hash);
|
|
1119
|
+
const destinationChain = (0, import_omni_bridge_sdk2.getChain)(
|
|
1120
|
+
transfer.transfer_message.recipient
|
|
1121
|
+
);
|
|
1122
|
+
let txHash = null;
|
|
1123
|
+
if ((0, import_omni_bridge_sdk2.isEvmChain)(destinationChain)) {
|
|
1124
|
+
txHash = transfer.finalised?.EVMLog?.transaction_hash;
|
|
1125
|
+
} else if (destinationChain === import_omni_bridge_sdk2.ChainKind.Sol) {
|
|
1126
|
+
txHash = transfer.finalised?.Solana?.signature;
|
|
1127
|
+
} else {
|
|
1128
|
+
return { hash: null };
|
|
1129
|
+
}
|
|
1130
|
+
if (!txHash)
|
|
1131
|
+
throw new OmniTransferDestinationChainHashNotFoundError(
|
|
1132
|
+
args.tx.hash,
|
|
1133
|
+
import_omni_bridge_sdk2.ChainKind[destinationChain].toLowerCase()
|
|
1134
|
+
);
|
|
1135
|
+
return { hash: txHash };
|
|
1136
|
+
},
|
|
1137
|
+
{
|
|
1138
|
+
...args.retryOptions ?? import_internal_utils12.RETRY_CONFIGS.TWO_MINS_GRADUAL,
|
|
1139
|
+
handleError: (err, ctx) => {
|
|
1140
|
+
if (err instanceof OmniTransferNotFoundError || err === args.signal?.reason) {
|
|
1141
|
+
ctx.abort();
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
);
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* Gets storage deposit for a token to avoid frequent RPC calls.
|
|
1149
|
+
* Cache expires after one day using TTL cache.
|
|
1150
|
+
*/
|
|
1151
|
+
async getCachedStorageDepositValue(contractId) {
|
|
1152
|
+
const cached = this.storageDepositCache.get(contractId);
|
|
1153
|
+
if (cached != null) {
|
|
1154
|
+
return cached;
|
|
1155
|
+
}
|
|
1156
|
+
const data = await Promise.all([
|
|
1157
|
+
(0, import_internal_utils12.getNearNep141MinStorageBalance)({
|
|
1158
|
+
contractId,
|
|
1159
|
+
nearProvider: this.nearProvider
|
|
1160
|
+
}),
|
|
1161
|
+
(0, import_internal_utils12.getNearNep141StorageBalance)({
|
|
1162
|
+
contractId,
|
|
1163
|
+
accountId: OMNI_BRIDGE_CONTRACT,
|
|
1164
|
+
nearProvider: this.nearProvider
|
|
1165
|
+
})
|
|
1166
|
+
]);
|
|
1167
|
+
this.storageDepositCache.set(contractId, data);
|
|
1168
|
+
return data;
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Gets cached tokens supported by the omni relayer, tokens not listed there can't be transferred.
|
|
1172
|
+
* Cache expires after one day using TTL cache.
|
|
1173
|
+
*/
|
|
1174
|
+
async getCachedSupportedTokens() {
|
|
1175
|
+
const cached = this.supportedTokensCache.get(
|
|
1176
|
+
_OmniBridge.SUPPORTED_TOKENS_CACHE_KEY
|
|
1177
|
+
);
|
|
1178
|
+
if (cached != null) {
|
|
1179
|
+
return cached;
|
|
1180
|
+
}
|
|
1181
|
+
const data = await this.omniBridgeAPI.getAllowlistedTokens();
|
|
1182
|
+
this.supportedTokensCache.set(_OmniBridge.SUPPORTED_TOKENS_CACHE_KEY, data);
|
|
1183
|
+
return data;
|
|
1184
|
+
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Gets cached token address on destination chain.
|
|
1187
|
+
* Cache expires after one day using TTL cache.
|
|
1188
|
+
*/
|
|
1189
|
+
async getCachedDestinationTokenAddress(contractId, chain) {
|
|
1190
|
+
const key = `${chain}:${contractId}`;
|
|
1191
|
+
const cached = this.destinationChainAddressCache.get(key);
|
|
1192
|
+
if (cached != null) {
|
|
1193
|
+
return cached;
|
|
1194
|
+
}
|
|
1195
|
+
const tokenOnDestinationNetwork = await (0, import_omni_bridge_sdk2.getBridgedToken)(
|
|
1196
|
+
(0, import_omni_bridge_sdk2.omniAddress)(import_omni_bridge_sdk2.ChainKind.Near, contractId),
|
|
1197
|
+
caip2ToChainKind(chain)
|
|
1198
|
+
);
|
|
1199
|
+
this.destinationChainAddressCache.set(key, tokenOnDestinationNetwork);
|
|
1200
|
+
return tokenOnDestinationNetwork;
|
|
1201
|
+
}
|
|
1202
|
+
};
|
|
1203
|
+
// 86400000 - 1 day
|
|
1204
|
+
_OmniBridge.SUPPORTED_TOKENS_CACHE_KEY = "SUPPORTED_TOKENS_CACHE_KEY";
|
|
1205
|
+
var OmniBridge = _OmniBridge;
|
|
1206
|
+
|
|
1207
|
+
// src/bridges/poa-bridge/poa-bridge.ts
|
|
1208
|
+
var import_internal_utils14 = require("@defuse-protocol/internal-utils");
|
|
1209
|
+
var import_ttlcache2 = __toESM(require("@isaacs/ttlcache"), 1);
|
|
1210
|
+
|
|
1211
|
+
// src/bridges/poa-bridge/poa-bridge-utils.ts
|
|
1212
|
+
var import_internal_utils13 = require("@defuse-protocol/internal-utils");
|
|
1213
|
+
function createWithdrawIntentPrimitive4(params) {
|
|
1214
|
+
const { contractId: tokenAccountId } = import_internal_utils13.utils.parseDefuseAssetId(
|
|
820
1215
|
params.assetId
|
|
821
1216
|
);
|
|
822
1217
|
return {
|
|
@@ -891,7 +1286,7 @@ function contractIdToCaip2(contractId) {
|
|
|
891
1286
|
var PoaBridge = class {
|
|
892
1287
|
constructor({ env }) {
|
|
893
1288
|
// TTL cache for supported tokens with 30-second TTL
|
|
894
|
-
this.supportedTokensCache = new
|
|
1289
|
+
this.supportedTokensCache = new import_ttlcache2.default({ ttl: 30 * 1e3 });
|
|
895
1290
|
this.env = env;
|
|
896
1291
|
}
|
|
897
1292
|
is(routeConfig) {
|
|
@@ -909,9 +1304,9 @@ var PoaBridge = class {
|
|
|
909
1304
|
}
|
|
910
1305
|
}
|
|
911
1306
|
parseAssetId(assetId) {
|
|
912
|
-
const parsed =
|
|
1307
|
+
const parsed = import_internal_utils14.utils.parseDefuseAssetId(assetId);
|
|
913
1308
|
if (parsed.contractId.endsWith(
|
|
914
|
-
`.${
|
|
1309
|
+
`.${import_internal_utils14.configsByEnvironment[this.env].poaTokenFactoryContractID}`
|
|
915
1310
|
)) {
|
|
916
1311
|
return Object.assign(parsed, {
|
|
917
1312
|
blockchain: contractIdToCaip2(parsed.contractId),
|
|
@@ -923,7 +1318,7 @@ var PoaBridge = class {
|
|
|
923
1318
|
return null;
|
|
924
1319
|
}
|
|
925
1320
|
createWithdrawalIntents(args) {
|
|
926
|
-
const intent =
|
|
1321
|
+
const intent = createWithdrawIntentPrimitive4({
|
|
927
1322
|
...args.withdrawalParams,
|
|
928
1323
|
amount: args.withdrawalParams.amount + args.feeEstimation.amount,
|
|
929
1324
|
destinationMemo: args.withdrawalParams.destinationMemo
|
|
@@ -938,7 +1333,7 @@ var PoaBridge = class {
|
|
|
938
1333
|
*/
|
|
939
1334
|
async validateWithdrawal(args) {
|
|
940
1335
|
const assetInfo = this.parseAssetId(args.assetId);
|
|
941
|
-
(0,
|
|
1336
|
+
(0, import_internal_utils14.assert)(assetInfo != null, "Asset is not supported");
|
|
942
1337
|
const { tokens } = await this.getCachedSupportedTokens(
|
|
943
1338
|
[toPoaNetwork(assetInfo.blockchain)],
|
|
944
1339
|
args.logger
|
|
@@ -959,16 +1354,16 @@ var PoaBridge = class {
|
|
|
959
1354
|
}
|
|
960
1355
|
async estimateWithdrawalFee(args) {
|
|
961
1356
|
const assetInfo = this.parseAssetId(args.withdrawalParams.assetId);
|
|
962
|
-
(0,
|
|
963
|
-
const estimation = await
|
|
1357
|
+
(0, import_internal_utils14.assert)(assetInfo != null, "Asset is not supported");
|
|
1358
|
+
const estimation = await import_internal_utils14.poaBridge.httpClient.getWithdrawalEstimate(
|
|
964
1359
|
{
|
|
965
|
-
token:
|
|
1360
|
+
token: import_internal_utils14.utils.getTokenAccountId(args.withdrawalParams.assetId),
|
|
966
1361
|
address: args.withdrawalParams.destinationAddress,
|
|
967
1362
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
968
1363
|
chain: toPoaNetwork(assetInfo.blockchain)
|
|
969
1364
|
},
|
|
970
1365
|
{
|
|
971
|
-
baseURL:
|
|
1366
|
+
baseURL: import_internal_utils14.configsByEnvironment[this.env].poaBridgeBaseURL,
|
|
972
1367
|
logger: args.logger
|
|
973
1368
|
}
|
|
974
1369
|
);
|
|
@@ -978,12 +1373,12 @@ var PoaBridge = class {
|
|
|
978
1373
|
};
|
|
979
1374
|
}
|
|
980
1375
|
async waitForWithdrawalCompletion(args) {
|
|
981
|
-
const withdrawalStatus = await
|
|
1376
|
+
const withdrawalStatus = await import_internal_utils14.poaBridge.waitForWithdrawalCompletion({
|
|
982
1377
|
txHash: args.tx.hash,
|
|
983
1378
|
index: args.index,
|
|
984
1379
|
signal: args.signal ?? new AbortController().signal,
|
|
985
1380
|
retryOptions: args.retryOptions,
|
|
986
|
-
baseURL:
|
|
1381
|
+
baseURL: import_internal_utils14.configsByEnvironment[this.env].poaBridgeBaseURL,
|
|
987
1382
|
logger: args.logger
|
|
988
1383
|
});
|
|
989
1384
|
return { hash: withdrawalStatus.destinationTxHash };
|
|
@@ -998,10 +1393,10 @@ var PoaBridge = class {
|
|
|
998
1393
|
if (cached != null) {
|
|
999
1394
|
return cached;
|
|
1000
1395
|
}
|
|
1001
|
-
const data = await
|
|
1396
|
+
const data = await import_internal_utils14.poaBridge.httpClient.getSupportedTokens(
|
|
1002
1397
|
{ chains },
|
|
1003
1398
|
{
|
|
1004
|
-
baseURL:
|
|
1399
|
+
baseURL: import_internal_utils14.configsByEnvironment[this.env].poaBridgeBaseURL,
|
|
1005
1400
|
logger
|
|
1006
1401
|
}
|
|
1007
1402
|
);
|
|
@@ -1023,7 +1418,7 @@ var PUBLIC_STELLAR_RPC_URLS = {
|
|
|
1023
1418
|
};
|
|
1024
1419
|
|
|
1025
1420
|
// src/intents/intent-executer-impl/intent-executer.ts
|
|
1026
|
-
var
|
|
1421
|
+
var import_internal_utils15 = require("@defuse-protocol/internal-utils");
|
|
1027
1422
|
|
|
1028
1423
|
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_u64.js
|
|
1029
1424
|
var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
@@ -1404,7 +1799,7 @@ var IntentExecuter = class {
|
|
|
1404
1799
|
relayParams: relayParamsFactory,
|
|
1405
1800
|
...intentParams
|
|
1406
1801
|
}) {
|
|
1407
|
-
const verifyingContract =
|
|
1802
|
+
const verifyingContract = import_internal_utils15.configsByEnvironment[this.env].contractID;
|
|
1408
1803
|
let intentPayload = defaultIntentPayloadFactory({
|
|
1409
1804
|
verifying_contract: verifyingContract,
|
|
1410
1805
|
...intentParams
|
|
@@ -1454,7 +1849,7 @@ async function mergeIntentPayloads(basePayload, intentPayloadFactory) {
|
|
|
1454
1849
|
}
|
|
1455
1850
|
|
|
1456
1851
|
// src/intents/intent-relayer-impl/intent-relayer-public.ts
|
|
1457
|
-
var
|
|
1852
|
+
var import_internal_utils16 = require("@defuse-protocol/internal-utils");
|
|
1458
1853
|
var IntentRelayerPublic = class {
|
|
1459
1854
|
constructor({ env }) {
|
|
1460
1855
|
this.env = env;
|
|
@@ -1476,13 +1871,13 @@ var IntentRelayerPublic = class {
|
|
|
1476
1871
|
multiPayloads,
|
|
1477
1872
|
quoteHashes
|
|
1478
1873
|
}, ctx = {}) {
|
|
1479
|
-
const a = await
|
|
1874
|
+
const a = await import_internal_utils16.solverRelay.publishIntents(
|
|
1480
1875
|
{
|
|
1481
1876
|
quote_hashes: quoteHashes,
|
|
1482
1877
|
signed_datas: multiPayloads
|
|
1483
1878
|
},
|
|
1484
1879
|
{
|
|
1485
|
-
baseURL:
|
|
1880
|
+
baseURL: import_internal_utils16.configsByEnvironment[this.env].solverRelayBaseURL,
|
|
1486
1881
|
logger: ctx.logger
|
|
1487
1882
|
}
|
|
1488
1883
|
);
|
|
@@ -1492,10 +1887,10 @@ var IntentRelayerPublic = class {
|
|
|
1492
1887
|
throw a.unwrapErr();
|
|
1493
1888
|
}
|
|
1494
1889
|
async waitForSettlement(ticket, ctx = {}) {
|
|
1495
|
-
const result = await
|
|
1890
|
+
const result = await import_internal_utils16.solverRelay.waitForIntentSettlement({
|
|
1496
1891
|
intentHash: ticket,
|
|
1497
1892
|
signal: new AbortController().signal,
|
|
1498
|
-
baseURL:
|
|
1893
|
+
baseURL: import_internal_utils16.configsByEnvironment[this.env].solverRelayBaseURL,
|
|
1499
1894
|
logger: ctx.logger
|
|
1500
1895
|
});
|
|
1501
1896
|
return {
|
|
@@ -1503,7 +1898,7 @@ var IntentRelayerPublic = class {
|
|
|
1503
1898
|
hash: result.txHash,
|
|
1504
1899
|
// Usually relayer's account id is the verifying contract (`intents.near`),
|
|
1505
1900
|
// but it is not set in stone and may change in the future.
|
|
1506
|
-
accountId:
|
|
1901
|
+
accountId: import_internal_utils16.configsByEnvironment[this.env].contractID
|
|
1507
1902
|
}
|
|
1508
1903
|
};
|
|
1509
1904
|
}
|
|
@@ -1517,14 +1912,14 @@ var noopIntentSigner = {
|
|
|
1517
1912
|
};
|
|
1518
1913
|
|
|
1519
1914
|
// src/lib/array.ts
|
|
1520
|
-
var
|
|
1915
|
+
var import_internal_utils17 = require("@defuse-protocol/internal-utils");
|
|
1521
1916
|
function zip(arr1, arr2) {
|
|
1522
|
-
(0,
|
|
1917
|
+
(0, import_internal_utils17.assert)(arr1.length === arr2.length, "Arrays must have the same length");
|
|
1523
1918
|
return arr1.map((v, i) => [v, arr2[i]]);
|
|
1524
1919
|
}
|
|
1525
1920
|
|
|
1526
1921
|
// src/lib/configure-rpc-config.ts
|
|
1527
|
-
var
|
|
1922
|
+
var import_internal_utils18 = require("@defuse-protocol/internal-utils");
|
|
1528
1923
|
|
|
1529
1924
|
// src/lib/object.ts
|
|
1530
1925
|
function pick(obj, keys) {
|
|
@@ -1548,7 +1943,7 @@ function configureEvmRpcUrls(defaultRpcUrls, userRpcUrls, supportedChains) {
|
|
|
1548
1943
|
).map(([caip2, urls]) => [getEIP155ChainId(caip2), urls])
|
|
1549
1944
|
);
|
|
1550
1945
|
for (const [chainId, urls] of Object.entries(evmRpcUrls)) {
|
|
1551
|
-
(0,
|
|
1946
|
+
(0, import_internal_utils18.assert)(
|
|
1552
1947
|
urls.length > 0,
|
|
1553
1948
|
`EVM RPC URLs for chain ${chainId} are not provided`
|
|
1554
1949
|
);
|
|
@@ -1562,7 +1957,7 @@ function configureStellarRpcUrls(defaultRpcUrls, userRpcUrls) {
|
|
|
1562
1957
|
userRpcUrls?.[Chains.Stellar] ?? {}
|
|
1563
1958
|
);
|
|
1564
1959
|
for (const [key, value] of Object.entries(stellarRpcUrls)) {
|
|
1565
|
-
(0,
|
|
1960
|
+
(0, import_internal_utils18.assert)(value.length > 0, `Stellar RPC URL for ${key} is not provided`);
|
|
1566
1961
|
}
|
|
1567
1962
|
return stellarRpcUrls;
|
|
1568
1963
|
}
|
|
@@ -1574,6 +1969,9 @@ function createInternalTransferRoute() {
|
|
|
1574
1969
|
function createNearWithdrawalRoute(msg) {
|
|
1575
1970
|
return { route: RouteEnum.NearWithdrawal, msg };
|
|
1576
1971
|
}
|
|
1972
|
+
function createOmniWithdrawalRoute() {
|
|
1973
|
+
return { route: RouteEnum.OmniBridge };
|
|
1974
|
+
}
|
|
1577
1975
|
function createVirtualChainRoute(auroraEngineContractId, proxyTokenContractId) {
|
|
1578
1976
|
return {
|
|
1579
1977
|
route: RouteEnum.VirtualChain,
|
|
@@ -1614,6 +2012,8 @@ function determineRouteConfig(sdk, withdrawalParams) {
|
|
|
1614
2012
|
route: RouteEnum.PoaBridge,
|
|
1615
2013
|
chain: parseAssetId.blockchain
|
|
1616
2014
|
};
|
|
2015
|
+
case BridgeNameEnum.Omni:
|
|
2016
|
+
return createOmniWithdrawalRoute();
|
|
1617
2017
|
case BridgeNameEnum.None:
|
|
1618
2018
|
return createNearWithdrawalRoute();
|
|
1619
2019
|
default:
|
|
@@ -1627,9 +2027,9 @@ var IntentsSDK = class {
|
|
|
1627
2027
|
constructor(args) {
|
|
1628
2028
|
this.env = args.env ?? "production";
|
|
1629
2029
|
this.referral = args.referral;
|
|
1630
|
-
const nearRpcUrls = args.rpc?.[Chains.Near] ??
|
|
1631
|
-
(0,
|
|
1632
|
-
const nearProvider = (0,
|
|
2030
|
+
const nearRpcUrls = args.rpc?.[Chains.Near] ?? import_internal_utils19.PUBLIC_NEAR_RPC_URLS;
|
|
2031
|
+
(0, import_internal_utils19.assert)(nearRpcUrls.length > 0, "NEAR RPC URLs are not provided");
|
|
2032
|
+
const nearProvider = (0, import_internal_utils19.nearFailoverRpcProvider)({ urls: nearRpcUrls });
|
|
1633
2033
|
const stellarRpcUrls = configureStellarRpcUrls(
|
|
1634
2034
|
PUBLIC_STELLAR_RPC_URLS,
|
|
1635
2035
|
args.rpc
|
|
@@ -1661,6 +2061,10 @@ var IntentsSDK = class {
|
|
|
1661
2061
|
}
|
|
1662
2062
|
})
|
|
1663
2063
|
}),
|
|
2064
|
+
new OmniBridge({
|
|
2065
|
+
env: this.env,
|
|
2066
|
+
nearProvider
|
|
2067
|
+
}),
|
|
1664
2068
|
new DirectBridge({
|
|
1665
2069
|
env: this.env,
|
|
1666
2070
|
nearProvider
|
|
@@ -1680,6 +2084,8 @@ var IntentsSDK = class {
|
|
|
1680
2084
|
assetId: args.withdrawalParams.assetId,
|
|
1681
2085
|
amount: actualAmount,
|
|
1682
2086
|
destinationAddress: args.withdrawalParams.destinationAddress,
|
|
2087
|
+
feeEstimation: args.feeEstimation,
|
|
2088
|
+
routeConfig: args.withdrawalParams.routeConfig,
|
|
1683
2089
|
logger: args.logger
|
|
1684
2090
|
});
|
|
1685
2091
|
return bridge.createWithdrawalIntents({
|
|
@@ -1749,7 +2155,7 @@ var IntentsSDK = class {
|
|
|
1749
2155
|
const routeConfig = determineRouteConfig(this, w);
|
|
1750
2156
|
const route = routeConfig.route;
|
|
1751
2157
|
const index = indexes.get(route);
|
|
1752
|
-
(0,
|
|
2158
|
+
(0, import_internal_utils19.assert)(index != null, "Index is not found for route");
|
|
1753
2159
|
indexes.set(route, index + 1);
|
|
1754
2160
|
return {
|
|
1755
2161
|
routeConfig,
|
|
@@ -1783,7 +2189,7 @@ var IntentsSDK = class {
|
|
|
1783
2189
|
if (Array.isArray(args.withdrawalParams)) {
|
|
1784
2190
|
return result;
|
|
1785
2191
|
}
|
|
1786
|
-
(0,
|
|
2192
|
+
(0, import_internal_utils19.assert)(result.length === 1, "Unexpected result length");
|
|
1787
2193
|
return result[0];
|
|
1788
2194
|
}
|
|
1789
2195
|
parseAssetId(assetId) {
|
|
@@ -1797,7 +2203,7 @@ var IntentsSDK = class {
|
|
|
1797
2203
|
}
|
|
1798
2204
|
async signAndSendIntent(args) {
|
|
1799
2205
|
const intentSigner = args.signer ?? this.intentSigner;
|
|
1800
|
-
(0,
|
|
2206
|
+
(0, import_internal_utils19.assert)(intentSigner != null, "Intent signer is not provided");
|
|
1801
2207
|
const intentExecuter = new IntentExecuter({
|
|
1802
2208
|
env: this.env,
|
|
1803
2209
|
logger: args.logger,
|
|
@@ -1866,12 +2272,12 @@ var IntentsSDK = class {
|
|
|
1866
2272
|
intentHash,
|
|
1867
2273
|
logger
|
|
1868
2274
|
}) {
|
|
1869
|
-
return
|
|
2275
|
+
return import_internal_utils19.solverRelay.getStatus(
|
|
1870
2276
|
{
|
|
1871
2277
|
intent_hash: intentHash
|
|
1872
2278
|
},
|
|
1873
2279
|
{
|
|
1874
|
-
baseURL:
|
|
2280
|
+
baseURL: import_internal_utils19.configsByEnvironment[this.env].solverRelayBaseURL,
|
|
1875
2281
|
logger
|
|
1876
2282
|
}
|
|
1877
2283
|
);
|
|
@@ -1902,7 +2308,7 @@ var IntentsSDK = class {
|
|
|
1902
2308
|
withdrawalParams,
|
|
1903
2309
|
intentTx,
|
|
1904
2310
|
logger: args.logger,
|
|
1905
|
-
retryOptions:
|
|
2311
|
+
retryOptions: import_internal_utils19.RETRY_CONFIGS.FIVE_MINS_STEADY
|
|
1906
2312
|
});
|
|
1907
2313
|
if (!Array.isArray(args.withdrawalParams)) {
|
|
1908
2314
|
return {
|
|
@@ -1981,14 +2387,14 @@ var IntentSignerNearKeypair = class extends IntentSignerNEP413 {
|
|
|
1981
2387
|
};
|
|
1982
2388
|
|
|
1983
2389
|
// src/intents/intent-signer-impl/intent-signer-viem.ts
|
|
1984
|
-
var
|
|
2390
|
+
var import_internal_utils20 = require("@defuse-protocol/internal-utils");
|
|
1985
2391
|
var IntentSignerViem = class {
|
|
1986
2392
|
constructor(account) {
|
|
1987
2393
|
this.account = account;
|
|
1988
2394
|
}
|
|
1989
2395
|
async signIntent(intent) {
|
|
1990
2396
|
const payload = JSON.stringify({
|
|
1991
|
-
signer_id: intent.signer_id ??
|
|
2397
|
+
signer_id: intent.signer_id ?? import_internal_utils20.utils.authHandleToIntentsUserId({
|
|
1992
2398
|
identifier: this.account.address,
|
|
1993
2399
|
method: "evm"
|
|
1994
2400
|
}),
|
|
@@ -2006,7 +2412,7 @@ var IntentSignerViem = class {
|
|
|
2006
2412
|
return {
|
|
2007
2413
|
standard: "erc191",
|
|
2008
2414
|
payload,
|
|
2009
|
-
signature:
|
|
2415
|
+
signature: import_internal_utils20.utils.transformERC191Signature(signature)
|
|
2010
2416
|
};
|
|
2011
2417
|
}
|
|
2012
2418
|
};
|
|
@@ -2023,11 +2429,11 @@ function createIntentSignerViem(config) {
|
|
|
2023
2429
|
}
|
|
2024
2430
|
|
|
2025
2431
|
// index.ts
|
|
2026
|
-
var import_internal_utils18 = require("@defuse-protocol/internal-utils");
|
|
2027
|
-
var import_internal_utils19 = require("@defuse-protocol/internal-utils");
|
|
2028
|
-
var import_internal_utils20 = require("@defuse-protocol/internal-utils");
|
|
2029
2432
|
var import_internal_utils21 = require("@defuse-protocol/internal-utils");
|
|
2030
2433
|
var import_internal_utils22 = require("@defuse-protocol/internal-utils");
|
|
2434
|
+
var import_internal_utils23 = require("@defuse-protocol/internal-utils");
|
|
2435
|
+
var import_internal_utils24 = require("@defuse-protocol/internal-utils");
|
|
2436
|
+
var import_internal_utils25 = require("@defuse-protocol/internal-utils");
|
|
2031
2437
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2032
2438
|
0 && (module.exports = {
|
|
2033
2439
|
AssertionError,
|