@defuse-protocol/intents-sdk 0.45.4 → 0.46.1

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 (35) hide show
  1. package/dist/index.d.cts +2 -2
  2. package/dist/index.d.ts +2 -2
  3. package/dist/src/bridges/aurora-engine-bridge/aurora-engine-bridge.cjs +3 -3
  4. package/dist/src/bridges/aurora-engine-bridge/aurora-engine-bridge.js +3 -3
  5. package/dist/src/bridges/direct-bridge/direct-bridge.cjs +3 -3
  6. package/dist/src/bridges/direct-bridge/direct-bridge.js +3 -3
  7. package/dist/src/bridges/hot-bridge/hot-bridge.cjs +3 -3
  8. package/dist/src/bridges/hot-bridge/hot-bridge.js +3 -3
  9. package/dist/src/bridges/omni-bridge/omni-bridge.cjs +7 -7
  10. package/dist/src/bridges/omni-bridge/omni-bridge.js +8 -8
  11. package/dist/src/bridges/poa-bridge/poa-bridge.cjs +11 -6
  12. package/dist/src/bridges/poa-bridge/poa-bridge.js +12 -7
  13. package/dist/src/intents/intent-executer-impl/intent-executer.cjs +8 -4
  14. package/dist/src/intents/intent-executer-impl/intent-executer.d.cts +1 -1
  15. package/dist/src/intents/intent-executer-impl/intent-executer.d.ts +1 -1
  16. package/dist/src/intents/intent-executer-impl/intent-executer.js +8 -3
  17. package/dist/src/intents/intent-payload-builder.cjs +5 -5
  18. package/dist/src/intents/intent-payload-builder.d.cts +4 -4
  19. package/dist/src/intents/intent-payload-builder.d.ts +4 -4
  20. package/dist/src/intents/intent-payload-builder.js +6 -6
  21. package/dist/src/intents/intent-relayer-impl/intent-relayer-public.cjs +5 -5
  22. package/dist/src/intents/intent-relayer-impl/intent-relayer-public.js +6 -6
  23. package/dist/src/intents/salt-manager.cjs +2 -2
  24. package/dist/src/intents/salt-manager.js +3 -3
  25. package/dist/src/lib/estimate-fee.cjs +4 -4
  26. package/dist/src/lib/estimate-fee.js +5 -5
  27. package/dist/src/lib/tokensUsdPricesHttpClient/apis.cjs +1 -1
  28. package/dist/src/lib/tokensUsdPricesHttpClient/apis.js +2 -2
  29. package/dist/src/sdk.cjs +18 -12
  30. package/dist/src/sdk.d.cts +35 -4
  31. package/dist/src/sdk.d.ts +35 -4
  32. package/dist/src/sdk.js +19 -13
  33. package/dist/src/shared-types.d.cts +7 -0
  34. package/dist/src/shared-types.d.ts +7 -0
  35. package/package.json +3 -3
@@ -1,6 +1,6 @@
1
1
  import { VersionedNonceBuilder } from "./expirable-nonce.js";
2
2
  import { DEFAULT_DEADLINE_MS, DEFAULT_NONCE_DEADLINE_OFFSET_MS } from "./intent-payload-factory.js";
3
- import { configsByEnvironment, utils } from "@defuse-protocol/internal-utils";
3
+ import { utils } from "@defuse-protocol/internal-utils";
4
4
 
5
5
  //#region src/intents/intent-payload-builder.ts
6
6
  /**
@@ -30,9 +30,9 @@ import { configsByEnvironment, utils } from "@defuse-protocol/internal-utils";
30
30
  var IntentPayloadBuilder = class IntentPayloadBuilder {
31
31
  constructor(config) {
32
32
  this.intents = [];
33
- this.env = config.env;
33
+ this.envConfig = config.envConfig;
34
34
  this.saltManager = config.saltManager;
35
- this.verifyingContract = configsByEnvironment[this.env].contractID;
35
+ this.verifyingContract = this.envConfig.contractID;
36
36
  }
37
37
  /**
38
38
  * Set the signer ID (address or account that will sign the intent).
@@ -121,7 +121,7 @@ var IntentPayloadBuilder = class IntentPayloadBuilder {
121
121
  this.deadline = void 0;
122
122
  this.intents = [];
123
123
  this.customNonce = void 0;
124
- this.verifyingContract = configsByEnvironment[this.env].contractID;
124
+ this.verifyingContract = this.envConfig.contractID;
125
125
  return this;
126
126
  }
127
127
  /**
@@ -175,7 +175,7 @@ var IntentPayloadBuilder = class IntentPayloadBuilder {
175
175
  */
