@defuse-protocol/intents-sdk 0.49.0 → 0.51.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.
Files changed (23) hide show
  1. package/dist/index.d.cts +3 -1
  2. package/dist/index.d.ts +3 -1
  3. package/dist/src/bridges/omni-bridge/omni-bridge-utils.cjs +14 -13
  4. package/dist/src/bridges/omni-bridge/omni-bridge-utils.js +2 -1
  5. package/dist/src/bridges/omni-bridge/omni-bridge.cjs +13 -13
  6. package/dist/src/bridges/omni-bridge/omni-bridge.js +2 -2
  7. package/dist/src/constants/poa-tokens-routable-through-omni-bridge.cjs +4 -4
  8. package/dist/src/constants/poa-tokens-routable-through-omni-bridge.d.cts +1 -1
  9. package/dist/src/constants/poa-tokens-routable-through-omni-bridge.d.ts +1 -1
  10. package/dist/src/constants/poa-tokens-routable-through-omni-bridge.js +1 -1
  11. package/dist/src/intents/intent-signer-impl/factories.d.cts +6 -7
  12. package/dist/src/intents/intent-signer-impl/factories.d.ts +6 -7
  13. package/dist/src/intents/intent-signer-impl/intent-signer-near-keypair.d.cts +9 -1
  14. package/dist/src/intents/intent-signer-impl/intent-signer-near-keypair.d.ts +9 -2
  15. package/dist/src/intents/intent-signer-impl/intent-signer-nep413.cjs +21 -14
  16. package/dist/src/intents/intent-signer-impl/intent-signer-nep413.d.cts +17 -1
  17. package/dist/src/intents/intent-signer-impl/intent-signer-nep413.d.ts +17 -1
  18. package/dist/src/intents/intent-signer-impl/intent-signer-nep413.js +21 -14
  19. package/dist/src/intents/intent-signer-impl/intent-signer-viem.cjs +13 -9
  20. package/dist/src/intents/intent-signer-impl/intent-signer-viem.d.cts +13 -1
  21. package/dist/src/intents/intent-signer-impl/intent-signer-viem.d.ts +13 -1
  22. package/dist/src/intents/intent-signer-impl/intent-signer-viem.js +13 -9
  23. package/package.json +3 -5
package/dist/index.d.cts CHANGED
@@ -8,6 +8,8 @@ import { Chain, Chains } from "./src/lib/caip2.cjs";
8
8
  import { BatchWithdrawalResult, FeeEstimation, HotBridgeRouteConfig, IntentPublishResult, IntentSettlementStatus, InternalTransferRouteConfig, NearTxInfo, NearWithdrawalRouteConfig, OmniBridgeRouteConfig, ParsedAssetInfo, PoaBridgeRouteConfig, ProcessWithdrawalArgs, RouteConfig, SignAndSendArgs, SignAndSendWithdrawalArgs, SignedIntentsComposition, TxInfo, TxNoInfo, VirtualChainRouteConfig, WithdrawalIdentifier, WithdrawalParams, WithdrawalResult } from "./src/shared-types.cjs";
9
9
  import { IntentPayloadBuilder } from "./src/intents/intent-payload-builder.cjs";
10
10
  import { IntentsSDK, IntentsSDKConfig } from "./src/sdk.cjs";
11
+ import { Nep413RawPayload } from "./src/intents/intent-signer-impl/intent-signer-nep413.cjs";
12
+ import { Erc191RawPayload } from "./src/intents/intent-signer-impl/intent-signer-viem.cjs";
11
13
  import { createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem } from "./src/intents/intent-signer-impl/factories.cjs";
12
14
  import { createDefaultRoute, createHotBridgeRoute, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute } from "./src/lib/route-config-factory.cjs";
13
15
  import { POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE } from "./src/constants/poa-tokens-routable-through-omni-bridge.cjs";
