@defuse-protocol/intents-sdk 0.47.0 → 0.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -18,5 +18,5 @@ import { HotWithdrawalApiFeeRequestTimeoutError, HotWithdrawalApiFeeRequestTimeo
18
18
  import { InsufficientUtxoForOmniBridgeWithdrawalError, InsufficientUtxoForOmniBridgeWithdrawalErrorType, IntentsNearOmniAvailableBalanceTooLowError, IntentsNearOmniAvailableBalanceTooLowErrorType, InvalidFeeValueError, InvalidFeeValueErrorType, OmniWithdrawalApiFeeRequestTimeoutError, OmniWithdrawalApiFeeRequestTimeoutErrorType, TokenNotFoundInDestinationChainError, TokenNotFoundInDestinationChainErrorType } from "./src/bridges/omni-bridge/error.cjs";
19
19
  import { computeIntentHash } from "./src/intents/intent-hash.cjs";
20
20
  import { validateAddress } from "./src/lib/validateAddress.cjs";
21
- import { AssertionError, AssertionErrorType, BaseError, BaseErrorType, EnvConfig, HttpRequestError, HttpRequestErrorType, ILogger, IntentSettlementError, IntentSettlementErrorType, NearIntentsEnv, PoaWithdrawalInvariantError, PoaWithdrawalInvariantErrorType, PoaWithdrawalNotFoundError, PoaWithdrawalNotFoundErrorType, PoaWithdrawalPendingError, PoaWithdrawalPendingErrorType, QuoteError, QuoteErrorType, RelayPublishError, RelayPublishErrorType, RetryOptions, 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, 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 };
21
+ 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 };
package/dist/index.d.ts CHANGED
@@ -18,5 +18,5 @@ import { HotWithdrawalApiFeeRequestTimeoutError, HotWithdrawalApiFeeRequestTimeo
18
18
  import { InsufficientUtxoForOmniBridgeWithdrawalError, InsufficientUtxoForOmniBridgeWithdrawalErrorType, IntentsNearOmniAvailableBalanceTooLowError, IntentsNearOmniAvailableBalanceTooLowErrorType, InvalidFeeValueError, InvalidFeeValueErrorType, OmniWithdrawalApiFeeRequestTimeoutError, OmniWithdrawalApiFeeRequestTimeoutErrorType, TokenNotFoundInDestinationChainError, TokenNotFoundInDestinationChainErrorType } from "./src/bridges/omni-bridge/error.js";
19
19
  import { computeIntentHash } from "./src/intents/intent-hash.js";
20
20
  import { validateAddress } from "./src/lib/validateAddress.js";
21
- import { AssertionError, AssertionErrorType, BaseError, BaseErrorType, EnvConfig, HttpRequestError, HttpRequestErrorType, ILogger, IntentSettlementError, IntentSettlementErrorType, NearIntentsEnv, PoaWithdrawalInvariantError, PoaWithdrawalInvariantErrorType, PoaWithdrawalNotFoundError, PoaWithdrawalNotFoundErrorType, PoaWithdrawalPendingError, PoaWithdrawalPendingErrorType, QuoteError, QuoteErrorType, RelayPublishError, RelayPublishErrorType, RetryOptions, 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, 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 };
21
+ 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 };
@@ -22,7 +22,8 @@ var IntentsBridge = class {
22
22
  const intents = [{
23
23
  intent: "transfer",
24
24
  receiver_id: args.withdrawalParams.destinationAddress,
25
- tokens: { [args.withdrawalParams.assetId]: args.withdrawalParams.amount.toString() }
25
+ tokens: { [args.withdrawalParams.assetId]: args.withdrawalParams.amount.toString() },
26
+ memo: args.withdrawalParams.destinationMemo
26
27
  }];
27
28
  return Promise.resolve(intents);
28
29
  }
@@ -22,7 +22,8 @@ var IntentsBridge = class {
22
22
  const intents = [{
23
23
  intent: "transfer",
24
24
  receiver_id: args.withdrawalParams.destinationAddress,
25
- tokens: { [args.withdrawalParams.assetId]: args.withdrawalParams.amount.toString() }
25
+ tokens: { [args.withdrawalParams.assetId]: args.withdrawalParams.amount.toString() },
26
+ memo: args.withdrawalParams.destinationMemo
26
27
  }];
27
28
  return Promise.resolve(intents);
28
29
  }
@@ -53,14 +53,22 @@ const SALTED_NONCE_BORSH_SCHEMA = { struct: {
53
53
  } };
54
54
  let VersionedNonceBuilder;