176
176
  clone() {
177
177
  const builder = new IntentPayloadBuilder({
178
- env: this.env,
178
+ envConfig: this.envConfig,
179
179
  saltManager: this.saltManager
180
180
  });
181
181
  builder.verifyingContract = this.verifyingContract;
@@ -193,7 +193,7 @@ var IntentPayloadBuilder = class IntentPayloadBuilder {
193
193
  */
194
194
  getState() {
195
195
  return {
196
- env: this.env,
196
+ envConfig: this.envConfig,
197
197
  verifyingContract: this.verifyingContract,
198
198
  signerId: this.signerId,
199
199
  deadline: this.deadline,
@@ -3,8 +3,8 @@ let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils")
3
3
 
4
4
  //#region src/intents/intent-relayer-impl/intent-relayer-public.ts
5
5
  var IntentRelayerPublic = class {
6
- constructor({ env, solverRelayApiKey }) {
7
- this.env = env;
6
+ constructor({ envConfig, solverRelayApiKey }) {
7
+ this.envConfig = envConfig;
8
8
  this.solverRelayApiKey = solverRelayApiKey;
9
9
  }
10
10
  async publishIntent({ multiPayload, quoteHashes }, ctx = {}) {
@@ -18,7 +18,7 @@ var IntentRelayerPublic = class {
18
18
  quote_hashes: quoteHashes,
19
19
  signed_datas: multiPayloads
20
20
  }, {
21
- baseURL: _defuse_protocol_internal_utils.configsByEnvironment[this.env].solverRelayBaseURL,
21
+ baseURL: this.envConfig.solverRelayBaseURL,
22
22
  logger: ctx.logger,
23
23
  solverRelayApiKey: this.solverRelayApiKey
24
24
  });
@@ -30,11 +30,11 @@ var IntentRelayerPublic = class {
30
30
  hash: (await _defuse_protocol_internal_utils.solverRelay.waitForIntentSettlement({
31
31
  intentHash: ticket,
32
32
  signal: ctx.signal,
33
- baseURL: _defuse_protocol_internal_utils.configsByEnvironment[this.env].solverRelayBaseURL,
33
+ baseURL: this.envConfig.solverRelayBaseURL,
34
34
  logger: ctx.logger,
35
35
  solverRelayApiKey: this.solverRelayApiKey
36
36
  })).txHash,
37
- accountId: _defuse_protocol_internal_utils.configsByEnvironment[this.env].contractID
37
+ accountId: this.envConfig.contractID
38
38
  } };
39
39
  }
40
40
  };
@@ -1,9 +1,9 @@
1
- import { configsByEnvironment, solverRelay } from "@defuse-protocol/internal-utils";
1
+ import { solverRelay } from "@defuse-protocol/internal-utils";
2
2
 
3
3
  //#region src/intents/intent-relayer-impl/intent-relayer-public.ts
4
4
  var IntentRelayerPublic = class {
5
- constructor({ env, solverRelayApiKey }) {
6
- this.env = env;
5
+ constructor({ envConfig, solverRelayApiKey }) {
6
+ this.envConfig = envConfig;
7
7
  this.solverRelayApiKey = solverRelayApiKey;
8
8
  }
9
9
  async publishIntent({ multiPayload, quoteHashes }, ctx = {}) {
@@ -17,7 +17,7 @@ var IntentRelayerPublic = class {
17
17
  quote_hashes: quoteHashes,
18
18
  signed_datas: multiPayloads
19
19
  }, {
20
- baseURL: configsByEnvironment[this.env].solverRelayBaseURL,
20
+ baseURL: this.envConfig.solverRelayBaseURL,
21
21
  logger: ctx.logger,
22
22
  solverRelayApiKey: this.solverRelayApiKey
23
23
  });
@@ -29,11 +29,11 @@ var IntentRelayerPublic = class {
29
29
  hash: (await solverRelay.waitForIntentSettlement({
30
30
  intentHash: ticket,
31
31
  signal: ctx.signal,
32
- baseURL: configsByEnvironment[this.env].solverRelayBaseURL,
32
+ baseURL: this.envConfig.solverRelayBaseURL,
33
33
  logger: ctx.logger,
34
34
  solverRelayApiKey: this.solverRelayApiKey
35
35
  })).txHash,
36
- accountId: configsByEnvironment[this.env].contractID
36
+ accountId: this.envConfig.contractID
37
37
  } };
38
38
  }
39
39
  };
@@ -7,11 +7,11 @@ valibot = require_rolldown_runtime.__toESM(valibot);
7
7
  //#region src/intents/salt-manager.ts
8
8
  const SALT_TTL_MS = 300 * 1e3;
9
9
  var SaltManager = class {
10
- constructor({ env, nearProvider }) {
10
+ constructor({ envConfig, nearProvider }) {
11
11
  this.currentSalt = null;
12
12
  this.fetchPromise = null;
13
13
  this.lastFetchTime = 0;
14
- this.intentsContract = _defuse_protocol_internal_utils.configsByEnvironment[env].contractID;
14
+ this.intentsContract = envConfig.contractID;
15
15
  this.nearProvider = nearProvider;
16
16
  }
17
17
  /**
@@ -1,15 +1,15 @@
1
- import { configsByEnvironment, utils } from "@defuse-protocol/internal-utils";
1
+ import { utils } from "@defuse-protocol/internal-utils";
2
2
  import { hex } from "@scure/base";
3
3
  import * as v from "valibot";
4
4
 
5
5
  //#region src/intents/salt-manager.ts
6
6
  const SALT_TTL_MS = 300 * 1e3;
7
7
  var SaltManager = class {
8
- constructor({ env, nearProvider }) {
8
+ constructor({ envConfig, nearProvider }) {
9
9
  this.currentSalt = null;
10
10
  this.fetchPromise = null;
11
11
  this.lastFetchTime = 0;
12
- this.intentsContract = configsByEnvironment[env].contractID;
12
+ this.intentsContract = envConfig.contractID;
13
13
  this.nearProvider = nearProvider;
14
14
  }
15
15
  /**
@@ -23,7 +23,7 @@ function getUnderlyingFee(feeEstimation, route, feeKey) {
23
23
  /**
24
24
  * ExactIn fallback with 1.2x multiplier
25
25
  */
26
- async function getFeeQuote({ feeAmount, feeAssetId, tokenAssetId, quoteOptions, env, logger, solverRelayApiKey }) {
26
+ async function getFeeQuote({ feeAmount, feeAssetId, tokenAssetId, quoteOptions, envConfig, logger, solverRelayApiKey }) {
27
27
  try {
28
28
  return await _defuse_protocol_internal_utils.solverRelay.getQuote({
29
29
  quoteParams: {
@@ -36,7 +36,7 @@ async function getFeeQuote({ feeAmount, feeAssetId, tokenAssetId, quoteOptions,
36
36
  trusted_metadata: quoteOptions?.trustedMetadata
37
37
  },
38
38
  config: {
39
- baseURL: _defuse_protocol_internal_utils.configsByEnvironment[env].solverRelayBaseURL,
39
+ baseURL: envConfig.solverRelayBaseURL,
40
40
  logBalanceSufficient: false,
41
41
  logger,
42
42
  solverRelayApiKey
@@ -45,7 +45,7 @@ async function getFeeQuote({ feeAmount, feeAssetId, tokenAssetId, quoteOptions,
45
45
  } catch (err) {
46
46
  if (!(err instanceof _defuse_protocol_internal_utils.QuoteError)) throw err;
47
47
  logger?.info("Can't get exact out quote, trying to get exact in quote with x1.2");
48
- const prices = await require_apis.tokens({ env });
48
+ const prices = await require_apis.tokens({ envConfig });
49
49
  const feeAssetPrice = prices.items.find((t) => t.defuse_asset_id === feeAssetId);
50
50
  const tokenAssetPrice = prices.items.find((t) => t.defuse_asset_id === tokenAssetId);
51
51
  if (feeAssetPrice == null || tokenAssetPrice == null) throw err;
@@ -70,7 +70,7 @@ async function getFeeQuote({ feeAmount, feeAssetId, tokenAssetId, quoteOptions,
70
70
  trusted_metadata: quoteOptions?.trustedMetadata
71
71
  },
72
72
  config: {
73
- baseURL: _defuse_protocol_internal_utils.configsByEnvironment[env].solverRelayBaseURL,
73
+ baseURL: envConfig.solverRelayBaseURL,
74
74
  logBalanceSufficient: false,
75
75
  logger,
76
76
  solverRelayApiKey
@@ -1,5 +1,5 @@
1
1
  import { tokens } from "./tokensUsdPricesHttpClient/apis.js";
2
- import { QuoteError, configsByEnvironment, solverRelay } from "@defuse-protocol/internal-utils";
2
+ import { QuoteError, solverRelay } from "@defuse-protocol/internal-utils";
3
3
 
4
4
  //#region src/lib/estimate-fee.ts
5
5
  /**
@@ -22,7 +22,7 @@ function getUnderlyingFee(feeEstimation, route, feeKey) {
22
22
  /**
23
23
  * ExactIn fallback with 1.2x multiplier
24
24
  */
25
- async function getFeeQuote({ feeAmount, feeAssetId, tokenAssetId, quoteOptions, env, logger, solverRelayApiKey }) {
25
+ async function getFeeQuote({ feeAmount, feeAssetId, tokenAssetId, quoteOptions, envConfig, logger, solverRelayApiKey }) {
26
26
  try {
27
27
  return await solverRelay.getQuote({
28
28
  quoteParams: {
@@ -35,7 +35,7 @@ async function getFeeQuote({ feeAmount, feeAssetId, tokenAssetId, quoteOptions,
35
35
  trusted_metadata: quoteOptions?.trustedMetadata
36
36
  },
37
37
  config: {
38
- baseURL: configsByEnvironment[env].solverRelayBaseURL,
38
+ baseURL: envConfig.solverRelayBaseURL,
39
39
  logBalanceSufficient: false,
40
40
  logger,
41
41
  solverRelayApiKey
@@ -44,7 +44,7 @@ async function getFeeQuote({ feeAmount, feeAssetId, tokenAssetId, quoteOptions,
44
44
  } catch (err) {
45
45
  if (!(err instanceof QuoteError)) throw err;
46
46
  logger?.info("Can't get exact out quote, trying to get exact in quote with x1.2");
47
- const prices = await tokens({ env });
47
+ const prices = await tokens({ envConfig });
48
48
  const feeAssetPrice = prices.items.find((t) => t.defuse_asset_id === feeAssetId);
49
49
  const tokenAssetPrice = prices.items.find((t) => t.defuse_asset_id === tokenAssetId);
50
50
  if (feeAssetPrice == null || tokenAssetPrice == null) throw err;
@@ -69,7 +69,7 @@ async function getFeeQuote({ feeAmount, feeAssetId, tokenAssetId, quoteOptions,
69
69
  trusted_metadata: quoteOptions?.trustedMetadata
70
70
  },
71
71
  config: {
72
- baseURL: configsByEnvironment[env].solverRelayBaseURL,
72
+ baseURL: envConfig.solverRelayBaseURL,
73
73
  logBalanceSufficient: false,
74
74
  logger,
75
75
  solverRelayApiKey
@@ -4,7 +4,7 @@ let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils")
4
4
  //#region src/lib/tokensUsdPricesHttpClient/apis.ts
5
5
  async function tokens(config) {
6
6
  return (await (0, _defuse_protocol_internal_utils.request)({
7
- url: new URL("tokens", _defuse_protocol_internal_utils.configsByEnvironment[config.env].managerConsoleBaseURL),
7
+ url: new URL("tokens", config.envConfig.managerConsoleBaseURL),
8
8
  ...config,
9
9
  fetchOptions: {
10
10
  ...config.fetchOptions,
@@ -1,9 +1,9 @@
1
- import { configsByEnvironment, request } from "@defuse-protocol/internal-utils";
1
+ import { request } from "@defuse-protocol/internal-utils";
2
2
 
3
3
  //#region src/lib/tokensUsdPricesHttpClient/apis.ts
4
4
  async function tokens(config) {
5
5
  return (await request({
6
- url: new URL("tokens", configsByEnvironment[config.env].managerConsoleBaseURL),
6
+ url: new URL("tokens", config.envConfig.managerConsoleBaseURL),
7
7
  ...config,
8
8
  fetchOptions: {
9
9
  ...config.fetchOptions,
package/dist/src/sdk.cjs CHANGED
@@ -29,7 +29,7 @@ valibot = require_rolldown_runtime.__toESM(valibot);
29
29
  //#region src/sdk.ts
30
30
  var IntentsSDK = class {
31
31
  constructor(args) {
32
- this.env = args.env ?? "production";
32
+ this.envConfig = (0, _defuse_protocol_internal_utils.resolveEnvConfig)(args.env);
33
33
  this.referral = args.referral;
34
34
  this.solverRelayApiKey = args.solverRelayApiKey;
35
35
  const nearRpcUrls = args.rpc?.[require_caip2.Chains.Near] ?? _defuse_protocol_internal_utils.PUBLIC_NEAR_RPC_URLS;
@@ -44,16 +44,16 @@ var IntentsSDK = class {
44
44
  this.bridges = [
45
45
  new require_intents_bridge.IntentsBridge(),
46
46
  new require_aurora_engine_bridge.AuroraEngineBridge({
47
- env: this.env,
47
+ envConfig: this.envConfig,
48
48
  nearProvider,
49
49
  solverRelayApiKey: this.solverRelayApiKey
50
50
  }),
51
51
  new require_poa_bridge.PoaBridge({
52
- env: this.env,
52
+ envConfig: this.envConfig,
53
53
  routeMigratedPoaTokensThroughOmniBridge: args.features?.routeMigratedPoaTokensThroughOmniBridge
54
54
  }),
55
55
  new require_hot_bridge.HotBridge({
56
- env: this.env,
56
+ envConfig: this.envConfig,
57
57
  solverRelayApiKey: this.solverRelayApiKey,
58
58
  hotSdk: new _hot_labs_omni_sdk.HotBridge({
59
59
  logger: console,
@@ -67,24 +67,24 @@ var IntentsSDK = class {
67
67
  })
68
68
  }),
69
69
  new require_omni_bridge.OmniBridge({
70
- env: this.env,
70
+ envConfig: this.envConfig,
71
71
  nearProvider,
72
72
  solverRelayApiKey: this.solverRelayApiKey,
73
73
  routeMigratedPoaTokensThroughOmniBridge: args.features?.routeMigratedPoaTokensThroughOmniBridge
74
74
  }),
75
75
  new require_direct_bridge.DirectBridge({
76
- env: this.env,
76
+ envConfig: this.envConfig,
77
77
  nearProvider,
78
78
  solverRelayApiKey: this.solverRelayApiKey
79
79
  })
80
80
  ];
81
81
  this.intentRelayer = new require_intent_relayer_public.IntentRelayerPublic({
82
- env: this.env,
82
+ envConfig: this.envConfig,
83
83
  solverRelayApiKey: this.solverRelayApiKey
84
84
  });
85
85
  this.intentSigner = args.intentSigner;
86
86
  this.saltManager = new require_salt_manager.SaltManager({
87
- env: this.env,
87
+ envConfig: this.envConfig,
88
88
  nearProvider
89
89
  });
90
90
  }
@@ -117,7 +117,7 @@ var IntentsSDK = class {
117
117
  */
118
118
  intentBuilder() {
119
119
  return new require_intent_payload_builder.IntentPayloadBuilder({
120
- env: this.env,
120
+ envConfig: this.envConfig,
121
121
  saltManager: this.saltManager
122
122
  });
123
123
  }
@@ -300,11 +300,17 @@ var IntentsSDK = class {
300
300
  }
301
301
  throw new Error(`Cannot determine bridge for assetId = ${assetId}`);
302
302
  }
303
+ async sendSignedIntents(args) {
304
+ return { tickets: await this.intentRelayer.publishIntents({
305
+ multiPayloads: args.multiPayloads,
306
+ quoteHashes: args.quoteHashes ?? []
307
+ }, { logger: args.logger }) };
308
+ }
303
309
  async signAndSendIntent(args) {
304
310
  const intentSigner = args.signer ?? this.intentSigner;
305
311
  (0, _defuse_protocol_internal_utils.assert)(intentSigner != null, "Intent signer is not provided");
306
312
  const intentExecuter = new require_intent_executer.IntentExecuter({
307
- env: this.env,
313
+ envConfig: this.envConfig,
308
314
  logger: args.logger,
309
315
  intentSigner,
310
316
  intentRelayer: this.intentRelayer,
@@ -368,7 +374,7 @@ var IntentsSDK = class {
368
374
  }
369
375
  async waitForIntentSettlement(args) {
370
376
  const { tx } = await new require_intent_executer.IntentExecuter({
371
- env: this.env,
377
+ envConfig: this.envConfig,
372
378
  logger: args.logger,
373
379
  intentSigner: require_intent_signer_noop.noopIntentSigner,
374
380
  intentRelayer: this.intentRelayer
@@ -377,7 +383,7 @@ var IntentsSDK = class {
377
383
  }
378
384
  async getIntentStatus({ intentHash, logger }) {
379
385
  return _defuse_protocol_internal_utils.solverRelay.getStatus({ intent_hash: intentHash }, {
380
- baseURL: _defuse_protocol_internal_utils.configsByEnvironment[this.env].solverRelayBaseURL,
386
+ baseURL: this.envConfig.solverRelayBaseURL,
381
387
  logger,
382
388
  solverRelayApiKey: this.solverRelayApiKey
383
389
  });
@@ -1,14 +1,38 @@
1
- import { IntentHash, IntentPrimitive } from "./intents/shared-types.cjs";
1
+ import { IntentHash, IntentPrimitive, MultiPayload } from "./intents/shared-types.cjs";
2
2
  import { IIntentSigner } from "./intents/interfaces/intent-signer.cjs";
3
3
  import { BatchWithdrawalResult, Bridge, CreateWithdrawalCompletionPromisesParams, FeeEstimation, IIntentsSDK, IntentPublishResult, IntentSettlementStatus, NearTxInfo, ParsedAssetInfo, PartialRPCEndpointMap, ProcessWithdrawalArgs, QuoteOptions, SignAndSendArgs, SignAndSendWithdrawalArgs, TxInfo, TxNoInfo, WithdrawalParams, WithdrawalResult } from "./shared-types.cjs";
4
4
  import { IIntentRelayer } from "./intents/interfaces/intent-relayer.cjs";
5
5
  import { ISaltManager } from "./intents/interfaces/salt-manager.cjs";
6
6
  import { IntentPayloadBuilder } from "./intents/intent-payload-builder.cjs";
7
- import { ILogger, NearIntentsEnv } from "@defuse-protocol/internal-utils";
7
+ import { EnvConfig, ILogger, NearIntentsEnv } from "@defuse-protocol/internal-utils";
8
8
 
9
9
  //#region src/sdk.d.ts
10
10
  interface IntentsSDKConfig {
11
- env?: NearIntentsEnv;
11
+ /**
12
+ * Environment configuration. Can be:
13
+ * - "production" or "stage" to use preset configurations
14
+ * - A custom EnvConfig object for private environments
15
+ *
16
+ * Defaults to "production" if not specified.
17
+ *
18
+ * @example
19
+ * // Use preset
20
+ * new IntentsSDK({ env: "production", referral: "..." });
21
+ *
22
+ * // Use custom config for private environment
23
+ * new IntentsSDK({
24
+ * env: {
25
+ * contractID: "intents.private-shard",
26
+ * poaTokenFactoryContractID: "",
27
+ * poaBridgeBaseURL: "",
28
+ * solverRelayBaseURL: "https://private-relay.example.com",
29
+ * managerConsoleBaseURL: "",
30
+ * nearIntentsBaseURL: "",
31
+ * },
32
+ * referral: "...",
33
+ * });
34
+ */
35
+ env?: NearIntentsEnv | EnvConfig;
12
36
  intentSigner?: IIntentSigner;
13
37
  rpc?: PartialRPCEndpointMap;
14
38
  referral: string;
@@ -22,7 +46,7 @@ interface IntentsSDKConfig {
22
46
  };
23
47
  }
24
48
  declare class IntentsSDK implements IIntentsSDK {
25
- protected env: NearIntentsEnv;
49
+ protected envConfig: EnvConfig;
26
50
  protected referral: string;
27
51
  protected intentRelayer: IIntentRelayer<IntentHash>;
28
52
  protected intentSigner?: IIntentSigner;
@@ -177,6 +201,13 @@ declare class IntentsSDK implements IIntentsSDK {
177
201
  */
178
202
  createWithdrawalCompletionPromises(params: CreateWithdrawalCompletionPromisesParams): Array<Promise<TxInfo | TxNoInfo>>;
179
203
  parseAssetId(assetId: string): ParsedAssetInfo;
204
+ sendSignedIntents(args: {
205
+ multiPayloads: MultiPayload[];
206
+ quoteHashes?: string[];
207
+ logger?: ILogger;
208
+ }): Promise<{
209
+ tickets: IntentHash[];
210
+ }>;
180
211
  signAndSendIntent(args: SignAndSendArgs): Promise<IntentPublishResult>;
181
212
  private withSaltRetry;
182
213
  signAndSendWithdrawalIntent(args: SignAndSendWithdrawalArgs<WithdrawalParams> | SignAndSendWithdrawalArgs<WithdrawalParams[]>): Promise<IntentPublishResult>;
package/dist/src/sdk.d.ts CHANGED
@@ -1,14 +1,38 @@
1
- import { IntentHash, IntentPrimitive } from "./intents/shared-types.js";
1
+ import { IntentHash, IntentPrimitive, MultiPayload } from "./intents/shared-types.js";
2
2
  import { IIntentSigner } from "./intents/interfaces/intent-signer.js";
3
3
  import { BatchWithdrawalResult, Bridge, CreateWithdrawalCompletionPromisesParams, FeeEstimation, IIntentsSDK, IntentPublishResult, IntentSettlementStatus, NearTxInfo, ParsedAssetInfo, PartialRPCEndpointMap, ProcessWithdrawalArgs, QuoteOptions, SignAndSendArgs, SignAndSendWithdrawalArgs, TxInfo, TxNoInfo, WithdrawalParams, WithdrawalResult } from "./shared-types.js";
4
4
  import { IIntentRelayer } from "./intents/interfaces/intent-relayer.js";
5
5
  import { ISaltManager } from "./intents/interfaces/salt-manager.js";
6
6
  import { IntentPayloadBuilder } from "./intents/intent-payload-builder.js";
7
- import { ILogger, NearIntentsEnv } from "@defuse-protocol/internal-utils";
7
+ import { EnvConfig, ILogger, NearIntentsEnv } from "@defuse-protocol/internal-utils";
8
8
 
9
9
  //#region src/sdk.d.ts
10
10
  interface IntentsSDKConfig {
11
- env?: NearIntentsEnv;
11
+ /**
12
+ * Environment configuration. Can be:
13
+ * - "production" or "stage" to use preset configurations
14
+ * - A custom EnvConfig object for private environments
15
+ *
16
+ * Defaults to "production" if not specified.
17
+ *
18
+ * @example
19
+ * // Use preset
20
+ * new IntentsSDK({ env: "production", referral: "..." });
21
+ *
22
+ * // Use custom config for private environment
23
+ * new IntentsSDK({
24
+ * env: {
25
+ * contractID: "intents.private-shard",
26
+ * poaTokenFactoryContractID: "",
27
+ * poaBridgeBaseURL: "",
28
+ * solverRelayBaseURL: "https://private-relay.example.com",
29
+ * managerConsoleBaseURL: "",
30
+ * nearIntentsBaseURL: "",
31
+ * },
32
+ * referral: "...",
33
+ * });
34
+ */
35
+ env?: NearIntentsEnv | EnvConfig;
12
36
  intentSigner?: IIntentSigner;
13
37
  rpc?: PartialRPCEndpointMap;
14
38
  referral: string;
@@ -22,7 +46,7 @@ interface IntentsSDKConfig {
22
46
  };
23
47
  }
24
48
  declare class IntentsSDK implements IIntentsSDK {
25
- protected env: NearIntentsEnv;
49
+ protected envConfig: EnvConfig;
26
50
  protected referral: string;
27
51
  protected intentRelayer: IIntentRelayer<IntentHash>;
28
52
  protected intentSigner?: IIntentSigner;
@@ -177,6 +201,13 @@ declare class IntentsSDK implements IIntentsSDK {
177
201
  */
178
202
  createWithdrawalCompletionPromises(params: CreateWithdrawalCompletionPromisesParams): Array<Promise<TxInfo | TxNoInfo>>;
179
203
  parseAssetId(assetId: string): ParsedAssetInfo;
204
+ sendSignedIntents(args: {
205
+ multiPayloads: MultiPayload[];
206
+ quoteHashes?: string[];
207
+ logger?: ILogger;
208
+ }): Promise<{
209
+ tickets: IntentHash[];
210
+ }>;
180
211
  signAndSendIntent(args: SignAndSendArgs): Promise<IntentPublishResult>;
181
212
  private withSaltRetry;
182
213
  signAndSendWithdrawalIntent(args: SignAndSendWithdrawalArgs<WithdrawalParams> | SignAndSendWithdrawalArgs<WithdrawalParams[]>): Promise<IntentPublishResult>;
package/dist/src/sdk.js CHANGED
@@ -19,7 +19,7 @@ import { configureEvmRpcUrls, configureStellarRpcUrls } from "./lib/configure-rp
19
19
  import { createWithdrawalIdentifiers, watchWithdrawal } from "./core/withdrawal-watcher.js";
20
20
  import { SaltManager } from "./intents/salt-manager.js";
21
21
  import { IntentPayloadBuilder } from "./intents/intent-payload-builder.js";
22
- import { PUBLIC_NEAR_RPC_URLS, RelayPublishError, assert, configsByEnvironment, nearFailoverRpcProvider, solverRelay } from "@defuse-protocol/internal-utils";
22
+ import { PUBLIC_NEAR_RPC_URLS, RelayPublishError, assert, 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";
@@ -27,7 +27,7 @@ import * as v from "valibot";
27
27
  //#region src/sdk.ts
28
28
  var IntentsSDK = class {
29
29
  constructor(args) {
30
- this.env = args.env ?? "production";
30
+ this.envConfig = resolveEnvConfig(args.env);
31
31
  this.referral = args.referral;
32
32
  this.solverRelayApiKey = args.solverRelayApiKey;
33
33
  const nearRpcUrls = args.rpc?.[Chains.Near] ?? PUBLIC_NEAR_RPC_URLS;
@@ -42,16 +42,16 @@ var IntentsSDK = class {
42
42
  this.bridges = [
43
43
  new IntentsBridge(),
44
44
  new AuroraEngineBridge({
45
- env: this.env,
45
+ envConfig: this.envConfig,
46
46
  nearProvider,
47
47
  solverRelayApiKey: this.solverRelayApiKey
48
48
  }),
49
49
  new PoaBridge({
50
- env: this.env,
50
+ envConfig: this.envConfig,
51
51
  routeMigratedPoaTokensThroughOmniBridge: args.features?.routeMigratedPoaTokensThroughOmniBridge
52
52
  }),
53
53
  new HotBridge$1({
54
- env: this.env,
54
+ envConfig: this.envConfig,
55
55
  solverRelayApiKey: this.solverRelayApiKey,
56
56
  hotSdk: new HotBridge({
57
57
  logger: console,
@@ -65,24 +65,24 @@ var IntentsSDK = class {
65
65
  })
66
66
  }),
67
67
  new OmniBridge({
68
- env: this.env,
68
+ envConfig: this.envConfig,
69
69
  nearProvider,
70
70
  solverRelayApiKey: this.solverRelayApiKey,
71
71
  routeMigratedPoaTokensThroughOmniBridge: args.features?.routeMigratedPoaTokensThroughOmniBridge
72
72
  }),
73
73
  new DirectBridge({
74
- env: this.env,
74
+ envConfig: this.envConfig,
75
75
  nearProvider,
76
76
  solverRelayApiKey: this.solverRelayApiKey
77
77
  })
78
78
  ];
79
79
  this.intentRelayer = new IntentRelayerPublic({
80
- env: this.env,
80
+ envConfig: this.envConfig,
81
81
  solverRelayApiKey: this.solverRelayApiKey
82
82
  });
83
83
  this.intentSigner = args.intentSigner;
84
84
  this.saltManager = new SaltManager({
85
- env: this.env,
85
+ envConfig: this.envConfig,
86
86
  nearProvider
87
87
  });
88
88
  }
@@ -115,7 +115,7 @@ var IntentsSDK = class {
115
115
  */
116
116
  intentBuilder() {
117
117
  return new IntentPayloadBuilder({
118
- env: this.env,
118
+ envConfig: this.envConfig,
119
119
  saltManager: this.saltManager
120
120
  });
121
121
  }
@@ -298,11 +298,17 @@ var IntentsSDK = class {
298
298
  }
299
299
  throw new Error(`Cannot determine bridge for assetId = ${assetId}`);
300
300
  }
301
+ async sendSignedIntents(args) {
302
+ return { tickets: await this.intentRelayer.publishIntents({
303
+ multiPayloads: args.multiPayloads,
304
+ quoteHashes: args.quoteHashes ?? []
305
+ }, { logger: args.logger }) };
306
+ }
301
307
  async signAndSendIntent(args) {
302
308
  const intentSigner = args.signer ?? this.intentSigner;
303
309
  assert(intentSigner != null, "Intent signer is not provided");
304
310
  const intentExecuter = new IntentExecuter({
305
- env: this.env,
311
+ envConfig: this.envConfig,
306
312
  logger: args.logger,
307
313
  intentSigner,
308
314
  intentRelayer: this.intentRelayer,
@@ -366,7 +372,7 @@ var IntentsSDK = class {
366
372
  }
367
373
  async waitForIntentSettlement(args) {
368
374
  const { tx } = await new IntentExecuter({
369
- env: this.env,
375
+ envConfig: this.envConfig,
370
376
  logger: args.logger,
371
377
  intentSigner: noopIntentSigner,
372
378
  intentRelayer: this.intentRelayer
@@ -375,7 +381,7 @@ var IntentsSDK = class {
375
381
  }
376
382
  async getIntentStatus({ intentHash, logger }) {
377
383
  return solverRelay.getStatus({ intent_hash: intentHash }, {
378
- baseURL: configsByEnvironment[this.env].solverRelayBaseURL,
384
+ baseURL: this.envConfig.solverRelayBaseURL,
379
385
  logger,
380
386
  solverRelayApiKey: this.solverRelayApiKey
381
387
  });
@@ -110,6 +110,13 @@ type ProcessWithdrawalArgs<T extends WithdrawalParams | WithdrawalParams[]> = {
110
110
  };
111
111
  interface IIntentsSDK {
112
112
  setIntentSigner(signer: IIntentSigner): void;
113
+ sendSignedIntents(args: {
114
+ multiPayloads: MultiPayload[];
115
+ quoteHashes?: string[];
116
+ logger?: ILogger;
117
+ }): Promise<{
118
+ tickets: IntentHash[];
119
+ }>;
113
120
  signAndSendIntent(args: SignAndSendArgs): Promise<IntentPublishResult>;
114
121
  waitForIntentSettlement(args: {
115
122
  intentHash: IntentHash;
@@ -110,6 +110,13 @@ type ProcessWithdrawalArgs<T extends WithdrawalParams | WithdrawalParams[]> = {
110
110
  };
111
111
  interface IIntentsSDK {
112
112
  setIntentSigner(signer: IIntentSigner): void;
113
+ sendSignedIntents(args: {
114
+ multiPayloads: MultiPayload[];
115
+ quoteHashes?: string[];
116
+ logger?: ILogger;
117
+ }): Promise<{
118
+ tickets: IntentHash[];
119
+ }>;
113
120
  signAndSendIntent(args: SignAndSendArgs): Promise<IntentPublishResult>;
114
121
  waitForIntentSettlement(args: {
115
122
  intentHash: IntentHash;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defuse-protocol/intents-sdk",
3
- "version": "0.45.4",
3
+ "version": "0.46.1",
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.4.4",
51
- "@defuse-protocol/internal-utils": "0.23.1"
50
+ "@defuse-protocol/contract-types": "0.5.0",
51
+ "@defuse-protocol/internal-utils": "0.24.1"
52
52
  },
53
53
  "devDependencies": {
54
54
  "tsdown": "0.19.0"