@@ -19,4 +21,4 @@ import { InsufficientUtxoForOmniBridgeWithdrawalError, InsufficientUtxoForOmniBr
19
21
  import { computeIntentHash } from "./src/intents/intent-hash.cjs";
20
22
  import { validateAddress } from "./src/lib/validateAddress.cjs";
21
23
  import { AssertionError, AssertionErrorType, BaseError, BaseErrorType, EnvConfig, HttpRequestError, HttpRequestErrorType, ILogger, IntentSettlementError, IntentSettlementErrorType, NearIntentsEnv, PoaWithdrawalInvariantError, PoaWithdrawalInvariantErrorType, PoaWithdrawalNotFoundError, PoaWithdrawalNotFoundErrorType, PoaWithdrawalPendingError, PoaWithdrawalPendingErrorType, QuoteError, QuoteErrorType, RelayPublishError, RelayPublishErrorType, RetryOptions, RpcEndpoint, RpcEndpointConfig, RpcRequestError, RpcRequestErrorType, TimeoutError, TimeoutErrorType } from "@defuse-protocol/internal-utils";
22
- export { AssertionError, type AssertionErrorType, BaseError, type BaseErrorType, type BatchWithdrawalResult, BridgeNameEnum, type BridgeNameEnumValues, type Chain, Chains, DestinationExplicitNearAccountDoesntExistError, type DestinationExplicitNearAccountDoesntExistErrorType, type EnvConfig, type FeeEstimation, FeeExceedsAmountError, type FeeExceedsAmountErrorType, type HotBridgeRouteConfig, HotWithdrawalApiFeeRequestTimeoutError, type HotWithdrawalApiFeeRequestTimeoutErrorType, HotWithdrawalNotFoundError, type HotWithdrawalNotFoundErrorType, HttpRequestError, type HttpRequestErrorType, type IIntentSigner, type ILogger, InsufficientUtxoForOmniBridgeWithdrawalError, type InsufficientUtxoForOmniBridgeWithdrawalErrorType, type IntentPayload, IntentPayloadBuilder, type IntentPayloadFactory, type IntentPrimitive, type IntentPublishResult, type IntentRelayParamsFactory, IntentSettlementError, type IntentSettlementErrorType, type IntentSettlementStatus, IntentsNearOmniAvailableBalanceTooLowError, type IntentsNearOmniAvailableBalanceTooLowErrorType, IntentsSDK, type IntentsSDKConfig, type InternalTransferRouteConfig, InvalidFeeValueError, type InvalidFeeValueErrorType, MinWithdrawalAmountError, type MinWithdrawalAmountErrorType, type MultiPayload, type NearIntentsEnv, type NearTxInfo, type NearWithdrawalRouteConfig, type OmniBridgeRouteConfig, OmniWithdrawalApiFeeRequestTimeoutError, type OmniWithdrawalApiFeeRequestTimeoutErrorType, type OnBeforePublishIntentHook, POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE, type ParsedAssetInfo, type PoaBridgeRouteConfig, PoaWithdrawalInvariantError, type PoaWithdrawalInvariantErrorType, PoaWithdrawalNotFoundError, type PoaWithdrawalNotFoundErrorType, PoaWithdrawalPendingError, type PoaWithdrawalPendingErrorType, type ProcessWithdrawalArgs, QuoteError, type QuoteErrorType, RelayPublishError, type RelayPublishErrorType, type RetryOptions, type RouteConfig, RouteEnum, type RouteEnumValues, type RpcEndpoint, type RpcEndpointConfig, RpcRequestError, type RpcRequestErrorType, type SignAndSendArgs, type SignAndSendWithdrawalArgs, type SignedIntentsComposition, TimeoutError, type TimeoutErrorType, TokenNotFoundInDestinationChainError, type TokenNotFoundInDestinationChainErrorType, TrustlineNotFoundError, type TrustlineNotFoundErrorType, type TxInfo, type TxNoInfo, UnsupportedAssetIdError, type UnsupportedAssetIdErrorType, UnsupportedDestinationMemoError, type UnsupportedDestinationMemoErrorType, VersionedNonceBuilder, type VirtualChainRouteConfig, WithdrawalFailedError, type WithdrawalFailedErrorType, type WithdrawalIdentifier, type WithdrawalParams, type WithdrawalResult, WithdrawalWatchError, type WithdrawalWatchErrorType, computeIntentHash, createDefaultRoute, createHotBridgeRoute, createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute, validateAddress as validateAddressFormat };
24
+ export { AssertionError, type AssertionErrorType, BaseError, type BaseErrorType, type BatchWithdrawalResult, BridgeNameEnum, type BridgeNameEnumValues, type Chain, Chains, DestinationExplicitNearAccountDoesntExistError, type DestinationExplicitNearAccountDoesntExistErrorType, type EnvConfig, type Erc191RawPayload, type FeeEstimation, FeeExceedsAmountError, type FeeExceedsAmountErrorType, type HotBridgeRouteConfig, HotWithdrawalApiFeeRequestTimeoutError, type HotWithdrawalApiFeeRequestTimeoutErrorType, HotWithdrawalNotFoundError, type HotWithdrawalNotFoundErrorType, HttpRequestError, type HttpRequestErrorType, type IIntentSigner, type ILogger, InsufficientUtxoForOmniBridgeWithdrawalError, type InsufficientUtxoForOmniBridgeWithdrawalErrorType, type IntentPayload, IntentPayloadBuilder, type IntentPayloadFactory, type IntentPrimitive, type IntentPublishResult, type IntentRelayParamsFactory, IntentSettlementError, type IntentSettlementErrorType, type IntentSettlementStatus, IntentsNearOmniAvailableBalanceTooLowError, type IntentsNearOmniAvailableBalanceTooLowErrorType, IntentsSDK, type IntentsSDKConfig, type InternalTransferRouteConfig, InvalidFeeValueError, type InvalidFeeValueErrorType, MinWithdrawalAmountError, type MinWithdrawalAmountErrorType, type MultiPayload, type NearIntentsEnv, type NearTxInfo, type NearWithdrawalRouteConfig, type Nep413RawPayload, type OmniBridgeRouteConfig, OmniWithdrawalApiFeeRequestTimeoutError, type OmniWithdrawalApiFeeRequestTimeoutErrorType, type OnBeforePublishIntentHook, POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE, type ParsedAssetInfo, type PoaBridgeRouteConfig, PoaWithdrawalInvariantError, type PoaWithdrawalInvariantErrorType, PoaWithdrawalNotFoundError, type PoaWithdrawalNotFoundErrorType, PoaWithdrawalPendingError, type PoaWithdrawalPendingErrorType, type ProcessWithdrawalArgs, QuoteError, type QuoteErrorType, RelayPublishError, type RelayPublishErrorType, type RetryOptions, type RouteConfig, RouteEnum, type RouteEnumValues, type RpcEndpoint, type RpcEndpointConfig, RpcRequestError, type RpcRequestErrorType, type SignAndSendArgs, type SignAndSendWithdrawalArgs, type SignedIntentsComposition, TimeoutError, type TimeoutErrorType, TokenNotFoundInDestinationChainError, type TokenNotFoundInDestinationChainErrorType, TrustlineNotFoundError, type TrustlineNotFoundErrorType, type TxInfo, type TxNoInfo, UnsupportedAssetIdError, type UnsupportedAssetIdErrorType, UnsupportedDestinationMemoError, type UnsupportedDestinationMemoErrorType, VersionedNonceBuilder, type VirtualChainRouteConfig, WithdrawalFailedError, type WithdrawalFailedErrorType, type WithdrawalIdentifier, type WithdrawalParams, type WithdrawalResult, WithdrawalWatchError, type WithdrawalWatchErrorType, computeIntentHash, createDefaultRoute, createHotBridgeRoute, createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute, validateAddress as validateAddressFormat };
package/dist/index.d.ts CHANGED
@@ -8,6 +8,8 @@ import { Chain, Chains } from "./src/lib/caip2.js";
8
8
  import { BatchWithdrawalResult, FeeEstimation, HotBridgeRouteConfig, IntentPublishResult, IntentSettlementStatus, InternalTransferRouteConfig, NearTxInfo, NearWithdrawalRouteConfig, OmniBridgeRouteConfig, ParsedAssetInfo, PoaBridgeRouteConfig, ProcessWithdrawalArgs, RouteConfig, SignAndSendArgs, SignAndSendWithdrawalArgs, SignedIntentsComposition, TxInfo, TxNoInfo, VirtualChainRouteConfig, WithdrawalIdentifier, WithdrawalParams, WithdrawalResult } from "./src/shared-types.js";
9
9
  import { IntentPayloadBuilder } from "./src/intents/intent-payload-builder.js";
10
10
  import { IntentsSDK, IntentsSDKConfig } from "./src/sdk.js";
11
+ import { Nep413RawPayload } from "./src/intents/intent-signer-impl/intent-signer-nep413.js";
12
+ import { Erc191RawPayload } from "./src/intents/intent-signer-impl/intent-signer-viem.js";
11
13
  import { createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem } from "./src/intents/intent-signer-impl/factories.js";
12
14
  import { createDefaultRoute, createHotBridgeRoute, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute } from "./src/lib/route-config-factory.js";
13
15
  import { POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE } from "./src/constants/poa-tokens-routable-through-omni-bridge.js";
@@ -19,4 +21,4 @@ import { InsufficientUtxoForOmniBridgeWithdrawalError, InsufficientUtxoForOmniBr
19
21
  import { computeIntentHash } from "./src/intents/intent-hash.js";
20
22
  import { validateAddress } from "./src/lib/validateAddress.js";
21
23
  import { AssertionError, AssertionErrorType, BaseError, BaseErrorType, EnvConfig, HttpRequestError, HttpRequestErrorType, ILogger, IntentSettlementError, IntentSettlementErrorType, NearIntentsEnv, PoaWithdrawalInvariantError, PoaWithdrawalInvariantErrorType, PoaWithdrawalNotFoundError, PoaWithdrawalNotFoundErrorType, PoaWithdrawalPendingError, PoaWithdrawalPendingErrorType, QuoteError, QuoteErrorType, RelayPublishError, RelayPublishErrorType, RetryOptions, RpcEndpoint, RpcEndpointConfig, RpcRequestError, RpcRequestErrorType, TimeoutError, TimeoutErrorType } from "@defuse-protocol/internal-utils";
22
- export { AssertionError, type AssertionErrorType, BaseError, type BaseErrorType, type BatchWithdrawalResult, BridgeNameEnum, type BridgeNameEnumValues, type Chain, Chains, DestinationExplicitNearAccountDoesntExistError, type DestinationExplicitNearAccountDoesntExistErrorType, type EnvConfig, type FeeEstimation, FeeExceedsAmountError, type FeeExceedsAmountErrorType, type HotBridgeRouteConfig, HotWithdrawalApiFeeRequestTimeoutError, type HotWithdrawalApiFeeRequestTimeoutErrorType, HotWithdrawalNotFoundError, type HotWithdrawalNotFoundErrorType, HttpRequestError, type HttpRequestErrorType, type IIntentSigner, type ILogger, InsufficientUtxoForOmniBridgeWithdrawalError, type InsufficientUtxoForOmniBridgeWithdrawalErrorType, type IntentPayload, IntentPayloadBuilder, type IntentPayloadFactory, type IntentPrimitive, type IntentPublishResult, type IntentRelayParamsFactory, IntentSettlementError, type IntentSettlementErrorType, type IntentSettlementStatus, IntentsNearOmniAvailableBalanceTooLowError, type IntentsNearOmniAvailableBalanceTooLowErrorType, IntentsSDK, type IntentsSDKConfig, type InternalTransferRouteConfig, InvalidFeeValueError, type InvalidFeeValueErrorType, MinWithdrawalAmountError, type MinWithdrawalAmountErrorType, type MultiPayload, type NearIntentsEnv, type NearTxInfo, type NearWithdrawalRouteConfig, type OmniBridgeRouteConfig, OmniWithdrawalApiFeeRequestTimeoutError, type OmniWithdrawalApiFeeRequestTimeoutErrorType, type OnBeforePublishIntentHook, POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE, type ParsedAssetInfo, type PoaBridgeRouteConfig, PoaWithdrawalInvariantError, type PoaWithdrawalInvariantErrorType, PoaWithdrawalNotFoundError, type PoaWithdrawalNotFoundErrorType, PoaWithdrawalPendingError, type PoaWithdrawalPendingErrorType, type ProcessWithdrawalArgs, QuoteError, type QuoteErrorType, RelayPublishError, type RelayPublishErrorType, type RetryOptions, type RouteConfig, RouteEnum, type RouteEnumValues, type RpcEndpoint, type RpcEndpointConfig, RpcRequestError, type RpcRequestErrorType, type SignAndSendArgs, type SignAndSendWithdrawalArgs, type SignedIntentsComposition, TimeoutError, type TimeoutErrorType, TokenNotFoundInDestinationChainError, type TokenNotFoundInDestinationChainErrorType, TrustlineNotFoundError, type TrustlineNotFoundErrorType, type TxInfo, type TxNoInfo, UnsupportedAssetIdError, type UnsupportedAssetIdErrorType, UnsupportedDestinationMemoError, type UnsupportedDestinationMemoErrorType, VersionedNonceBuilder, type VirtualChainRouteConfig, WithdrawalFailedError, type WithdrawalFailedErrorType, type WithdrawalIdentifier, type WithdrawalParams, type WithdrawalResult, WithdrawalWatchError, type WithdrawalWatchErrorType, computeIntentHash, createDefaultRoute, createHotBridgeRoute, createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute, validateAddress as validateAddressFormat };
24
+ export { AssertionError, type AssertionErrorType, BaseError, type BaseErrorType, type BatchWithdrawalResult, BridgeNameEnum, type BridgeNameEnumValues, type Chain, Chains, DestinationExplicitNearAccountDoesntExistError, type DestinationExplicitNearAccountDoesntExistErrorType, type EnvConfig, type Erc191RawPayload, type FeeEstimation, FeeExceedsAmountError, type FeeExceedsAmountErrorType, type HotBridgeRouteConfig, HotWithdrawalApiFeeRequestTimeoutError, type HotWithdrawalApiFeeRequestTimeoutErrorType, HotWithdrawalNotFoundError, type HotWithdrawalNotFoundErrorType, HttpRequestError, type HttpRequestErrorType, type IIntentSigner, type ILogger, InsufficientUtxoForOmniBridgeWithdrawalError, type InsufficientUtxoForOmniBridgeWithdrawalErrorType, type IntentPayload, IntentPayloadBuilder, type IntentPayloadFactory, type IntentPrimitive, type IntentPublishResult, type IntentRelayParamsFactory, IntentSettlementError, type IntentSettlementErrorType, type IntentSettlementStatus, IntentsNearOmniAvailableBalanceTooLowError, type IntentsNearOmniAvailableBalanceTooLowErrorType, IntentsSDK, type IntentsSDKConfig, type InternalTransferRouteConfig, InvalidFeeValueError, type InvalidFeeValueErrorType, MinWithdrawalAmountError, type MinWithdrawalAmountErrorType, type MultiPayload, type NearIntentsEnv, type NearTxInfo, type NearWithdrawalRouteConfig, type Nep413RawPayload, type OmniBridgeRouteConfig, OmniWithdrawalApiFeeRequestTimeoutError, type OmniWithdrawalApiFeeRequestTimeoutErrorType, type OnBeforePublishIntentHook, POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE, type ParsedAssetInfo, type PoaBridgeRouteConfig, PoaWithdrawalInvariantError, type PoaWithdrawalInvariantErrorType, PoaWithdrawalNotFoundError, type PoaWithdrawalNotFoundErrorType, PoaWithdrawalPendingError, type PoaWithdrawalPendingErrorType, type ProcessWithdrawalArgs, QuoteError, type QuoteErrorType, RelayPublishError, type RelayPublishErrorType, type RetryOptions, type RouteConfig, RouteEnum, type RouteEnumValues, type RpcEndpoint, type RpcEndpointConfig, RpcRequestError, type RpcRequestErrorType, type SignAndSendArgs, type SignAndSendWithdrawalArgs, type SignedIntentsComposition, TimeoutError, type TimeoutErrorType, TokenNotFoundInDestinationChainError, type TokenNotFoundInDestinationChainErrorType, TrustlineNotFoundError, type TrustlineNotFoundErrorType, type TxInfo, type TxNoInfo, UnsupportedAssetIdError, type UnsupportedAssetIdErrorType, UnsupportedDestinationMemoError, type UnsupportedDestinationMemoErrorType, VersionedNonceBuilder, type VirtualChainRouteConfig, WithdrawalFailedError, type WithdrawalFailedErrorType, type WithdrawalIdentifier, type WithdrawalParams, type WithdrawalResult, WithdrawalWatchError, type WithdrawalWatchErrorType, computeIntentHash, createDefaultRoute, createHotBridgeRoute, createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute, validateAddress as validateAddressFormat };
@@ -5,13 +5,14 @@ const require_poa_tokens_routable_through_omni_bridge = require('../../constants
5
5
  let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
6
6
  let valibot = require("valibot");
7
7
  valibot = require_rolldown_runtime.__toESM(valibot);
8
- let omni_bridge_sdk = require("omni-bridge-sdk");
8
+ let _omni_bridge_core = require("@omni-bridge/core");
9
+ let _omni_bridge_near = require("@omni-bridge/near");
9
10
 
10
11
  //#region src/bridges/omni-bridge/omni-bridge-utils.ts
11
12
  function createWithdrawIntentsPrimitive(params) {
12
13
  const { contractId: tokenAccountId, standard } = _defuse_protocol_internal_utils.utils.parseDefuseAssetId(params.assetId);
13
14
  (0, _defuse_protocol_internal_utils.assert)(standard === "nep141", "Only NEP-141 is supported");
14
- const recipient = (0, omni_bridge_sdk.omniAddress)(params.omniChainKind, params.destinationAddress);
15
+ const recipient = (0, _omni_bridge_core.omniAddress)(params.omniChainKind, params.destinationAddress);
15
16
  let msg = "";
16
17
  const ftWithdrawPayload = {
17
18
  recipient,
@@ -25,7 +26,7 @@ function createWithdrawIntentsPrimitive(params) {
25
26
  }
26
27
  const intents = [];
27
28
  if (params.nativeFee > 0n) intents.push({
28
- deposit_for_account_id: (0, omni_bridge_sdk.calculateStorageAccountId)({
29
+ deposit_for_account_id: (0, _omni_bridge_near.calculateStorageAccountId)({
29
30
  token: `near:${tokenAccountId}`,
30
31
  amount: params.amount,
31
32
  recipient,
@@ -56,12 +57,12 @@ function createWithdrawIntentsPrimitive(params) {
56
57
  * This serves as a single source of truth for bidirectional chain conversions.
57
58
  */
58
59
  const CHAIN_MAPPINGS = [
59
- [require_caip2.Chains.Ethereum, omni_bridge_sdk.ChainKind.Eth],
60
- [require_caip2.Chains.Base, omni_bridge_sdk.ChainKind.Base],
61
- [require_caip2.Chains.Arbitrum, omni_bridge_sdk.ChainKind.Arb],
62
- [require_caip2.Chains.Solana, omni_bridge_sdk.ChainKind.Sol],
63
- [require_caip2.Chains.BNB, omni_bridge_sdk.ChainKind.Bnb],
64
- [require_caip2.Chains.Bitcoin, omni_bridge_sdk.ChainKind.Btc]
60
+ [require_caip2.Chains.Ethereum, _omni_bridge_core.ChainKind.Eth],
61
+ [require_caip2.Chains.Base, _omni_bridge_core.ChainKind.Base],
62
+ [require_caip2.Chains.Arbitrum, _omni_bridge_core.ChainKind.Arb],
63
+ [require_caip2.Chains.Solana, _omni_bridge_core.ChainKind.Sol],
64
+ [require_caip2.Chains.BNB, _omni_bridge_core.ChainKind.Bnb],
65
+ [require_caip2.Chains.Bitcoin, _omni_bridge_core.ChainKind.Btc]
65
66
  ];
66
67
  function caip2ToChainKind(network) {
67
68
  return CHAIN_MAPPINGS.find(([chain]) => chain === network)?.[1] ?? null;
@@ -69,7 +70,7 @@ function caip2ToChainKind(network) {
69
70
  function chainKindToCaip2(network) {
70
71
  return CHAIN_MAPPINGS.find(([_, kind]) => kind === network)?.[0] ?? null;
71
72
  }
72
- const UTXO_CHAINS = [omni_bridge_sdk.ChainKind.Btc];
73
+ const UTXO_CHAINS = [_omni_bridge_core.ChainKind.Btc];
73
74
  function isUtxoChain(network) {
74
75
  return UTXO_CHAINS.includes(network);
75
76
  }
@@ -78,7 +79,7 @@ function poaContractIdToChainKind(contractId) {
78
79
  }
79
80
  function validateOmniToken(nearAddress) {
80
81
  if (nearAddress.endsWith(".testnet")) return false;
81
- return (0, omni_bridge_sdk.isBridgeToken)(nearAddress);
82
+ return (0, _omni_bridge_core.isBridgeToken)(nearAddress);
82
83
  }
83
84
  async function getAccountOmniStorageBalance(nearProvider, accountId) {
84
85
  return _defuse_protocol_internal_utils.utils.queryContract({
@@ -111,7 +112,7 @@ async function getBridgedToken(nearProvider, tokenAddress, destinationChain) {
111
112
  contractId: require_omni_bridge_constants.OMNI_BRIDGE_CONTRACT,
112
113
  methodName: "get_bridged_token",
113
114
  args: {
114
- chain: omni_bridge_sdk.ChainKind[destinationChain].toString(),
115
+ chain: _omni_bridge_core.ChainKind[destinationChain].toString(),
115
116
  address: tokenAddress
116
117
  },
117
118
  finality: "optimistic",
@@ -126,7 +127,7 @@ async function getBridgedToken(nearProvider, tokenAddress, destinationChain) {
126
127
  * @returns Promise resolving to the token's decimal information
127
128
  */
128
129
  async function getTokenDecimals(nearProvider, tokenAddress) {
129
- if ((0, omni_bridge_sdk.getChain)(tokenAddress) === omni_bridge_sdk.ChainKind.Near) throw new Error("Token decimals cannot be queried using NEAR addresses. Use the token's foreign chain representation (e.g., eth:0x...) to query decimals.");
130
+ if ((0, _omni_bridge_core.getChain)(tokenAddress) === _omni_bridge_core.ChainKind.Near) throw new Error("Token decimals cannot be queried using NEAR addresses. Use the token's foreign chain representation (e.g., eth:0x...) to query decimals.");
130
131
  return _defuse_protocol_internal_utils.utils.queryContract({
131
132
  contractId: require_omni_bridge_constants.OMNI_BRIDGE_CONTRACT,
132
133
  methodName: "get_token_decimals",
@@ -3,7 +3,8 @@ import { MIN_GAS_AMOUNT, OMNI_BRIDGE_CONTRACT } from "./omni-bridge-constants.js
3
3
  import { POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE } from "../../constants/poa-tokens-routable-through-omni-bridge.js";
4
4
  import { assert, utils } from "@defuse-protocol/internal-utils";
5
5
  import * as v from "valibot";
6
- import { ChainKind, calculateStorageAccountId, getChain, isBridgeToken, omniAddress } from "omni-bridge-sdk";
6
+ import { ChainKind, getChain, isBridgeToken, omniAddress } from "@omni-bridge/core";
7
+ import { calculateStorageAccountId } from "@omni-bridge/near";
7
8
 
8
9
  //#region src/bridges/omni-bridge/omni-bridge-utils.ts
9
10
  function createWithdrawIntentsPrimitive(params) {
@@ -13,7 +13,7 @@ let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils")
13
13
  let lru_cache = require("lru-cache");
14
14
  let _isaacs_ttlcache = require("@isaacs/ttlcache");
15
15
  _isaacs_ttlcache = require_rolldown_runtime.__toESM(_isaacs_ttlcache);
16
- let omni_bridge_sdk = require("omni-bridge-sdk");
16
+ let _omni_bridge_core = require("@omni-bridge/core");
17
17
 
18
18
  //#region src/bridges/omni-bridge/omni-bridge.ts
19
19
  var OmniBridge = class {
@@ -27,7 +27,7 @@ var OmniBridge = class {
27
27
  this.tokenDecimalsCache = new _isaacs_ttlcache.default({ ttl: 36e5 });
28
28
  this.envConfig = envConfig;
29
29
  this.nearProvider = nearProvider;
30
- this.omniBridgeAPI = new omni_bridge_sdk.OmniBridgeAPI();
30
+ this.omniBridgeAPI = new _omni_bridge_core.BridgeAPI("mainnet");
31
31
  this.solverRelayApiKey = solverRelayApiKey;
32
32
  this.routeMigratedPoaTokensThroughOmniBridge = routeMigratedPoaTokensThroughOmniBridge ?? false;
33
33
  }
@@ -53,7 +53,7 @@ var OmniBridge = class {
53
53
  if (omniChainKind === null) throw new require_errors.UnsupportedAssetIdError(params.assetId, `Chain ${params.routeConfig.chain} is not supported in Omni Bridge.`);
54
54
  caip2Chain = params.routeConfig.chain;
55
55
  } else {
56
- omniChainKind = poaTokenRoutedThroughOmniBridge ? require_omni_bridge_utils.poaContractIdToChainKind(parsed.contractId) : (0, omni_bridge_sdk.parseOriginChain)(parsed.contractId);
56
+ omniChainKind = poaTokenRoutedThroughOmniBridge ? require_omni_bridge_utils.poaContractIdToChainKind(parsed.contractId) : (0, _omni_bridge_core.parseOriginChain)(parsed.contractId);
57
57
  if (omniChainKind === null) throw new require_errors.UnsupportedAssetIdError(params.assetId, `Withdrawal of ${parsed.contractId} to its origin chain is not supported in Omni Bridge.`);
58
58
  caip2Chain = require_omni_bridge_utils.chainKindToCaip2(omniChainKind);
59
59
  if (caip2Chain === null) throw new require_errors.UnsupportedAssetIdError(params.assetId, `Withdrawal of ${parsed.contractId} to its origin chain is not supported in Omni Bridge.`);
@@ -67,7 +67,7 @@ var OmniBridge = class {
67
67
  parseAssetId(assetId) {
68
68
  const parsed = require_parse_defuse_asset_id.parseDefuseAssetId(assetId);
69
69
  if (parsed.standard !== "nep141") return null;
70
- const omniChainKind = this.isPoaTokenRoutedThroughOmniBridge(parsed.contractId) ? require_omni_bridge_utils.poaContractIdToChainKind(parsed.contractId) : (0, omni_bridge_sdk.parseOriginChain)(parsed.contractId);
70
+ const omniChainKind = this.isPoaTokenRoutedThroughOmniBridge(parsed.contractId) ? require_omni_bridge_utils.poaContractIdToChainKind(parsed.contractId) : (0, _omni_bridge_core.parseOriginChain)(parsed.contractId);
71
71
  if (omniChainKind === null) return null;
72
72
  const blockchain = require_omni_bridge_utils.chainKindToCaip2(omniChainKind);
73
73
  if (blockchain === null) return null;
@@ -86,7 +86,7 @@ var OmniBridge = class {
86
86
  omniChainKind = require_omni_bridge_utils.caip2ToChainKind(routeConfig.chain);
87
87
  blockchain = routeConfig.chain;
88
88
  } else {
89
- omniChainKind = this.isPoaTokenRoutedThroughOmniBridge(parsed.contractId) ? require_omni_bridge_utils.poaContractIdToChainKind(parsed.contractId) : (0, omni_bridge_sdk.parseOriginChain)(parsed.contractId);
89
+ omniChainKind = this.isPoaTokenRoutedThroughOmniBridge(parsed.contractId) ? require_omni_bridge_utils.poaContractIdToChainKind(parsed.contractId) : (0, _omni_bridge_core.parseOriginChain)(parsed.contractId);
90
90
  if (omniChainKind === null) return null;
91
91
  blockchain = require_omni_bridge_utils.chainKindToCaip2(omniChainKind);
92
92
  }
@@ -159,7 +159,7 @@ var OmniBridge = class {
159
159
  const decimals = await this.getCachedTokenDecimals(destTokenAddress);
160
160
  (0, _defuse_protocol_internal_utils.assert)(decimals !== null, `Failed to retrieve token decimals for address ${destTokenAddress} via OmniBridge contract.
161
161
  Ensure the token is supported and the address is correct.`);
162
- if ((0, omni_bridge_sdk.verifyTransferAmount)(args.amount, 0n, decimals.origin_decimals, decimals.decimals) === false) throw new require_errors.MinWithdrawalAmountError((0, omni_bridge_sdk.getMinimumTransferableAmount)(decimals.origin_decimals, decimals.decimals), args.amount, args.assetId);
162
+ if ((0, _omni_bridge_core.verifyTransferAmount)(args.amount, 0n, decimals.origin_decimals, decimals.decimals) === false) throw new require_errors.MinWithdrawalAmountError((0, _omni_bridge_core.getMinimumTransferableAmount)(decimals.origin_decimals, decimals.decimals), args.amount, args.assetId);
163
163
  const storageBalance = await require_omni_bridge_utils.getAccountOmniStorageBalance(this.nearProvider, this.envConfig.contractID);
164
164
  const intentsNearStorageBalance = storageBalance === null ? 0n : BigInt(storageBalance.available);
165
165
  if (intentsNearStorageBalance <= require_omni_bridge_constants.MIN_ALLOWED_STORAGE_BALANCE_FOR_INTENTS_NEAR) throw new require_error.IntentsNearOmniAvailableBalanceTooLowError(intentsNearStorageBalance.toString());
@@ -169,7 +169,7 @@ var OmniBridge = class {
169
169
  (0, _defuse_protocol_internal_utils.assert)(require_estimate_fee.getUnderlyingFee(args.feeEstimation, require_route_enum.RouteEnum.OmniBridge, "relayerFee") > 0n, `Invalid Omni Bridge relayer fee for non UTXO chain withdrawal: expected > 0, got ${relayerFee}`);
170
170
  }
171
171
  if (utxoChainWithdrawal) {
172
- const fee = await (0, _defuse_protocol_internal_utils.withTimeout)(() => this.omniBridgeAPI.getFee((0, omni_bridge_sdk.omniAddress)(omni_bridge_sdk.ChainKind.Near, this.envConfig.contractID), (0, omni_bridge_sdk.omniAddress)(omniChainKind, args.destinationAddress), (0, omni_bridge_sdk.omniAddress)(omni_bridge_sdk.ChainKind.Near, assetInfo.contractId), args.amount), {
172
+ const fee = await (0, _defuse_protocol_internal_utils.withTimeout)(() => this.omniBridgeAPI.getFee((0, _omni_bridge_core.omniAddress)(_omni_bridge_core.ChainKind.Near, this.envConfig.contractID), (0, _omni_bridge_core.omniAddress)(omniChainKind, args.destinationAddress), (0, _omni_bridge_core.omniAddress)(_omni_bridge_core.ChainKind.Near, assetInfo.contractId), args.amount), {
173
173
  timeout: typeof window !== "undefined" ? 1e4 : 3e3,
174
174
  errorInstance: new require_error.OmniWithdrawalApiFeeRequestTimeoutError()
175
175
  });
@@ -189,7 +189,7 @@ var OmniBridge = class {
189
189
  (0, _defuse_protocol_internal_utils.assert)(assetInfo !== null, `Asset ${args.withdrawalParams.assetId} is not supported by Omni Bridge`);
190
190
  const omniChainKind = require_omni_bridge_utils.caip2ToChainKind(assetInfo.blockchain);
191
191
  (0, _defuse_protocol_internal_utils.assert)(omniChainKind !== null, `Chain ${assetInfo.blockchain} is not supported by Omni Bridge`);
192
- const fee = await (0, _defuse_protocol_internal_utils.withTimeout)(() => this.omniBridgeAPI.getFee((0, omni_bridge_sdk.omniAddress)(omni_bridge_sdk.ChainKind.Near, this.envConfig.contractID), (0, omni_bridge_sdk.omniAddress)(omniChainKind, args.withdrawalParams.destinationAddress), (0, omni_bridge_sdk.omniAddress)(omni_bridge_sdk.ChainKind.Near, assetInfo.contractId), args.withdrawalParams.amount), {
192
+ const fee = await (0, _defuse_protocol_internal_utils.withTimeout)(() => this.omniBridgeAPI.getFee((0, _omni_bridge_core.omniAddress)(_omni_bridge_core.ChainKind.Near, this.envConfig.contractID), (0, _omni_bridge_core.omniAddress)(omniChainKind, args.withdrawalParams.destinationAddress), (0, _omni_bridge_core.omniAddress)(_omni_bridge_core.ChainKind.Near, assetInfo.contractId), args.withdrawalParams.amount), {
193
193
  timeout: typeof window !== "undefined" ? 1e4 : 3e3,
194
194
  errorInstance: new require_error.OmniWithdrawalApiFeeRequestTimeoutError()
195
195
  });
@@ -250,11 +250,11 @@ var OmniBridge = class {
250
250
  async describeWithdrawal(args) {
251
251
  const transfer = (await this.omniBridgeAPI.getTransfer({ transactionHash: args.tx.hash }))[args.index];
252
252
  if (transfer == null || transfer.transfer_message == null) return { status: "pending" };
253
- const destinationChain = (0, omni_bridge_sdk.getChain)(transfer.transfer_message.recipient);
253
+ const destinationChain = (0, _omni_bridge_core.getChain)(transfer.transfer_message.recipient);
254
254
  let txHash = null;
255
- if ((0, omni_bridge_sdk.isEvmChain)(destinationChain)) txHash = transfer.finalised?.EVMLog?.transaction_hash;
256
- else if (destinationChain === omni_bridge_sdk.ChainKind.Sol) txHash = transfer.finalised?.Solana?.signature;
257
- else if (destinationChain === omni_bridge_sdk.ChainKind.Btc) txHash = typeof window !== "undefined" ? transfer.utxo_transfer?.btc_pending_id : transfer.finalised?.UtxoLog?.transaction_hash;
255
+ if ((0, _omni_bridge_core.isEvmChain)(destinationChain)) txHash = transfer.finalised?.EVMLog?.transaction_hash;
256
+ else if (destinationChain === _omni_bridge_core.ChainKind.Sol) txHash = transfer.finalised?.Solana?.signature;
257
+ else if (destinationChain === _omni_bridge_core.ChainKind.Btc) txHash = typeof window !== "undefined" ? transfer.utxo_transfer?.btc_pending_id : transfer.finalised?.UtxoLog?.transaction_hash;
258
258
  else return {
259
259
  status: "completed",
260
260
  txHash: null
@@ -289,7 +289,7 @@ var OmniBridge = class {
289
289
  const key = `${omniChainKind}:${contractId}`;
290
290
  const cached = this.destinationChainAddressCache.get(key);
291
291
  if (cached !== void 0) return cached;
292
- const tokenOnDestinationNetwork = await require_omni_bridge_utils.getBridgedToken(this.nearProvider, (0, omni_bridge_sdk.omniAddress)(omni_bridge_sdk.ChainKind.Near, contractId), omniChainKind);
292
+ const tokenOnDestinationNetwork = await require_omni_bridge_utils.getBridgedToken(this.nearProvider, (0, _omni_bridge_core.omniAddress)(_omni_bridge_core.ChainKind.Near, contractId), omniChainKind);
293
293
  if (tokenOnDestinationNetwork !== null) this.destinationChainAddressCache.set(key, tokenOnDestinationNetwork);
294
294
  return tokenOnDestinationNetwork;
295
295
  }
@@ -11,7 +11,7 @@ import { caip2ToChainKind, chainKindToCaip2, createWithdrawIntentsPrimitive, get
11
11
  import { assert, getNearNep141MinStorageBalance, getNearNep141StorageBalance, withTimeout } from "@defuse-protocol/internal-utils";
12
12
  import { LRUCache } from "lru-cache";
13
13
  import TTLCache from "@isaacs/ttlcache";
14
- import { ChainKind, OmniBridgeAPI, getChain, getMinimumTransferableAmount, isEvmChain, omniAddress, parseOriginChain, verifyTransferAmount } from "omni-bridge-sdk";
14
+ import { BridgeAPI, ChainKind, getChain, getMinimumTransferableAmount, isEvmChain, omniAddress, parseOriginChain, verifyTransferAmount } from "@omni-bridge/core";
15
15
 
16
16
  //#region src/bridges/omni-bridge/omni-bridge.ts
17
17
  var OmniBridge = class {
@@ -25,7 +25,7 @@ var OmniBridge = class {
25
25
  this.tokenDecimalsCache = new TTLCache({ ttl: 36e5 });
26
26
  this.envConfig = envConfig;
27
27
  this.nearProvider = nearProvider;
28
- this.omniBridgeAPI = new OmniBridgeAPI();
28
+ this.omniBridgeAPI = new BridgeAPI("mainnet");
29
29
  this.solverRelayApiKey = solverRelayApiKey;
30
30
  this.routeMigratedPoaTokensThroughOmniBridge = routeMigratedPoaTokensThroughOmniBridge ?? false;
31
31
  }
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
- let omni_bridge_sdk = require("omni-bridge-sdk");
2
+ let _omni_bridge_core = require("@omni-bridge/core");
3
3
 
4
4
  //#region src/constants/poa-tokens-routable-through-omni-bridge.ts
5
5
  /**
@@ -8,9 +8,9 @@ let omni_bridge_sdk = require("omni-bridge-sdk");
8
8
  * feature flag to enable Omni Bridge routing for these tokens.
9
9
  */
10
10
  const POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE = {
11
- "sol-57d087fd8c460f612f8701f5499ad8b2eec5ab68.omft.near": omni_bridge_sdk.ChainKind.Sol,
12
- "sol-c58e6539c2f2e097c251f8edf11f9c03e581f8d4.omft.near": omni_bridge_sdk.ChainKind.Sol,
13
- "sol-b9c68f94ec8fd160137af8cdfe5e61cd68e2afba.omft.near": omni_bridge_sdk.ChainKind.Sol
11
+ "sol-57d087fd8c460f612f8701f5499ad8b2eec5ab68.omft.near": _omni_bridge_core.ChainKind.Sol,
12
+ "sol-c58e6539c2f2e097c251f8edf11f9c03e581f8d4.omft.near": _omni_bridge_core.ChainKind.Sol,
13
+ "sol-b9c68f94ec8fd160137af8cdfe5e61cd68e2afba.omft.near": _omni_bridge_core.ChainKind.Sol
14
14
  };
15
15
 
16
16
  //#endregion
@@ -1,4 +1,4 @@
1
- import { ChainKind } from "omni-bridge-sdk";
1
+ import { ChainKind } from "@omni-bridge/core";
2
2
 
3
3
  //#region src/constants/poa-tokens-routable-through-omni-bridge.d.ts
4
4
 
@@ -1,4 +1,4 @@
1
- import { ChainKind } from "omni-bridge-sdk";
1
+ import { ChainKind } from "@omni-bridge/core";
2
2
 
3
3
  //#region src/constants/poa-tokens-routable-through-omni-bridge.d.ts
4
4
 
@@ -1,4 +1,4 @@
1
- import { ChainKind } from "omni-bridge-sdk";
1
+ import { ChainKind } from "@omni-bridge/core";
2
2
 
3
3
  //#region src/constants/poa-tokens-routable-through-omni-bridge.ts
4
4
  /**
@@ -1,11 +1,10 @@
1
- import { IIntentSigner } from "../interfaces/intent-signer.cjs";
2
- import { IntentSignerNEP413Config } from "./intent-signer-nep413.cjs";
3
- import { IntentSignerNearKeypairConfig } from "./intent-signer-near-keypair.cjs";
4
- import { IntentSignerViemConfig } from "./intent-signer-viem.cjs";
1
+ import { IntentSignerNEP413, IntentSignerNEP413Config } from "./intent-signer-nep413.cjs";
2
+ import { IntentSignerNearKeypair, IntentSignerNearKeypairConfig } from "./intent-signer-near-keypair.cjs";
3
+ import { IntentSignerViem, IntentSignerViemConfig } from "./intent-signer-viem.cjs";
5
4
 
6
5
  //#region src/intents/intent-signer-impl/factories.d.ts
7
- declare function createIntentSignerNEP413(config: IntentSignerNEP413Config): IIntentSigner;
8
- declare function createIntentSignerNearKeyPair(config: IntentSignerNearKeypairConfig): IIntentSigner;
9
- declare function createIntentSignerViem(config: IntentSignerViemConfig): IIntentSigner;
6
+ declare function createIntentSignerNEP413(config: IntentSignerNEP413Config): IntentSignerNEP413;
7
+ declare function createIntentSignerNearKeyPair(config: IntentSignerNearKeypairConfig): IntentSignerNearKeypair;
8
+ declare function createIntentSignerViem(config: IntentSignerViemConfig): IntentSignerViem;
10
9
  //#endregion
11
10
  export { createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem };
@@ -1,11 +1,10 @@
1
- import { IIntentSigner } from "../interfaces/intent-signer.js";
2
- import { IntentSignerNEP413Config } from "./intent-signer-nep413.js";
3
- import { IntentSignerNearKeypairConfig } from "./intent-signer-near-keypair.js";
4
- import { IntentSignerViemConfig } from "./intent-signer-viem.js";
1
+ import { IntentSignerNEP413, IntentSignerNEP413Config } from "./intent-signer-nep413.js";
2
+ import { IntentSignerNearKeypair, IntentSignerNearKeypairConfig } from "./intent-signer-near-keypair.js";
3
+ import { IntentSignerViem, IntentSignerViemConfig } from "./intent-signer-viem.js";
5
4
 
6
5
  //#region src/intents/intent-signer-impl/factories.d.ts
7
- declare function createIntentSignerNEP413(config: IntentSignerNEP413Config): IIntentSigner;
8
- declare function createIntentSignerNearKeyPair(config: IntentSignerNearKeypairConfig): IIntentSigner;
9
- declare function createIntentSignerViem(config: IntentSignerViemConfig): IIntentSigner;
6
+ declare function createIntentSignerNEP413(config: IntentSignerNEP413Config): IntentSignerNEP413;
7
+ declare function createIntentSignerNearKeyPair(config: IntentSignerNearKeypairConfig): IntentSignerNearKeypair;
8
+ declare function createIntentSignerViem(config: IntentSignerViemConfig): IntentSignerViem;
10
9
  //#endregion
11
10
  export { createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem };
@@ -1,3 +1,5 @@
1
+ import { IIntentSigner } from "../interfaces/intent-signer.cjs";
2
+ import { IntentSignerNEP413 } from "./intent-signer-nep413.cjs";
1
3
  import * as near_api_js0 from "near-api-js";
2
4
 
3
5
  //#region src/intents/intent-signer-impl/intent-signer-near-keypair.d.ts
@@ -11,5 +13,11 @@ interface IntentSignerNearKeypairConfig {
11
13
  */
12
14
  accountId: string;
13
15
  }
16
+ declare class IntentSignerNearKeypair extends IntentSignerNEP413 implements IIntentSigner {
17
+ constructor({
18
+ signer,
19
+ accountId
20
+ }: IntentSignerNearKeypairConfig);
21
+ }
14
22
  //#endregion
15
- export { IntentSignerNearKeypairConfig };
23
+ export { IntentSignerNearKeypair, IntentSignerNearKeypairConfig };
@@ -1,4 +1,5 @@
1
- import "./intent-signer-nep413.js";
1
+ import { IIntentSigner } from "../interfaces/intent-signer.js";
2
+ import { IntentSignerNEP413 } from "./intent-signer-nep413.js";
2
3
  import * as near_api_js0 from "near-api-js";
3
4
 
4
5
  //#region src/intents/intent-signer-impl/intent-signer-near-keypair.d.ts
@@ -12,5 +13,11 @@ interface IntentSignerNearKeypairConfig {
12
13
  */
13
14
  accountId: string;
14
15
  }
16
+ declare class IntentSignerNearKeypair extends IntentSignerNEP413 implements IIntentSigner {
17
+ constructor({
18
+ signer,
19
+ accountId
20
+ }: IntentSignerNearKeypairConfig);
21
+ }
15
22
  //#endregion
16
- export { IntentSignerNearKeypairConfig };
23
+ export { IntentSignerNearKeypair, IntentSignerNearKeypairConfig };
@@ -5,32 +5,39 @@ let _scure_base = require("@scure/base");
5
5
  //#region src/intents/intent-signer-impl/intent-signer-nep413.ts
6
6
  var IntentSignerNEP413 = class {
7
7
  constructor({ signMessage, accountId }) {
8
- this.signMessage = signMessage;
8
+ this.standard = "nep413";
9
+ this.signMessageFn = signMessage;
9
10
  this.accountId = accountId;
10
11
  }
11
- async signIntent(intent) {
12
+ async signRaw(input) {
12
13
  const nep413Payload = {
13
- recipient: intent.verifying_contract,
14
- nonce: Array.from(_scure_base.base64.decode(intent.nonce)),
15
- message: JSON.stringify({
16
- deadline: intent.deadline,
17
- intents: intent.intents,
18
- signer_id: intent.signer_id ?? this.accountId
19
- })
14
+ message: input.payload.message,
15
+ nonce: Array.from(_scure_base.base64.decode(input.payload.nonce)),
16
+ recipient: input.payload.recipient,
17
+ callback_url: input.payload.callbackUrl
20
18
  };
21
19
  const nep413Hash = await require_nep413.hashNEP413Message(nep413Payload);
22
- const { publicKey, signature } = await this.signMessage(nep413Payload, nep413Hash);
20
+ const { publicKey, signature } = await this.signMessageFn(nep413Payload, nep413Hash);
23
21
  const signatureFormatted = signature.startsWith("ed25519:") ? signature : `ed25519:${_scure_base.base58.encode(_scure_base.base64.decode(signature))}`;
24
22
  return {
25
23
  standard: "nep413",
26
- payload: {
27
- ...nep413Payload,
28
- nonce: intent.nonce
29
- },
24
+ payload: input.payload,
30
25
  public_key: publicKey,
31
26
  signature: signatureFormatted
32
27
  };
33
28
  }
29
+ /** Builds payload from IntentPayload and signs it via signRaw() */
30
+ async signIntent(intent) {
31
+ return this.signRaw({ payload: {
32
+ message: JSON.stringify({
33
+ deadline: intent.deadline,
34
+ intents: intent.intents,
35
+ signer_id: intent.signer_id ?? this.accountId
36
+ }),
37
+ nonce: intent.nonce,
38
+ recipient: intent.verifying_contract
39
+ } });
40
+ }
34
41
  };
35
42
 
36
43
  //#endregion
@@ -1,6 +1,10 @@
1
+ import { IntentPayload } from "../shared-types.cjs";
2
+ import { IIntentSigner } from "../interfaces/intent-signer.cjs";
1
3
  import { NEP413Payload } from "../../lib/nep413.cjs";
4
+ import { MultiPayloadNep413 } from "@defuse-protocol/contract-types";
2
5
 
3
6
  //#region src/intents/intent-signer-impl/intent-signer-nep413.d.ts
7
+ type Nep413RawPayload = Pick<MultiPayloadNep413, "payload">;
4
8
  type MaybePromise<T> = T | Promise<T>;
5
9
  type SignMessageNEP413 = (nep413Payload: NEP413Payload, nep413Hash: Uint8Array) => MaybePromise<{
6
10
  publicKey: string;
@@ -10,5 +14,17 @@ interface IntentSignerNEP413Config {
10
14
  signMessage: SignMessageNEP413;
11
15
  accountId: string;
12
16
  }
17
+ declare class IntentSignerNEP413 implements IIntentSigner {
18
+ readonly standard: "nep413";
19
+ private signMessageFn;
20
+ protected accountId: string;
21
+ constructor({
22
+ signMessage,
23
+ accountId
24
+ }: IntentSignerNEP413Config);
25
+ signRaw(input: Nep413RawPayload): Promise<MultiPayloadNep413>;
26
+ /** Builds payload from IntentPayload and signs it via signRaw() */
27
+ signIntent(intent: IntentPayload): Promise<MultiPayloadNep413>;
28
+ }
13
29
  //#endregion
14
- export { IntentSignerNEP413Config };
30
+ export { IntentSignerNEP413, IntentSignerNEP413Config, Nep413RawPayload };
@@ -1,6 +1,10 @@
1
+ import { IntentPayload } from "../shared-types.js";
2
+ import { IIntentSigner } from "../interfaces/intent-signer.js";
1
3
  import { NEP413Payload } from "../../lib/nep413.js";
4
+ import { MultiPayloadNep413 } from "@defuse-protocol/contract-types";
2
5
 
3
6
  //#region src/intents/intent-signer-impl/intent-signer-nep413.d.ts
7
+ type Nep413RawPayload = Pick<MultiPayloadNep413, "payload">;
4
8
  type MaybePromise<T> = T | Promise<T>;
5
9
  type SignMessageNEP413 = (nep413Payload: NEP413Payload, nep413Hash: Uint8Array) => MaybePromise<{
6
10
  publicKey: string;
@@ -10,5 +14,17 @@ interface IntentSignerNEP413Config {
10
14
  signMessage: SignMessageNEP413;
11
15
  accountId: string;
12
16
  }
17
+ declare class IntentSignerNEP413 implements IIntentSigner {
18
+ readonly standard: "nep413";
19
+ private signMessageFn;
20
+ protected accountId: string;
21
+ constructor({
22
+ signMessage,
23
+ accountId
24
+ }: IntentSignerNEP413Config);
25
+ signRaw(input: Nep413RawPayload): Promise<MultiPayloadNep413>;
26
+ /** Builds payload from IntentPayload and signs it via signRaw() */
27
+ signIntent(intent: IntentPayload): Promise<MultiPayloadNep413>;
28
+ }
13
29
  //#endregion
14
- export { IntentSignerNEP413Config };
30
+ export { IntentSignerNEP413, IntentSignerNEP413Config, Nep413RawPayload };
@@ -4,32 +4,39 @@ import { base58, base64 } from "@scure/base";
4
4
  //#region src/intents/intent-signer-impl/intent-signer-nep413.ts
5
5
  var IntentSignerNEP413 = class {
6
6
  constructor({ signMessage, accountId }) {
7
- this.signMessage = signMessage;
7
+ this.standard = "nep413";
8
+ this.signMessageFn = signMessage;
8
9
  this.accountId = accountId;
9
10
  }
10
- async signIntent(intent) {
11
+ async signRaw(input) {
11
12
  const nep413Payload = {
12
- recipient: intent.verifying_contract,
13
- nonce: Array.from(base64.decode(intent.nonce)),
14
- message: JSON.stringify({
15
- deadline: intent.deadline,
16
- intents: intent.intents,
17
- signer_id: intent.signer_id ?? this.accountId
18
- })
13
+ message: input.payload.message,
14
+ nonce: Array.from(base64.decode(input.payload.nonce)),
15
+ recipient: input.payload.recipient,
16
+ callback_url: input.payload.callbackUrl
19
17
  };
20
18
  const nep413Hash = await hashNEP413Message(nep413Payload);
21
- const { publicKey, signature } = await this.signMessage(nep413Payload, nep413Hash);
19
+ const { publicKey, signature } = await this.signMessageFn(nep413Payload, nep413Hash);
22
20
  const signatureFormatted = signature.startsWith("ed25519:") ? signature : `ed25519:${base58.encode(base64.decode(signature))}`;
23
21
  return {
24
22
  standard: "nep413",
25
- payload: {
26
- ...nep413Payload,
27
- nonce: intent.nonce
28
- },
23
+ payload: input.payload,
29
24
  public_key: publicKey,
30
25
  signature: signatureFormatted
31
26
  };
32
27
  }
28
+ /** Builds payload from IntentPayload and signs it via signRaw() */
29
+ async signIntent(intent) {
30
+ return this.signRaw({ payload: {
31
+ message: JSON.stringify({
32
+ deadline: intent.deadline,
33
+ intents: intent.intents,
34
+ signer_id: intent.signer_id ?? this.accountId
35
+ }),
36
+ nonce: intent.nonce,
37
+ recipient: intent.verifying_contract
38
+ } });
39
+ }
33
40
  };
34
41
 
35
42
  //#endregion
@@ -5,9 +5,20 @@ let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils")
5
5
  var IntentSignerViem = class {
6
6
  constructor(config) {
7
7
  this.config = config;
8
+ this.standard = "erc191";
8
9
  }
10
+ async signRaw(input) {
11
+ const signature = await this.config.signer.signMessage?.({ message: input.payload });
12
+ if (signature == null) throw new Error("No signature is returned");
13
+ return {
14
+ standard: "erc191",
15
+ payload: input.payload,
16
+ signature: _defuse_protocol_internal_utils.utils.transformERC191Signature(signature)
17
+ };
18
+ }
19
+ /** Builds payload from IntentPayload and signs it via signRaw() */
9
20
  async signIntent(intent) {
10
- const payload = JSON.stringify({
21
+ return this.signRaw({ payload: JSON.stringify({
11
22
  signer_id: intent.signer_id ?? this.config.accountId ?? _defuse_protocol_internal_utils.utils.authHandleToIntentsUserId({
12
23
  identifier: this.config.signer.address,
13
24
  method: "evm"
@@ -16,14 +27,7 @@ var IntentSignerViem = class {
16
27
  deadline: intent.deadline,
17
28
  nonce: intent.nonce,
18
29
  intents: intent.intents
19
- });
20
- const signature = await this.config.signer.signMessage?.({ message: payload });
21
- if (signature == null) throw new Error("No signature is returned");
22
- return {
23
- standard: "erc191",
24
- payload,
25
- signature: _defuse_protocol_internal_utils.utils.transformERC191Signature(signature)
26
- };
30
+ }) });
27
31
  }
28
32
  };
29
33
 
@@ -1,6 +1,10 @@
1
+ import { IntentPayload } from "../shared-types.cjs";
2
+ import { IIntentSigner } from "../interfaces/intent-signer.cjs";
3
+ import { MultiPayloadErc191 } from "@defuse-protocol/contract-types";
1
4
  import { Account } from "viem";
2
5
 
3
6
  //#region src/intents/intent-signer-impl/intent-signer-viem.d.ts
7
+ type Erc191RawPayload = Pick<MultiPayloadErc191, "payload">;
4
8
  type IntentSignerViemConfig = {
5
9
  /**
6
10
  * Instance of viem's Account type
@@ -13,5 +17,13 @@ type IntentSignerViemConfig = {
13
17
  */
14
18
  accountId?: string;
15
19
  };
20
+ declare class IntentSignerViem implements IIntentSigner {
21
+ private config;
22
+ readonly standard: "erc191";
23
+ constructor(config: IntentSignerViemConfig);
24
+ signRaw(input: Erc191RawPayload): Promise<MultiPayloadErc191>;
25
+ /** Builds payload from IntentPayload and signs it via signRaw() */
26
+ signIntent(intent: IntentPayload): Promise<MultiPayloadErc191>;
27
+ }
16
28
  //#endregion
17
- export { IntentSignerViemConfig };
29
+ export { Erc191RawPayload, IntentSignerViem, IntentSignerViemConfig };
@@ -1,6 +1,10 @@
1
+ import { IntentPayload } from "../shared-types.js";
2
+ import { IIntentSigner } from "../interfaces/intent-signer.js";
1
3
  import { Account } from "viem";
4
+ import { MultiPayloadErc191 } from "@defuse-protocol/contract-types";
2
5
 
3
6
  //#region src/intents/intent-signer-impl/intent-signer-viem.d.ts
7
+ type Erc191RawPayload = Pick<MultiPayloadErc191, "payload">;
4
8
  type IntentSignerViemConfig = {
5
9
  /**
6
10
  * Instance of viem's Account type
@@ -13,5 +17,13 @@ type IntentSignerViemConfig = {
13
17
  */
14
18
  accountId?: string;
15
19
  };
20
+ declare class IntentSignerViem implements IIntentSigner {
21
+ private config;
22
+ readonly standard: "erc191";
23
+ constructor(config: IntentSignerViemConfig);
24
+ signRaw(input: Erc191RawPayload): Promise<MultiPayloadErc191>;
25
+ /** Builds payload from IntentPayload and signs it via signRaw() */
26
+ signIntent(intent: IntentPayload): Promise<MultiPayloadErc191>;
27
+ }
16
28
  //#endregion
17
- export { IntentSignerViemConfig };
29
+ export { Erc191RawPayload, IntentSignerViem, IntentSignerViemConfig };
@@ -4,9 +4,20 @@ import { utils } from "@defuse-protocol/internal-utils";
4
4
  var IntentSignerViem = class {
5
5
  constructor(config) {
6
6
  this.config = config;
7
+ this.standard = "erc191";
7
8
  }
9
+ async signRaw(input) {
10
+ const signature = await this.config.signer.signMessage?.({ message: input.payload });
11
+ if (signature == null) throw new Error("No signature is returned");
12
+ return {
13
+ standard: "erc191",
14
+ payload: input.payload,
15
+ signature: utils.transformERC191Signature(signature)
16
+ };
17
+ }
18
+ /** Builds payload from IntentPayload and signs it via signRaw() */
8
19
  async signIntent(intent) {
9
- const payload = JSON.stringify({
20
+ return this.signRaw({ payload: JSON.stringify({
10
21
  signer_id: intent.signer_id ?? this.config.accountId ?? utils.authHandleToIntentsUserId({
11
22
  identifier: this.config.signer.address,
12
23
  method: "evm"
@@ -15,14 +26,7 @@ var IntentSignerViem = class {
15
26
  deadline: intent.deadline,
16
27
  nonce: intent.nonce,
17
28
  intents: intent.intents
18
- });
19
- const signature = await this.config.signer.signMessage?.({ message: payload });
20
- if (signature == null) throw new Error("No signature is returned");
21
- return {
22
- standard: "erc191",
23
- payload,
24
- signature: utils.transformERC191Signature(signature)
25
- };
29
+ }) });
26
30
  }
27
31
  };
28
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defuse-protocol/intents-sdk",
3
- "version": "0.49.0",
3
+ "version": "0.51.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "repository": {
@@ -34,16 +34,14 @@
34
34
  "@hot-labs/omni-sdk": "2.24.7",
35
35
  "@isaacs/ttlcache": "^1.0.0",
36
36
  "@lifeomic/attempt": "^3.0.0",
37
- "@near-js/accounts": "^2.0.1",
38
- "@near-js/client": "^2.0.1",
39
- "@near-js/keystores": "^2.0.1",
37
+ "@omni-bridge/core": "0.2.3",
38
+ "@omni-bridge/near": "0.2.3",
40
39
  "@noble/hashes": "^1.7.1",
41
40
  "@scure/base": "^1.0.0",
42
41
  "@solana/web3.js": "^1.0.0",
43
42
  "borsher": "^4.0.0",
44
43
  "lru-cache": "^11",
45
44
  "near-api-js": "^4.0.0 || ^5.0.0",
46
- "omni-bridge-sdk": "0.23.1",
47
45
  "ripple-address-codec": "^5.0.0",
48
46
  "valibot": "^1.0.0",
49
47
  "viem": "^2.0.0",