55
55
  (function(_VersionedNonceBuilder) {
56
- function encodeNonce(salt, deadline) {
56
+ const RANDOM_BYTES_LENGTH = 15;
57
+ function createTimestampedNonceBytes(startTime) {
58
+ const bytes = new Uint8Array(RANDOM_BYTES_LENGTH);
59
+ new DataView(bytes.buffer).setBigInt64(0, BigInt(startTime.getTime()) * 1000000n, true);
60
+ crypto.getRandomValues(bytes.subarray(8));
61
+ return bytes;
62
+ }
63
+ _VersionedNonceBuilder.createTimestampedNonceBytes = createTimestampedNonceBytes;
64
+ function encodeNonce(salt, deadline, randomBytes = crypto.getRandomValues(new Uint8Array(RANDOM_BYTES_LENGTH))) {
57
65
  if (salt.length !== 4) throw new Error(`Invalid salt length: ${salt.length}, expected 4`);
66
+ if (randomBytes.length !== RANDOM_BYTES_LENGTH) throw new Error(`Invalid randomBytes length: ${randomBytes.length}, expected ${RANDOM_BYTES_LENGTH}`);
58
67
  const deadlineBigInt = BigInt(deadline.getTime()) * 1000000n;
59
- const nonceBytes = crypto.getRandomValues(new Uint8Array(15));
60
68
  const borshBytes = new Uint8Array(27);
61
69
  borshBytes.set(salt, 0);
62
70
  new DataView(borshBytes.buffer, borshBytes.byteOffset, borshBytes.byteLength).setBigUint64(4, deadlineBigInt, true);
63
- borshBytes.set(nonceBytes, 12);
71
+ borshBytes.set(randomBytes, 12);
64
72
  const result = new Uint8Array(5 + borshBytes.length);
65
73
  result.set(VERSIONED_MAGIC_PREFIX, 0);
66
74
  result.set([LATEST_VERSION], 4);
@@ -24,14 +24,23 @@ declare class VersionedNonce {
24
24
  static latest(saltedNonce: SaltedNonce): VersionedNonce;
25
25
  }
26
26
  declare namespace VersionedNonceBuilder {
27
+ /**
28
+ * Creates nonce bytes with embedded start timestamp.
29
+ * Layout: [startTime: 8 bytes LE nanoseconds] [random: 7 bytes]
30
+ *
31
+ * @param startTime The start time to embed in the nonce
32
+ * @returns 15-byte Uint8Array with timestamp and random data
33
+ */
34
+ function createTimestampedNonceBytes(startTime: Date): Uint8Array;
27
35
  /**
28
36
  * Encodes a versioned expirable nonce with the given salt and deadline
29
37
  *
30
38
  * @param salt The salt to use for the nonce
31
39
  * @param deadline The expiration deadline for the nonce
40
+ * @param randomBytes Optional random bytes to use. If not provided, random bytes will be generated.
32
41
  * @returns The encoded nonce as a base64 string
33
42
  */
34
- function encodeNonce(salt: Salt, deadline: Date): string;
43
+ function encodeNonce(salt: Salt, deadline: Date, randomBytes?: Uint8Array<ArrayBufferLike>): string;
35
44
  /**
36
45
  * Decodes a versioned expirable nonce from a base64-encoded string
37
46
  *
@@ -1,4 +1,5 @@
1
1
  import "valibot";
2
+ import "near-api-js/lib/utils/serialize";
2
3
 
3
4
  //#region src/intents/expirable-nonce.d.ts
4
5
  type Salt = Uint8Array;
@@ -25,14 +26,23 @@ declare class VersionedNonce {
25
26
  static latest(saltedNonce: SaltedNonce): VersionedNonce;
26
27
  }
27
28
  declare namespace VersionedNonceBuilder {
29
+ /**
30
+ * Creates nonce bytes with embedded start timestamp.
31
+ * Layout: [startTime: 8 bytes LE nanoseconds] [random: 7 bytes]
32
+ *
33
+ * @param startTime The start time to embed in the nonce
34
+ * @returns 15-byte Uint8Array with timestamp and random data
35
+ */
36
+ function createTimestampedNonceBytes(startTime: Date): Uint8Array;
28
37
  /**
29
38
  * Encodes a versioned expirable nonce with the given salt and deadline
30
39
  *
31
40
  * @param salt The salt to use for the nonce
32
41
  * @param deadline The expiration deadline for the nonce
42
+ * @param randomBytes Optional random bytes to use. If not provided, random bytes will be generated.
33
43
  * @returns The encoded nonce as a base64 string
34
44
  */
35
- function encodeNonce(salt: Salt, deadline: Date): string;
45
+ function encodeNonce(salt: Salt, deadline: Date, randomBytes?: Uint8Array<ArrayBufferLike>): string;
36
46
  /**
37
47
  * Decodes a versioned expirable nonce from a base64-encoded string
38
48
  *
@@ -51,14 +51,22 @@ const SALTED_NONCE_BORSH_SCHEMA = { struct: {
51
51
  } };
52
52
  let VersionedNonceBuilder;
53
53
  (function(_VersionedNonceBuilder) {
54
- function encodeNonce(salt, deadline) {
54
+ const RANDOM_BYTES_LENGTH = 15;
55
+ function createTimestampedNonceBytes(startTime) {
56
+ const bytes = new Uint8Array(RANDOM_BYTES_LENGTH);
57
+ new DataView(bytes.buffer).setBigInt64(0, BigInt(startTime.getTime()) * 1000000n, true);
58
+ crypto.getRandomValues(bytes.subarray(8));
59
+ return bytes;
60
+ }
61
+ _VersionedNonceBuilder.createTimestampedNonceBytes = createTimestampedNonceBytes;
62
+ function encodeNonce(salt, deadline, randomBytes = crypto.getRandomValues(new Uint8Array(RANDOM_BYTES_LENGTH))) {
55
63
  if (salt.length !== 4) throw new Error(`Invalid salt length: ${salt.length}, expected 4`);
64
+ if (randomBytes.length !== RANDOM_BYTES_LENGTH) throw new Error(`Invalid randomBytes length: ${randomBytes.length}, expected ${RANDOM_BYTES_LENGTH}`);
56
65
  const deadlineBigInt = BigInt(deadline.getTime()) * 1000000n;
57
- const nonceBytes = crypto.getRandomValues(new Uint8Array(15));
58
66
  const borshBytes = new Uint8Array(27);
59
67
  borshBytes.set(salt, 0);
60
68
  new DataView(borshBytes.buffer, borshBytes.byteOffset, borshBytes.byteLength).setBigUint64(4, deadlineBigInt, true);
61
- borshBytes.set(nonceBytes, 12);
69
+ borshBytes.set(randomBytes, 12);
62
70
  const result = new Uint8Array(5 + borshBytes.length);
63
71
  result.set(VERSIONED_MAGIC_PREFIX, 0);
64
72
  result.set([LATEST_VERSION], 4);
@@ -52,8 +52,6 @@ function parseTonAddress(addressString) {
52
52
  * payload
53
53
  * )
54
54
  *
55
- * For cell payloads: Uses TON TLB message serialization (not fully implemented here)
56
- *
57
55
  * @param payload - The TON Connect payload to hash
58
56
  * @returns 32-byte hash as Uint8Array
59
57
  */
@@ -86,8 +84,6 @@ function computeTonConnectHash(payload) {
86
84
  }
87
85
  return (0, _noble_hashes_sha2.sha256)(message);
88
86
  }
89
- case "binary": throw new Error("Binary payload hashing is not yet supported");
90
- case "cell": throw new Error("Cell payload hashing is not yet supported.");
91
87
  default: throw new Error(`Unknown TON Connect payload type: ${schemaType}`);
92
88
  }
93
89
  }
@@ -51,8 +51,6 @@ function parseTonAddress(addressString) {
51
51
  * payload
52
52
  * )
53
53
  *
54
- * For cell payloads: Uses TON TLB message serialization (not fully implemented here)
55
- *
56
54
  * @param payload - The TON Connect payload to hash
57
55
  * @returns 32-byte hash as Uint8Array
58
56
  */
@@ -85,8 +83,6 @@ function computeTonConnectHash(payload) {
85
83
  }
86
84
  return sha256(message);
87
85
  }
88
- case "binary": throw new Error("Binary payload hashing is not yet supported");
89
- case "cell": throw new Error("Cell payload hashing is not yet supported.");
90
86
  default: throw new Error(`Unknown TON Connect payload type: ${schemaType}`);
91
87
  }
92
88
  }
@@ -92,8 +92,12 @@ var IntentPayloadBuilder = class IntentPayloadBuilder {
92
92
  return this;
93
93
  }
94
94
  /**
95
- * Set a custom nonce. If not provided, a nonce will be automatically generated.
96
- * The nonce must be a valid versioned nonce format.
95
+ * Set a pre-built nonce directly.
96
+ * Use this when you have a complete nonce from an external source
97
+ * or need to reuse/invalidate a specific nonce.
98
+ *
99
+ * For most cases where you need custom random bytes, use {@link setNonceRandomBytes} instead,
100
+ * which handles salt fetching and nonce encoding automatically.
97
101
  *
98
102
  * @param nonce - Custom nonce string (base64 encoded)
99
103
  * @returns The builder instance for chaining
@@ -103,6 +107,23 @@ var IntentPayloadBuilder = class IntentPayloadBuilder {
103
107
  return this;
104
108
  }
105
109
  /**
110
+ * Set custom random bytes for nonce generation.
111
+ * The nonce will be automatically created at build time using these bytes,
112
+ * the deadline, and the contract salt.
113
+ *
114
+ * Use this when you need control over the random portion of the nonce
115
+ * (e.g., embedding a start timestamp via {@link VersionedNonceBuilder.createTimestampedNonceBytes}).
116
+ *
117
+ * For pre-built nonces, use {@link setNonce} instead.
118
+ *
119
+ * @param randomBytes - 15 bytes to use as the random portion of the nonce
120
+ * @returns The builder instance for chaining
121
+ */
122
+ setNonceRandomBytes(randomBytes) {
123
+ this.customRandomBytes = randomBytes;
124
+ return this;
125
+ }
126
+ /**
106
127
  * Clear all intents from the builder.
107
128
  *
108
129
  * @returns The builder instance for chaining
@@ -122,6 +143,7 @@ var IntentPayloadBuilder = class IntentPayloadBuilder {
122
143
  this.deadline = void 0;
123
144
  this.intents = [];
124
145
  this.customNonce = void 0;
146
+ this.customRandomBytes = void 0;
125
147
  this.verifyingContract = this.envConfig.contractID;
126
148
  return this;
127
149
  }
@@ -134,8 +156,7 @@ var IntentPayloadBuilder = class IntentPayloadBuilder {
134
156
  */
135
157
  buildWithSalt(salt) {
136
158
  const deadline = this.deadline ?? new Date(Date.now() + require_intent_payload_factory.DEFAULT_DEADLINE_MS);
137
- const nonceDeadline = new Date(deadline.getTime() + require_intent_payload_factory.DEFAULT_NONCE_DEADLINE_OFFSET_MS);
138
- const nonce = this.customNonce ?? require_expirable_nonce.VersionedNonceBuilder.encodeNonce(salt, nonceDeadline);
159
+ const nonce = this.customNonce ?? require_expirable_nonce.VersionedNonceBuilder.encodeNonce(salt, deadline, this.customRandomBytes);
139
160
  return {
140
161
  verifying_contract: this.verifyingContract,
141
162
  signer_id: this.signerId,
@@ -184,6 +205,7 @@ var IntentPayloadBuilder = class IntentPayloadBuilder {
184
205
  builder.deadline = this.deadline;
185
206
  builder.intents = [...this.intents];
186
207
  builder.customNonce = this.customNonce;
208
+ builder.customRandomBytes = this.customRandomBytes;
187
209
  return builder;
188
210
  }
189
211
  /**
@@ -47,6 +47,7 @@ declare class IntentPayloadBuilder<HasSigner extends boolean = false> {
47
47
  private deadline?;
48
48
  private intents;
49
49
  private customNonce?;
50
+ private customRandomBytes?;
50
51
  constructor(config: IntentPayloadBuilderConfig);
51
52
  /**
52
53
  * Set the signer ID (address or account that will sign the intent).
@@ -89,13 +90,31 @@ declare class IntentPayloadBuilder<HasSigner extends boolean = false> {
89
90
  */
90
91
  setVerifyingContract(contractAddress: string): this;
91
92
  /**
92
- * Set a custom nonce. If not provided, a nonce will be automatically generated.
93
- * The nonce must be a valid versioned nonce format.
93
+ * Set a pre-built nonce directly.
94
+ * Use this when you have a complete nonce from an external source
95
+ * or need to reuse/invalidate a specific nonce.
96
+ *
97
+ * For most cases where you need custom random bytes, use {@link setNonceRandomBytes} instead,
98
+ * which handles salt fetching and nonce encoding automatically.
94
99
  *
95
100
  * @param nonce - Custom nonce string (base64 encoded)
96
101
  * @returns The builder instance for chaining
97
102
  */
98
103
  setNonce(nonce: string): this;
104
+ /**
105
+ * Set custom random bytes for nonce generation.
106
+ * The nonce will be automatically created at build time using these bytes,
107
+ * the deadline, and the contract salt.
108
+ *
109
+ * Use this when you need control over the random portion of the nonce
110
+ * (e.g., embedding a start timestamp via {@link VersionedNonceBuilder.createTimestampedNonceBytes}).
111
+ *
112
+ * For pre-built nonces, use {@link setNonce} instead.
113
+ *
114
+ * @param randomBytes - 15 bytes to use as the random portion of the nonce
115
+ * @returns The builder instance for chaining
116
+ */
117
+ setNonceRandomBytes(randomBytes: Uint8Array<ArrayBufferLike>): this;
99
118
  /**
100
119
  * Clear all intents from the builder.
101
120
  *
@@ -47,6 +47,7 @@ declare class IntentPayloadBuilder<HasSigner extends boolean = false> {
47
47
  private deadline?;
48
48
  private intents;
49
49
  private customNonce?;
50
+ private customRandomBytes?;
50
51
  constructor(config: IntentPayloadBuilderConfig);
51
52
  /**
52
53
  * Set the signer ID (address or account that will sign the intent).
@@ -89,13 +90,31 @@ declare class IntentPayloadBuilder<HasSigner extends boolean = false> {
89
90
  */
90
91
  setVerifyingContract(contractAddress: string): this;
91
92
  /**
92
- * Set a custom nonce. If not provided, a nonce will be automatically generated.
93
- * The nonce must be a valid versioned nonce format.
93
+ * Set a pre-built nonce directly.
94
+ * Use this when you have a complete nonce from an external source
95
+ * or need to reuse/invalidate a specific nonce.
96
+ *
97
+ * For most cases where you need custom random bytes, use {@link setNonceRandomBytes} instead,
98
+ * which handles salt fetching and nonce encoding automatically.
94
99
  *
95
100
  * @param nonce - Custom nonce string (base64 encoded)
96
101
  * @returns The builder instance for chaining
97
102
  */
98
103
  setNonce(nonce: string): this;
104
+ /**
105
+ * Set custom random bytes for nonce generation.
106
+ * The nonce will be automatically created at build time using these bytes,
107
+ * the deadline, and the contract salt.
108
+ *
109
+ * Use this when you need control over the random portion of the nonce
110
+ * (e.g., embedding a start timestamp via {@link VersionedNonceBuilder.createTimestampedNonceBytes}).
111
+ *
112
+ * For pre-built nonces, use {@link setNonce} instead.
113
+ *
114
+ * @param randomBytes - 15 bytes to use as the random portion of the nonce
115
+ * @returns The builder instance for chaining
116
+ */
117
+ setNonceRandomBytes(randomBytes: Uint8Array<ArrayBufferLike>): this;
99
118
  /**
100
119
  * Clear all intents from the builder.
101
120
  *
@@ -1,5 +1,5 @@
1
1
  import { VersionedNonceBuilder } from "./expirable-nonce.js";
2
- import { DEFAULT_DEADLINE_MS, DEFAULT_NONCE_DEADLINE_OFFSET_MS } from "./intent-payload-factory.js";
2
+ import { DEFAULT_DEADLINE_MS } from "./intent-payload-factory.js";
3
3
  import { utils } from "@defuse-protocol/internal-utils";
4
4
 
5
5
  //#region src/intents/intent-payload-builder.ts
@@ -91,8 +91,12 @@ var IntentPayloadBuilder = class IntentPayloadBuilder {
91
91
  return this;
92
92
  }
93
93
  /**
94
- * Set a custom nonce. If not provided, a nonce will be automatically generated.
95
- * The nonce must be a valid versioned nonce format.
94
+ * Set a pre-built nonce directly.
95
+ * Use this when you have a complete nonce from an external source
96
+ * or need to reuse/invalidate a specific nonce.
97
+ *
98
+ * For most cases where you need custom random bytes, use {@link setNonceRandomBytes} instead,
99
+ * which handles salt fetching and nonce encoding automatically.
96
100
  *
97
101
  * @param nonce - Custom nonce string (base64 encoded)
98
102
  * @returns The builder instance for chaining
@@ -102,6 +106,23 @@ var IntentPayloadBuilder = class IntentPayloadBuilder {
102
106
  return this;
103
107
  }
104
108
  /**
109
+ * Set custom random bytes for nonce generation.
110
+ * The nonce will be automatically created at build time using these bytes,
111
+ * the deadline, and the contract salt.
112
+ *
113
+ * Use this when you need control over the random portion of the nonce
114
+ * (e.g., embedding a start timestamp via {@link VersionedNonceBuilder.createTimestampedNonceBytes}).
115
+ *
116
+ * For pre-built nonces, use {@link setNonce} instead.
117
+ *
118
+ * @param randomBytes - 15 bytes to use as the random portion of the nonce
119
+ * @returns The builder instance for chaining
120
+ */
121
+ setNonceRandomBytes(randomBytes) {
122
+ this.customRandomBytes = randomBytes;
123
+ return this;
124
+ }
125
+ /**
105
126
  * Clear all intents from the builder.
106
127
  *
107
128
  * @returns The builder instance for chaining
@@ -121,6 +142,7 @@ var IntentPayloadBuilder = class IntentPayloadBuilder {
121
142
  this.deadline = void 0;
122
143
  this.intents = [];
123
144
  this.customNonce = void 0;
145
+ this.customRandomBytes = void 0;
124
146
  this.verifyingContract = this.envConfig.contractID;
125
147
  return this;
126
148
  }
@@ -133,8 +155,7 @@ var IntentPayloadBuilder = class IntentPayloadBuilder {
133
155
  */
134
156
  buildWithSalt(salt) {
135
157
  const deadline = this.deadline ?? new Date(Date.now() + DEFAULT_DEADLINE_MS);
136
- const nonceDeadline = new Date(deadline.getTime() + DEFAULT_NONCE_DEADLINE_OFFSET_MS);
137
- const nonce = this.customNonce ?? VersionedNonceBuilder.encodeNonce(salt, nonceDeadline);
158
+ const nonce = this.customNonce ?? VersionedNonceBuilder.encodeNonce(salt, deadline, this.customRandomBytes);
138
159
  return {
139
160
  verifying_contract: this.verifyingContract,
140
161
  signer_id: this.signerId,
@@ -183,6 +204,7 @@ var IntentPayloadBuilder = class IntentPayloadBuilder {
183
204
  builder.deadline = this.deadline;
184
205
  builder.intents = [...this.intents];
185
206
  builder.customNonce = this.customNonce;
207
+ builder.customRandomBytes = this.customRandomBytes;
186
208
  return builder;
187
209
  }
188
210
  /**
@@ -19,5 +19,4 @@ function defaultIntentPayloadFactory(salt, { intents, verifying_contract, ...par
19
19
 
20
20
  //#endregion
21
21
  exports.DEFAULT_DEADLINE_MS = DEFAULT_DEADLINE_MS;
22
- exports.DEFAULT_NONCE_DEADLINE_OFFSET_MS = DEFAULT_NONCE_DEADLINE_OFFSET_MS;
23
22
  exports.defaultIntentPayloadFactory = defaultIntentPayloadFactory;
@@ -18,4 +18,4 @@ function defaultIntentPayloadFactory(salt, { intents, verifying_contract, ...par
18
18
  }
19
19
 
20
20
  //#endregion
21
- export { DEFAULT_DEADLINE_MS, DEFAULT_NONCE_DEADLINE_OFFSET_MS, defaultIntentPayloadFactory };
21
+ export { DEFAULT_DEADLINE_MS, defaultIntentPayloadFactory };
@@ -6,6 +6,25 @@ valibot = require_rolldown_runtime.__toESM(valibot);
6
6
 
7
7
  //#region src/intents/salt-manager.ts
8
8
  const SALT_TTL_MS = 300 * 1e3;
9
+ /**
10
+ * Salt manager that returns a static, pre-configured salt.
11
+ * Use when salt is known ahead of time (e.g., private blockchain with fixed salt).
12
+ */
13
+ var StaticSaltManager = class {
14
+ /**
15
+ * @param saltHex Salt as hex string (e.g., "01020304")
16
+ */
17
+ constructor(saltHex) {
18
+ this.salt = _scure_base.hex.decode(saltHex);
19
+ if (this.salt.length !== 4) throw new Error(`Invalid salt length: ${this.salt.length}, expected 4`);
20
+ }
21
+ async getCachedSalt() {
22
+ return this.salt;
23
+ }
24
+ async refresh() {
25
+ return this.salt;
26
+ }
27
+ };
9
28
  var SaltManager = class {
10
29
  constructor({ envConfig, nearProvider }) {
11
30
  this.currentSalt = null;
@@ -71,4 +90,5 @@ async function fetchSalt(nearProvider, contractId) {
71
90
  }
72
91
 
73
92
  //#endregion
74
- exports.SaltManager = SaltManager;
93
+ exports.SaltManager = SaltManager;
94
+ exports.StaticSaltManager = StaticSaltManager;
@@ -4,6 +4,25 @@ import * as v from "valibot";
4
4
 
5
5
  //#region src/intents/salt-manager.ts
6
6
  const SALT_TTL_MS = 300 * 1e3;
7
+ /**
8
+ * Salt manager that returns a static, pre-configured salt.
9
+ * Use when salt is known ahead of time (e.g., private blockchain with fixed salt).
10
+ */
11
+ var StaticSaltManager = class {
12
+ /**
13
+ * @param saltHex Salt as hex string (e.g., "01020304")
14
+ */
15
+ constructor(saltHex) {
16
+ this.salt = hex.decode(saltHex);
17
+ if (this.salt.length !== 4) throw new Error(`Invalid salt length: ${this.salt.length}, expected 4`);
18
+ }
19
+ async getCachedSalt() {
20
+ return this.salt;
21
+ }
22
+ async refresh() {
23
+ return this.salt;
24
+ }
25
+ };
7
26
  var SaltManager = class {
8
27
  constructor({ envConfig, nearProvider }) {
9
28
  this.currentSalt = null;
@@ -69,4 +88,4 @@ async function fetchSalt(nearProvider, contractId) {
69
88
  }
70
89
 
71
90
  //#endregion
72
- export { SaltManager };
91
+ export { SaltManager, StaticSaltManager };
@@ -1,17 +1,37 @@
1
1
  const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
2
  const require_caip2 = require('./caip2.cjs');
3
- const require_object = require('./object.cjs');
4
3
  let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
5
4
 
6
5
  //#region src/lib/configure-rpc-config.ts
6
+ /**
7
+ * Configures EVM RPC URLs by merging defaults with user-provided URLs.
8
+ * Extracts plain URL strings for compatibility with external SDKs.
9
+ */
7
10
  function configureEvmRpcUrls(defaultRpcUrls, userRpcUrls, supportedChains) {
8
- const evmRpcUrls = Object.fromEntries(Object.entries(require_object.pick(Object.assign({}, defaultRpcUrls, userRpcUrls ?? {}), supportedChains)).map(([caip2, urls]) => [require_caip2.getEIP155ChainId(caip2), urls]));
11
+ const evmRpcUrls = {};
12
+ for (const caip2 of supportedChains) {
13
+ const endpoints = userRpcUrls?.[caip2] ?? defaultRpcUrls[caip2];
14
+ if (endpoints) {
15
+ const chainId = require_caip2.getEIP155ChainId(caip2);
16
+ evmRpcUrls[chainId] = (0, _defuse_protocol_internal_utils.extractRpcUrls)(endpoints);
17
+ }
18
+ }
9
19
  for (const [chainId, urls] of Object.entries(evmRpcUrls)) (0, _defuse_protocol_internal_utils.assert)(urls.length > 0, `EVM RPC URLs for chain ${chainId} are not provided`);
10
20
  return evmRpcUrls;
11
21
  }
22
+ /**
23
+ * Configures Stellar RPC URLs by merging defaults with user-provided URLs.
24
+ * Extracts plain URL strings for compatibility with external SDKs.
25
+ */
12
26
  function configureStellarRpcUrls(defaultRpcUrls, userRpcUrls) {
13
- const stellarRpcUrls = Object.assign({}, defaultRpcUrls, userRpcUrls?.[require_caip2.Chains.Stellar] ?? {});
14
- for (const [key, value] of Object.entries(stellarRpcUrls)) (0, _defuse_protocol_internal_utils.assert)(value.length > 0, `Stellar RPC URL for ${key} is not provided`);
27
+ const soroban = userRpcUrls?.[require_caip2.Chains.Stellar]?.soroban ?? defaultRpcUrls.soroban;
28
+ const horizon = userRpcUrls?.[require_caip2.Chains.Stellar]?.horizon ?? defaultRpcUrls.horizon;
29
+ const stellarRpcUrls = {
30
+ soroban: (0, _defuse_protocol_internal_utils.extractRpcUrls)(soroban),
31
+ horizon: (0, _defuse_protocol_internal_utils.extractRpcUrls)(horizon)
32
+ };
33
+ (0, _defuse_protocol_internal_utils.assert)(stellarRpcUrls.soroban.length > 0, "Stellar Soroban RPC URL is not provided");
34
+ (0, _defuse_protocol_internal_utils.assert)(stellarRpcUrls.horizon.length > 0, "Stellar Horizon RPC URL is not provided");
15
35
  return stellarRpcUrls;
16
36
  }
17
37
 
@@ -1,16 +1,36 @@
1
1
  import { Chains, getEIP155ChainId } from "./caip2.js";
2
- import { pick } from "./object.js";
3
- import { assert } from "@defuse-protocol/internal-utils";
2
+ import { assert, extractRpcUrls } from "@defuse-protocol/internal-utils";
4
3
 
5
4
  //#region src/lib/configure-rpc-config.ts
5
+ /**
6
+ * Configures EVM RPC URLs by merging defaults with user-provided URLs.
7
+ * Extracts plain URL strings for compatibility with external SDKs.
8
+ */
6
9
  function configureEvmRpcUrls(defaultRpcUrls, userRpcUrls, supportedChains) {
7
- const evmRpcUrls = Object.fromEntries(Object.entries(pick(Object.assign({}, defaultRpcUrls, userRpcUrls ?? {}), supportedChains)).map(([caip2, urls]) => [getEIP155ChainId(caip2), urls]));
10
+ const evmRpcUrls = {};
11
+ for (const caip2 of supportedChains) {
12
+ const endpoints = userRpcUrls?.[caip2] ?? defaultRpcUrls[caip2];
13
+ if (endpoints) {
14
+ const chainId = getEIP155ChainId(caip2);
15
+ evmRpcUrls[chainId] = extractRpcUrls(endpoints);
16
+ }
17
+ }
8
18
  for (const [chainId, urls] of Object.entries(evmRpcUrls)) assert(urls.length > 0, `EVM RPC URLs for chain ${chainId} are not provided`);
9
19
  return evmRpcUrls;
10
20
  }
21
+ /**
22
+ * Configures Stellar RPC URLs by merging defaults with user-provided URLs.
23
+ * Extracts plain URL strings for compatibility with external SDKs.
24
+ */
11
25
  function configureStellarRpcUrls(defaultRpcUrls, userRpcUrls) {
12
- const stellarRpcUrls = Object.assign({}, defaultRpcUrls, userRpcUrls?.[Chains.Stellar] ?? {});
13
- for (const [key, value] of Object.entries(stellarRpcUrls)) assert(value.length > 0, `Stellar RPC URL for ${key} is not provided`);
26
+ const soroban = userRpcUrls?.[Chains.Stellar]?.soroban ?? defaultRpcUrls.soroban;
27
+ const horizon = userRpcUrls?.[Chains.Stellar]?.horizon ?? defaultRpcUrls.horizon;
28
+ const stellarRpcUrls = {
29
+ soroban: extractRpcUrls(soroban),
30
+ horizon: extractRpcUrls(horizon)
31
+ };
32
+ assert(stellarRpcUrls.soroban.length > 0, "Stellar Soroban RPC URL is not provided");
33
+ assert(stellarRpcUrls.horizon.length > 0, "Stellar Horizon RPC URL is not provided");
14
34
  return stellarRpcUrls;
15
35
  }
16
36
 
package/dist/src/sdk.cjs CHANGED
@@ -32,9 +32,10 @@ var IntentsSDK = class {
32
32
  this.envConfig = (0, _defuse_protocol_internal_utils.resolveEnvConfig)(args.env);
33
33
  this.referral = args.referral;
34
34
  this.solverRelayApiKey = args.solverRelayApiKey;
35
- const nearRpcUrls = args.rpc?.[require_caip2.Chains.Near] ?? _defuse_protocol_internal_utils.PUBLIC_NEAR_RPC_URLS;
36
- (0, _defuse_protocol_internal_utils.assert)(nearRpcUrls.length > 0, "NEAR RPC URLs are not provided");
37
- const nearProvider = (0, _defuse_protocol_internal_utils.nearFailoverRpcProvider)({ urls: nearRpcUrls });
35
+ const nearRpcEndpoints = args.rpc?.[require_caip2.Chains.Near] ?? _defuse_protocol_internal_utils.PUBLIC_NEAR_RPC_URLS;
36
+ (0, _defuse_protocol_internal_utils.assert)(nearRpcEndpoints.length > 0, "NEAR RPC URLs are not provided");
37
+ const nearProvider = (0, _defuse_protocol_internal_utils.nearFailoverRpcProvider)({ urls: nearRpcEndpoints });
38
+ const nearRpcUrls = (0, _defuse_protocol_internal_utils.extractRpcUrls)(nearRpcEndpoints);
38
39
  const stellarRpcUrls = require_configure_rpc_config.configureStellarRpcUrls(require_public_rpc_urls.PUBLIC_STELLAR_RPC_URLS, args.rpc);
39
40
  const evmRpcUrls = require_configure_rpc_config.configureEvmRpcUrls(require_public_rpc_urls.PUBLIC_EVM_RPC_URLS, args.rpc, require_hot_bridge_chains.HotBridgeEVMChains);
40
41
  /**
@@ -83,7 +84,7 @@ var IntentsSDK = class {
83
84
  solverRelayApiKey: this.solverRelayApiKey
84
85
  });
85
86
  this.intentSigner = args.intentSigner;
86
- this.saltManager = new require_salt_manager.SaltManager({
87
+ this.saltManager = this.envConfig.contractSalt != null ? new require_salt_manager.StaticSaltManager(this.envConfig.contractSalt) : new require_salt_manager.SaltManager({
87
88
  envConfig: this.envConfig,
88
89
  nearProvider
89
90
  });
package/dist/src/sdk.js CHANGED
@@ -17,9 +17,9 @@ import { noopIntentSigner } from "./intents/intent-signer-impl/intent-signer-noo
17
17
  import { zip } from "./lib/array.js";
18
18
  import { configureEvmRpcUrls, configureStellarRpcUrls } from "./lib/configure-rpc-config.js";
19
19
  import { createWithdrawalIdentifiers, watchWithdrawal } from "./core/withdrawal-watcher.js";
20
- import { SaltManager } from "./intents/salt-manager.js";
20
+ import { SaltManager, StaticSaltManager } from "./intents/salt-manager.js";
21
21
  import { IntentPayloadBuilder } from "./intents/intent-payload-builder.js";
22
- import { PUBLIC_NEAR_RPC_URLS, RelayPublishError, assert, nearFailoverRpcProvider, resolveEnvConfig, solverRelay } from "@defuse-protocol/internal-utils";
22
+ import { PUBLIC_NEAR_RPC_URLS, RelayPublishError, assert, extractRpcUrls, nearFailoverRpcProvider, resolveEnvConfig, solverRelay } from "@defuse-protocol/internal-utils";
23
23
  import { HotBridge } from "@hot-labs/omni-sdk";
24
24
  import { stringify } from "viem";
25
25
  import * as v from "valibot";
@@ -30,9 +30,10 @@ var IntentsSDK = class {
30
30
  this.envConfig = resolveEnvConfig(args.env);
31
31
  this.referral = args.referral;
32
32
  this.solverRelayApiKey = args.solverRelayApiKey;
33
- const nearRpcUrls = args.rpc?.[Chains.Near] ?? PUBLIC_NEAR_RPC_URLS;
34
- assert(nearRpcUrls.length > 0, "NEAR RPC URLs are not provided");
35
- const nearProvider = nearFailoverRpcProvider({ urls: nearRpcUrls });
33
+ const nearRpcEndpoints = args.rpc?.[Chains.Near] ?? PUBLIC_NEAR_RPC_URLS;
34
+ assert(nearRpcEndpoints.length > 0, "NEAR RPC URLs are not provided");
35
+ const nearProvider = nearFailoverRpcProvider({ urls: nearRpcEndpoints });
36
+ const nearRpcUrls = extractRpcUrls(nearRpcEndpoints);
36
37
  const stellarRpcUrls = configureStellarRpcUrls(PUBLIC_STELLAR_RPC_URLS, args.rpc);
37
38
  const evmRpcUrls = configureEvmRpcUrls(PUBLIC_EVM_RPC_URLS, args.rpc, HotBridgeEVMChains);
38
39
  /**
@@ -81,7 +82,7 @@ var IntentsSDK = class {
81
82
  solverRelayApiKey: this.solverRelayApiKey
82
83
  });
83
84
  this.intentSigner = args.intentSigner;
84
- this.saltManager = new SaltManager({
85
+ this.saltManager = this.envConfig.contractSalt != null ? new StaticSaltManager(this.envConfig.contractSalt) : new SaltManager({
85
86
  envConfig: this.envConfig,
86
87
  nearProvider
87
88
  });
@@ -5,7 +5,7 @@ import { IntentHash, IntentPayloadFactory, IntentPrimitive, IntentRelayParamsFac
5
5
  import { IIntentSigner } from "./intents/interfaces/intent-signer.cjs";
6
6
  import { OnBeforePublishIntentHook } from "./intents/intent-executer-impl/intent-executer.cjs";
7
7
  import { Chain, Chains } from "./lib/caip2.cjs";
8
- import { ILogger, solverRelay } from "@defuse-protocol/internal-utils";
8
+ import { ILogger, RpcEndpoint, solverRelay } from "@defuse-protocol/internal-utils";
9
9
 
10
10
  //#region src/shared-types.d.ts
11
11
  interface IntentPublishResult {
@@ -194,7 +194,10 @@ interface WithdrawalParams {
194
194
  amount: bigint;
195
195
  destinationAddress: string;
196
196
  /**
197
- * XRP Leger chain specific. MEMO IS NOT SUPPORTED FOR STELLAR AND TON.
197
+ * Optional memo attached to the withdrawal.
198
+ * - XRP Ledger: included in the transaction memo field
199
+ * - Internal transfers (intents): passed as memo in the transfer intent
200
+ * - Stellar, TON: NOT SUPPORTED (will throw error)
198
201
  */
199
202
  destinationMemo?: string | undefined;
200
203
  feeInclusive: boolean;
@@ -368,11 +371,17 @@ type ParsedAssetInfo = ({
368
371
  } | {
369
372
  address: string;
370
373
  });
371
- type RPCEndpointMap = Record<typeof Chains.Near | HotBridgeEVMChain, string[]> & { [K in typeof Chains.Stellar]: {
372
- soroban: string[];
373
- horizon: string[];
374
+ type RPCEndpointMap = Record<typeof Chains.Near | HotBridgeEVMChain, RpcEndpoint[]> & { [K in typeof Chains.Stellar]: {
375
+ soroban: RpcEndpoint[];
376
+ horizon: RpcEndpoint[];
374
377
  } };
375
- type DeepPartial<T> = T extends object ? T extends Array<infer U> ? Array<DeepPartial<U>> : T extends Function ? T : { [P in keyof T]?: DeepPartial<T[P]> } : T;
376
- type PartialRPCEndpointMap = DeepPartial<RPCEndpointMap>;
378
+ /**
379
+ * Partial RPC endpoint map where each chain's URLs are optional,
380
+ * but individual RpcEndpoint items remain valid (not deeply partial).
381
+ */
382
+ type PartialRPCEndpointMap = { [K in keyof RPCEndpointMap]?: K extends typeof Chains.Stellar ? {
383
+ soroban?: RpcEndpoint[];
384
+ horizon?: RpcEndpoint[];
385
+ } : RpcEndpoint[] };
377
386
  //#endregion
378
387
  export { BatchWithdrawalResult, Bridge, CreateWithdrawalCompletionPromisesParams, FeeEstimation, HotBridgeRouteConfig, IIntentsSDK, IntentPublishResult, IntentSettlementStatus, InternalTransferRouteConfig, NearTxInfo, NearWithdrawalRouteConfig, OmniBridgeRouteConfig, ParsedAssetInfo, PartialRPCEndpointMap, PoaBridgeRouteConfig, ProcessWithdrawalArgs, QuoteOptions, RouteConfig, SignAndSendArgs, SignAndSendWithdrawalArgs, SignedIntentsComposition, TxInfo, TxNoInfo, VirtualChainRouteConfig, WithdrawalIdentifier, WithdrawalParams, WithdrawalResult };
@@ -5,7 +5,7 @@ import { IntentHash, IntentPayloadFactory, IntentPrimitive, IntentRelayParamsFac
5
5
  import { IIntentSigner } from "./intents/interfaces/intent-signer.js";
6
6
  import { OnBeforePublishIntentHook } from "./intents/intent-executer-impl/intent-executer.js";
7
7
  import { Chain, Chains } from "./lib/caip2.js";
8
- import { ILogger, solverRelay } from "@defuse-protocol/internal-utils";
8
+ import { ILogger, RpcEndpoint, solverRelay } from "@defuse-protocol/internal-utils";
9
9
 
10
10
  //#region src/shared-types.d.ts
11
11
  interface IntentPublishResult {
@@ -194,7 +194,10 @@ interface WithdrawalParams {
194
194
  amount: bigint;
195
195
  destinationAddress: string;
196
196
  /**
197
- * XRP Leger chain specific. MEMO IS NOT SUPPORTED FOR STELLAR AND TON.
197
+ * Optional memo attached to the withdrawal.
198
+ * - XRP Ledger: included in the transaction memo field
199
+ * - Internal transfers (intents): passed as memo in the transfer intent
200
+ * - Stellar, TON: NOT SUPPORTED (will throw error)
198
201
  */
199
202
  destinationMemo?: string | undefined;
200
203
  feeInclusive: boolean;
@@ -368,11 +371,17 @@ type ParsedAssetInfo = ({
368
371
  } | {
369
372
  address: string;
370
373
  });
371
- type RPCEndpointMap = Record<typeof Chains.Near | HotBridgeEVMChain, string[]> & { [K in typeof Chains.Stellar]: {
372
- soroban: string[];
373
- horizon: string[];
374
+ type RPCEndpointMap = Record<typeof Chains.Near | HotBridgeEVMChain, RpcEndpoint[]> & { [K in typeof Chains.Stellar]: {
375
+ soroban: RpcEndpoint[];
376
+ horizon: RpcEndpoint[];
374
377
  } };
375
- type DeepPartial<T> = T extends object ? T extends Array<infer U> ? Array<DeepPartial<U>> : T extends Function ? T : { [P in keyof T]?: DeepPartial<T[P]> } : T;
376
- type PartialRPCEndpointMap = DeepPartial<RPCEndpointMap>;
378
+ /**
379
+ * Partial RPC endpoint map where each chain's URLs are optional,
380
+ * but individual RpcEndpoint items remain valid (not deeply partial).
381
+ */
382
+ type PartialRPCEndpointMap = { [K in keyof RPCEndpointMap]?: K extends typeof Chains.Stellar ? {
383
+ soroban?: RpcEndpoint[];
384
+ horizon?: RpcEndpoint[];
385
+ } : RpcEndpoint[] };
377
386
  //#endregion
378
387
  export { BatchWithdrawalResult, Bridge, CreateWithdrawalCompletionPromisesParams, FeeEstimation, HotBridgeRouteConfig, IIntentsSDK, IntentPublishResult, IntentSettlementStatus, InternalTransferRouteConfig, NearTxInfo, NearWithdrawalRouteConfig, OmniBridgeRouteConfig, ParsedAssetInfo, PartialRPCEndpointMap, PoaBridgeRouteConfig, ProcessWithdrawalArgs, QuoteOptions, RouteConfig, SignAndSendArgs, SignAndSendWithdrawalArgs, SignedIntentsComposition, TxInfo, TxNoInfo, VirtualChainRouteConfig, WithdrawalIdentifier, WithdrawalParams, WithdrawalResult };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defuse-protocol/intents-sdk",
3
- "version": "0.47.0",
3
+ "version": "0.49.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "repository": {
@@ -47,8 +47,8 @@
47
47
  "ripple-address-codec": "^5.0.0",
48
48
  "valibot": "^1.0.0",
49
49
  "viem": "^2.0.0",
50
- "@defuse-protocol/contract-types": "0.5.0",
51
- "@defuse-protocol/internal-utils": "0.24.2"
50
+ "@defuse-protocol/contract-types": "0.6.0",
51
+ "@defuse-protocol/internal-utils": "0.26.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "tsdown": "0.19.0"
@@ -1,10 +0,0 @@
1
-
2
- //#region src/lib/object.ts
3
- function pick(obj, keys) {
4
- const result = {};
5
- for (const key of keys) if (key in obj) result[key] = obj[key];
6
- return result;
7
- }
8
-
9
- //#endregion
10
- exports.pick = pick;
@@ -1,9 +0,0 @@
1
- //#region src/lib/object.ts
2
- function pick(obj, keys) {
3
- const result = {};
4
- for (const key of keys) if (key in obj) result[key] = obj[key];
5
- return result;
6
- }
7
-
8
- //#endregion
9
- export { pick };