amogus-sdk-internal-utils 0.35.2
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/_virtual/rolldown_runtime.cjs +43 -0
- package/dist/_virtual/rolldown_runtime.js +18 -0
- package/dist/bridgeIndexer/bridgeIndexerHttpClient/apis.cjs +10 -0
- package/dist/bridgeIndexer/bridgeIndexerHttpClient/apis.d.cts +6 -0
- package/dist/bridgeIndexer/bridgeIndexerHttpClient/apis.d.ts +6 -0
- package/dist/bridgeIndexer/bridgeIndexerHttpClient/apis.js +10 -0
- package/dist/bridgeIndexer/bridgeIndexerHttpClient/index.cjs +17 -0
- package/dist/bridgeIndexer/bridgeIndexerHttpClient/index.d.cts +9 -0
- package/dist/bridgeIndexer/bridgeIndexerHttpClient/index.d.ts +9 -0
- package/dist/bridgeIndexer/bridgeIndexerHttpClient/index.js +12 -0
- package/dist/bridgeIndexer/bridgeIndexerHttpClient/runtime.cjs +20 -0
- package/dist/bridgeIndexer/bridgeIndexerHttpClient/runtime.js +20 -0
- package/dist/bridgeIndexer/bridgeIndexerHttpClient/types.cjs +25 -0
- package/dist/bridgeIndexer/bridgeIndexerHttpClient/types.d.cts +31 -0
- package/dist/bridgeIndexer/bridgeIndexerHttpClient/types.d.ts +31 -0
- package/dist/bridgeIndexer/bridgeIndexerHttpClient/types.js +23 -0
- package/dist/bridgeIndexer/index.cjs +13 -0
- package/dist/bridgeIndexer/index.d.cts +8 -0
- package/dist/bridgeIndexer/index.d.ts +8 -0
- package/dist/bridgeIndexer/index.js +8 -0
- package/dist/config.cjs +86 -0
- package/dist/config.d.cts +50 -0
- package/dist/config.d.ts +50 -0
- package/dist/config.js +76 -0
- package/dist/errors/assert.cjs +11 -0
- package/dist/errors/assert.d.cts +11 -0
- package/dist/errors/assert.d.ts +11 -0
- package/dist/errors/assert.js +11 -0
- package/dist/errors/base.cjs +34 -0
- package/dist/errors/base.d.cts +21 -0
- package/dist/errors/base.d.ts +21 -0
- package/dist/errors/base.js +33 -0
- package/dist/errors/index.cjs +23 -0
- package/dist/errors/index.d.cts +11 -0
- package/dist/errors/index.d.ts +11 -0
- package/dist/errors/index.js +18 -0
- package/dist/errors/request.cjs +48 -0
- package/dist/errors/request.d.cts +61 -0
- package/dist/errors/request.d.ts +61 -0
- package/dist/errors/request.js +46 -0
- package/dist/errors/utils/isNetworkError.cjs +23 -0
- package/dist/errors/utils/isNetworkError.js +22 -0
- package/dist/errors/utils/toError.cjs +8 -0
- package/dist/errors/utils/toError.d.cts +4 -0
- package/dist/errors/utils/toError.d.ts +4 -0
- package/dist/errors/utils/toError.js +7 -0
- package/dist/index.cjs +144 -0
- package/dist/index.d.cts +33 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +33 -0
- package/dist/logger.d.cts +11 -0
- package/dist/logger.d.ts +11 -0
- package/dist/nearClient.cjs +18 -0
- package/dist/nearClient.d.cts +8 -0
- package/dist/nearClient.d.ts +8 -0
- package/dist/nearClient.js +18 -0
- package/dist/poaBridge/constants/blockchains.cjs +62 -0
- package/dist/poaBridge/constants/blockchains.d.cts +95 -0
- package/dist/poaBridge/constants/blockchains.d.ts +95 -0
- package/dist/poaBridge/constants/blockchains.js +59 -0
- package/dist/poaBridge/errors/withdrawal.cjs +52 -0
- package/dist/poaBridge/errors/withdrawal.d.cts +34 -0
- package/dist/poaBridge/errors/withdrawal.d.ts +34 -0
- package/dist/poaBridge/errors/withdrawal.js +50 -0
- package/dist/poaBridge/getPendingDeposits.cjs +31 -0
- package/dist/poaBridge/getPendingDeposits.d.cts +14 -0
- package/dist/poaBridge/getPendingDeposits.d.ts +15 -0
- package/dist/poaBridge/getPendingDeposits.js +31 -0
- package/dist/poaBridge/index.cjs +23 -0
- package/dist/poaBridge/index.d.cts +11 -0
- package/dist/poaBridge/index.d.ts +11 -0
- package/dist/poaBridge/index.js +18 -0
- package/dist/poaBridge/poaBridgeHttpClient/apis.cjs +38 -0
- package/dist/poaBridge/poaBridgeHttpClient/apis.d.cts +12 -0
- package/dist/poaBridge/poaBridgeHttpClient/apis.d.ts +12 -0
- package/dist/poaBridge/poaBridgeHttpClient/apis.js +32 -0
- package/dist/poaBridge/poaBridgeHttpClient/index.cjs +21 -0
- package/dist/poaBridge/poaBridgeHttpClient/index.d.cts +9 -0
- package/dist/poaBridge/poaBridgeHttpClient/index.d.ts +9 -0
- package/dist/poaBridge/poaBridgeHttpClient/index.js +16 -0
- package/dist/poaBridge/poaBridgeHttpClient/runtime.cjs +49 -0
- package/dist/poaBridge/poaBridgeHttpClient/runtime.js +47 -0
- package/dist/poaBridge/poaBridgeHttpClient/types.d.cts +172 -0
- package/dist/poaBridge/poaBridgeHttpClient/types.d.ts +172 -0
- package/dist/poaBridge/waitForWithdrawalCompletion.cjs +57 -0
- package/dist/poaBridge/waitForWithdrawalCompletion.d.cts +31 -0
- package/dist/poaBridge/waitForWithdrawalCompletion.d.ts +31 -0
- package/dist/poaBridge/waitForWithdrawalCompletion.js +56 -0
- package/dist/services/blockchainBalanceService.cjs +40 -0
- package/dist/services/blockchainBalanceService.d.cts +21 -0
- package/dist/services/blockchainBalanceService.d.ts +21 -0
- package/dist/services/blockchainBalanceService.js +37 -0
- package/dist/solverRelay/errors/intentSettlement.cjs +20 -0
- package/dist/solverRelay/errors/intentSettlement.d.cts +13 -0
- package/dist/solverRelay/errors/intentSettlement.d.ts +13 -0
- package/dist/solverRelay/errors/intentSettlement.js +20 -0
- package/dist/solverRelay/errors/quote.cjs +18 -0
- package/dist/solverRelay/errors/quote.d.cts +21 -0
- package/dist/solverRelay/errors/quote.d.ts +22 -0
- package/dist/solverRelay/errors/quote.js +18 -0
- package/dist/solverRelay/getQuote.cjs +70 -0
- package/dist/solverRelay/getQuote.d.cts +14 -0
- package/dist/solverRelay/getQuote.d.ts +14 -0
- package/dist/solverRelay/getQuote.js +70 -0
- package/dist/solverRelay/getStatus.cjs +26 -0
- package/dist/solverRelay/getStatus.d.cts +17 -0
- package/dist/solverRelay/getStatus.d.ts +18 -0
- package/dist/solverRelay/getStatus.js +26 -0
- package/dist/solverRelay/index.cjs +27 -0
- package/dist/solverRelay/index.d.cts +16 -0
- package/dist/solverRelay/index.d.ts +16 -0
- package/dist/solverRelay/index.js +22 -0
- package/dist/solverRelay/publishIntent.cjs +20 -0
- package/dist/solverRelay/publishIntent.d.cts +15 -0
- package/dist/solverRelay/publishIntent.d.ts +16 -0
- package/dist/solverRelay/publishIntent.js +20 -0
- package/dist/solverRelay/publishIntents.cjs +42 -0
- package/dist/solverRelay/publishIntents.d.cts +10 -0
- package/dist/solverRelay/publishIntents.d.ts +11 -0
- package/dist/solverRelay/publishIntents.js +41 -0
- package/dist/solverRelay/solverRelayHttpClient/apis.cjs +21 -0
- package/dist/solverRelay/solverRelayHttpClient/apis.d.cts +9 -0
- package/dist/solverRelay/solverRelayHttpClient/apis.d.ts +9 -0
- package/dist/solverRelay/solverRelayHttpClient/apis.js +18 -0
- package/dist/solverRelay/solverRelayHttpClient/index.cjs +18 -0
- package/dist/solverRelay/solverRelayHttpClient/index.d.cts +9 -0
- package/dist/solverRelay/solverRelayHttpClient/index.d.ts +9 -0
- package/dist/solverRelay/solverRelayHttpClient/index.js +13 -0
- package/dist/solverRelay/solverRelayHttpClient/runtime.cjs +60 -0
- package/dist/solverRelay/solverRelayHttpClient/runtime.js +58 -0
- package/dist/solverRelay/solverRelayHttpClient/types.d.cts +117 -0
- package/dist/solverRelay/solverRelayHttpClient/types.d.ts +117 -0
- package/dist/solverRelay/utils/parseFailedPublishError.cjs +64 -0
- package/dist/solverRelay/utils/parseFailedPublishError.d.cts +56 -0
- package/dist/solverRelay/utils/parseFailedPublishError.d.ts +57 -0
- package/dist/solverRelay/utils/parseFailedPublishError.js +61 -0
- package/dist/solverRelay/utils/quoteWithLog.cjs +21 -0
- package/dist/solverRelay/utils/quoteWithLog.d.cts +12 -0
- package/dist/solverRelay/utils/quoteWithLog.d.ts +14 -0
- package/dist/solverRelay/utils/quoteWithLog.js +21 -0
- package/dist/solverRelay/waitForIntentSettlement.cjs +52 -0
- package/dist/solverRelay/waitForIntentSettlement.d.cts +30 -0
- package/dist/solverRelay/waitForIntentSettlement.d.ts +30 -0
- package/dist/solverRelay/waitForIntentSettlement.js +52 -0
- package/dist/types/authHandle.cjs +22 -0
- package/dist/types/authHandle.d.cts +25 -0
- package/dist/types/authHandle.d.ts +25 -0
- package/dist/types/authHandle.js +16 -0
- package/dist/types/base.d.cts +45 -0
- package/dist/types/base.d.ts +45 -0
- package/dist/types/intentsUserId.d.cts +10 -0
- package/dist/types/intentsUserId.d.ts +10 -0
- package/dist/types/walletMessage.cjs +11 -0
- package/dist/types/walletMessage.d.cts +106 -0
- package/dist/types/walletMessage.d.ts +106 -0
- package/dist/types/walletMessage.js +5 -0
- package/dist/utils/abortSignal.cjs +19 -0
- package/dist/utils/abortSignal.js +18 -0
- package/dist/utils/appFee.cjs +20 -0
- package/dist/utils/appFee.d.cts +9 -0
- package/dist/utils/appFee.d.ts +9 -0
- package/dist/utils/appFee.js +15 -0
- package/dist/utils/assert.cjs +9 -0
- package/dist/utils/assert.d.cts +7 -0
- package/dist/utils/assert.d.ts +7 -0
- package/dist/utils/assert.js +9 -0
- package/dist/utils/authIdentity.cjs +56 -0
- package/dist/utils/authIdentity.d.cts +34 -0
- package/dist/utils/authIdentity.d.ts +34 -0
- package/dist/utils/authIdentity.js +50 -0
- package/dist/utils/failover.cjs +36 -0
- package/dist/utils/failover.d.cts +24 -0
- package/dist/utils/failover.d.ts +24 -0
- package/dist/utils/failover.js +34 -0
- package/dist/utils/handleRPCResponse.cjs +30 -0
- package/dist/utils/handleRPCResponse.js +28 -0
- package/dist/utils/handleResponse.cjs +31 -0
- package/dist/utils/handleResponse.js +29 -0
- package/dist/utils/index.cjs +55 -0
- package/dist/utils/index.d.cts +13 -0
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.js +50 -0
- package/dist/utils/messageFactory.cjs +137 -0
- package/dist/utils/messageFactory.d.cts +70 -0
- package/dist/utils/messageFactory.d.ts +70 -0
- package/dist/utils/messageFactory.js +132 -0
- package/dist/utils/multiPayload/webauthn.cjs +27 -0
- package/dist/utils/multiPayload/webauthn.js +26 -0
- package/dist/utils/near.cjs +58 -0
- package/dist/utils/near.d.cts +35 -0
- package/dist/utils/near.d.ts +35 -0
- package/dist/utils/near.js +53 -0
- package/dist/utils/poll.cjs +87 -0
- package/dist/utils/poll.d.cts +54 -0
- package/dist/utils/poll.d.ts +54 -0
- package/dist/utils/poll.js +85 -0
- package/dist/utils/prepareBroadcastRequest.cjs +98 -0
- package/dist/utils/prepareBroadcastRequest.d.cts +16 -0
- package/dist/utils/prepareBroadcastRequest.d.ts +16 -0
- package/dist/utils/prepareBroadcastRequest.js +90 -0
- package/dist/utils/promise/withTimeout.cjs +34 -0
- package/dist/utils/promise/withTimeout.d.cts +16 -0
- package/dist/utils/promise/withTimeout.d.ts +16 -0
- package/dist/utils/promise/withTimeout.js +34 -0
- package/dist/utils/request.cjs +100 -0
- package/dist/utils/request.d.cts +27 -0
- package/dist/utils/request.d.ts +27 -0
- package/dist/utils/request.js +99 -0
- package/dist/utils/requestShouldRetry.cjs +20 -0
- package/dist/utils/requestShouldRetry.js +20 -0
- package/dist/utils/retry.cjs +66 -0
- package/dist/utils/retry.d.cts +56 -0
- package/dist/utils/retry.d.ts +56 -0
- package/dist/utils/retry.js +64 -0
- package/dist/utils/rpc-endpoint.cjs +56 -0
- package/dist/utils/rpc-endpoint.d.cts +20 -0
- package/dist/utils/rpc-endpoint.d.ts +20 -0
- package/dist/utils/rpc-endpoint.js +54 -0
- package/dist/utils/serialize.cjs +82 -0
- package/dist/utils/serialize.d.cts +17 -0
- package/dist/utils/serialize.d.ts +17 -0
- package/dist/utils/serialize.js +81 -0
- package/dist/utils/stellarAddressToBytes.cjs +295 -0
- package/dist/utils/stellarAddressToBytes.js +294 -0
- package/dist/utils/token.cjs +8 -0
- package/dist/utils/token.js +7 -0
- package/dist/utils/tokenUtils.cjs +263 -0
- package/dist/utils/tokenUtils.d.cts +88 -0
- package/dist/utils/tokenUtils.d.ts +88 -0
- package/dist/utils/tokenUtils.js +238 -0
- package/dist/utils/tronAddressToHex.cjs +18 -0
- package/dist/utils/tronAddressToHex.js +17 -0
- package/dist/utils/uint8Array.cjs +15 -0
- package/dist/utils/uint8Array.d.cts +4 -0
- package/dist/utils/uint8Array.d.ts +4 -0
- package/dist/utils/uint8Array.js +14 -0
- package/dist/utils/webAuthn.cjs +58 -0
- package/dist/utils/webAuthn.js +56 -0
- package/dist/xrpl/index.cjs +13 -0
- package/dist/xrpl/index.d.cts +8 -0
- package/dist/xrpl/index.d.ts +8 -0
- package/dist/xrpl/index.js +8 -0
- package/dist/xrpl/xrplHttpClient/apis.cjs +28 -0
- package/dist/xrpl/xrplHttpClient/apis.d.cts +7 -0
- package/dist/xrpl/xrplHttpClient/apis.d.ts +7 -0
- package/dist/xrpl/xrplHttpClient/apis.js +27 -0
- package/dist/xrpl/xrplHttpClient/errors.cjs +27 -0
- package/dist/xrpl/xrplHttpClient/errors.d.cts +24 -0
- package/dist/xrpl/xrplHttpClient/errors.d.ts +24 -0
- package/dist/xrpl/xrplHttpClient/errors.js +26 -0
- package/dist/xrpl/xrplHttpClient/index.cjs +19 -0
- package/dist/xrpl/xrplHttpClient/index.d.cts +10 -0
- package/dist/xrpl/xrplHttpClient/index.d.ts +10 -0
- package/dist/xrpl/xrplHttpClient/index.js +14 -0
- package/dist/xrpl/xrplHttpClient/runtime.cjs +57 -0
- package/dist/xrpl/xrplHttpClient/runtime.js +55 -0
- package/dist/xrpl/xrplHttpClient/types.cjs +39 -0
- package/dist/xrpl/xrplHttpClient/types.d.cts +64 -0
- package/dist/xrpl/xrplHttpClient/types.d.ts +64 -0
- package/dist/xrpl/xrplHttpClient/types.js +35 -0
- package/package.json +59 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const require_assert = require('../utils/assert.cjs');
|
|
2
|
+
const require_quote = require('./errors/quote.cjs');
|
|
3
|
+
const require_quoteWithLog = require('./utils/quoteWithLog.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/solverRelay/getQuote.ts
|
|
6
|
+
async function getQuote(params) {
|
|
7
|
+
return handleQuoteResult(await require_quoteWithLog.quoteWithLog(params.quoteParams, {
|
|
8
|
+
timeout: (params.quoteParams?.wait_ms ?? 0) + 1e4,
|
|
9
|
+
...params.config
|
|
10
|
+
}), params.quoteParams, params.config.logger);
|
|
11
|
+
}
|
|
12
|
+
function handleQuoteResult(result, quoteParams, logger) {
|
|
13
|
+
if (result == null) throw new require_quote.QuoteError({
|
|
14
|
+
quote: null,
|
|
15
|
+
quoteParams
|
|
16
|
+
});
|
|
17
|
+
const hasExactIn = quoteParams.exact_amount_in != null;
|
|
18
|
+
require_assert.assert(hasExactIn !== (quoteParams.exact_amount_out != null), `Invalid quoteParams: exactly one of exact_amount_in or exact_amount_out must be set (got exact_amount_in=${quoteParams.exact_amount_in}, exact_amount_out=${quoteParams.exact_amount_out}).`);
|
|
19
|
+
const quoteKind = hasExactIn ? "exact_in" : "exact_out";
|
|
20
|
+
const failedQuotes = [];
|
|
21
|
+
const validQuotes = [];
|
|
22
|
+
for (const q of result) {
|
|
23
|
+
if (!isValidQuote(q)) {
|
|
24
|
+
failedQuotes.push(q);
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (!matchesRequest(q, quoteParams)) {
|
|
28
|
+
logger?.warn("quote: dropping quote that doesn't match the request", {
|
|
29
|
+
quoteParams,
|
|
30
|
+
quote: q
|
|
31
|
+
});
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
validQuotes.push(q);
|
|
35
|
+
}
|
|
36
|
+
const bestQuote = sortQuotes(validQuotes, quoteKind)[0];
|
|
37
|
+
if (bestQuote != null) return bestQuote;
|
|
38
|
+
const failedQuote = failedQuotes[0];
|
|
39
|
+
if (failedQuote != null) throw new require_quote.QuoteError({
|
|
40
|
+
quote: failedQuote,
|
|
41
|
+
quoteParams
|
|
42
|
+
});
|
|
43
|
+
throw new require_quote.QuoteError({
|
|
44
|
+
quote: null,
|
|
45
|
+
quoteParams
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function sortQuotes(quotes, quoteKind) {
|
|
49
|
+
return quotes.slice().sort((a, b) => {
|
|
50
|
+
if (quoteKind === "exact_in") {
|
|
51
|
+
if (BigInt(a.amount_out) > BigInt(b.amount_out)) return -1;
|
|
52
|
+
if (BigInt(a.amount_out) < BigInt(b.amount_out)) return 1;
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
|
55
|
+
if (BigInt(a.amount_in) < BigInt(b.amount_in)) return -1;
|
|
56
|
+
if (BigInt(a.amount_in) > BigInt(b.amount_in)) return 1;
|
|
57
|
+
return 0;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function isValidQuote(quote) {
|
|
61
|
+
return !("type" in quote);
|
|
62
|
+
}
|
|
63
|
+
function matchesRequest(quote, quoteParams) {
|
|
64
|
+
if (quote.defuse_asset_identifier_in !== quoteParams.defuse_asset_identifier_in || quote.defuse_asset_identifier_out !== quoteParams.defuse_asset_identifier_out) return false;
|
|
65
|
+
if (quoteParams.exact_amount_in != null) return BigInt(quote.amount_in) === BigInt(quoteParams.exact_amount_in);
|
|
66
|
+
return BigInt(quote.amount_out) === BigInt(quoteParams.exact_amount_out);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
exports.getQuote = getQuote;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { JSONRPCErrorType, Quote } from "./solverRelayHttpClient/types.cjs";
|
|
2
|
+
import { QuoteError } from "./errors/quote.cjs";
|
|
3
|
+
import { quoteWithLog } from "./utils/quoteWithLog.cjs";
|
|
4
|
+
|
|
5
|
+
//#region src/solverRelay/getQuote.d.ts
|
|
6
|
+
type GetQuoteParams = {
|
|
7
|
+
quoteParams: Parameters<typeof quoteWithLog>[0];
|
|
8
|
+
config: Parameters<typeof quoteWithLog>[1];
|
|
9
|
+
};
|
|
10
|
+
type GetQuoteReturnType = Quote;
|
|
11
|
+
type GetQuoteErrorType = QuoteError | JSONRPCErrorType;
|
|
12
|
+
declare function getQuote(params: GetQuoteParams): Promise<GetQuoteReturnType>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { GetQuoteErrorType, GetQuoteParams, GetQuoteReturnType, getQuote };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { JSONRPCErrorType, Quote } from "./solverRelayHttpClient/types.js";
|
|
2
|
+
import { QuoteError } from "./errors/quote.js";
|
|
3
|
+
import { quoteWithLog } from "./utils/quoteWithLog.js";
|
|
4
|
+
|
|
5
|
+
//#region src/solverRelay/getQuote.d.ts
|
|
6
|
+
type GetQuoteParams = {
|
|
7
|
+
quoteParams: Parameters<typeof quoteWithLog>[0];
|
|
8
|
+
config: Parameters<typeof quoteWithLog>[1];
|
|
9
|
+
};
|
|
10
|
+
type GetQuoteReturnType = Quote;
|
|
11
|
+
type GetQuoteErrorType = QuoteError | JSONRPCErrorType;
|
|
12
|
+
declare function getQuote(params: GetQuoteParams): Promise<GetQuoteReturnType>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { GetQuoteErrorType, GetQuoteParams, GetQuoteReturnType, getQuote };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { assert } from "../utils/assert.js";
|
|
2
|
+
import { QuoteError } from "./errors/quote.js";
|
|
3
|
+
import { quoteWithLog } from "./utils/quoteWithLog.js";
|
|
4
|
+
|
|
5
|
+
//#region src/solverRelay/getQuote.ts
|
|
6
|
+
async function getQuote(params) {
|
|
7
|
+
return handleQuoteResult(await quoteWithLog(params.quoteParams, {
|
|
8
|
+
timeout: (params.quoteParams?.wait_ms ?? 0) + 1e4,
|
|
9
|
+
...params.config
|
|
10
|
+
}), params.quoteParams, params.config.logger);
|
|
11
|
+
}
|
|
12
|
+
function handleQuoteResult(result, quoteParams, logger) {
|
|
13
|
+
if (result == null) throw new QuoteError({
|
|
14
|
+
quote: null,
|
|
15
|
+
quoteParams
|
|
16
|
+
});
|
|
17
|
+
const hasExactIn = quoteParams.exact_amount_in != null;
|
|
18
|
+
assert(hasExactIn !== (quoteParams.exact_amount_out != null), `Invalid quoteParams: exactly one of exact_amount_in or exact_amount_out must be set (got exact_amount_in=${quoteParams.exact_amount_in}, exact_amount_out=${quoteParams.exact_amount_out}).`);
|
|
19
|
+
const quoteKind = hasExactIn ? "exact_in" : "exact_out";
|
|
20
|
+
const failedQuotes = [];
|
|
21
|
+
const validQuotes = [];
|
|
22
|
+
for (const q of result) {
|
|
23
|
+
if (!isValidQuote(q)) {
|
|
24
|
+
failedQuotes.push(q);
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (!matchesRequest(q, quoteParams)) {
|
|
28
|
+
logger?.warn("quote: dropping quote that doesn't match the request", {
|
|
29
|
+
quoteParams,
|
|
30
|
+
quote: q
|
|
31
|
+
});
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
validQuotes.push(q);
|
|
35
|
+
}
|
|
36
|
+
const bestQuote = sortQuotes(validQuotes, quoteKind)[0];
|
|
37
|
+
if (bestQuote != null) return bestQuote;
|
|
38
|
+
const failedQuote = failedQuotes[0];
|
|
39
|
+
if (failedQuote != null) throw new QuoteError({
|
|
40
|
+
quote: failedQuote,
|
|
41
|
+
quoteParams
|
|
42
|
+
});
|
|
43
|
+
throw new QuoteError({
|
|
44
|
+
quote: null,
|
|
45
|
+
quoteParams
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function sortQuotes(quotes, quoteKind) {
|
|
49
|
+
return quotes.slice().sort((a, b) => {
|
|
50
|
+
if (quoteKind === "exact_in") {
|
|
51
|
+
if (BigInt(a.amount_out) > BigInt(b.amount_out)) return -1;
|
|
52
|
+
if (BigInt(a.amount_out) < BigInt(b.amount_out)) return 1;
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
|
55
|
+
if (BigInt(a.amount_in) < BigInt(b.amount_in)) return -1;
|
|
56
|
+
if (BigInt(a.amount_in) > BigInt(b.amount_in)) return 1;
|
|
57
|
+
return 0;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function isValidQuote(quote) {
|
|
61
|
+
return !("type" in quote);
|
|
62
|
+
}
|
|
63
|
+
function matchesRequest(quote, quoteParams) {
|
|
64
|
+
if (quote.defuse_asset_identifier_in !== quoteParams.defuse_asset_identifier_in || quote.defuse_asset_identifier_out !== quoteParams.defuse_asset_identifier_out) return false;
|
|
65
|
+
if (quoteParams.exact_amount_in != null) return BigInt(quote.amount_in) === BigInt(quoteParams.exact_amount_in);
|
|
66
|
+
return BigInt(quote.amount_out) === BigInt(quoteParams.exact_amount_out);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
export { getQuote };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const require_assert = require('../utils/assert.cjs');
|
|
2
|
+
const require_apis = require('./solverRelayHttpClient/apis.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/solverRelay/getStatus.ts
|
|
5
|
+
async function getStatus(...args) {
|
|
6
|
+
return require_apis.getStatus(...args).then((response) => {
|
|
7
|
+
const status = response.status;
|
|
8
|
+
switch (status) {
|
|
9
|
+
case "SETTLED":
|
|
10
|
+
case "TX_BROADCASTED": return {
|
|
11
|
+
status,
|
|
12
|
+
intentHash: response.intent_hash,
|
|
13
|
+
txHash: response.data.hash
|
|
14
|
+
};
|
|
15
|
+
case "PENDING":
|
|
16
|
+
case "NOT_FOUND_OR_NOT_VALID": return {
|
|
17
|
+
status,
|
|
18
|
+
intentHash: response.intent_hash
|
|
19
|
+
};
|
|
20
|
+
default: require_assert.assert(false, `Unexpected intent status = ${status}`);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.getStatus = getStatus;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { JSONRPCErrorType } from "./solverRelayHttpClient/types.cjs";
|
|
2
|
+
import { getStatus as getStatus$1 } from "./solverRelayHttpClient/apis.cjs";
|
|
3
|
+
import { AssertionErrorType } from "../errors/assert.cjs";
|
|
4
|
+
|
|
5
|
+
//#region src/solverRelay/getStatus.d.ts
|
|
6
|
+
type GetStatusReturnType = {
|
|
7
|
+
status: "PENDING" | "NOT_FOUND_OR_NOT_VALID";
|
|
8
|
+
intentHash: string;
|
|
9
|
+
} | {
|
|
10
|
+
status: "TX_BROADCASTED" | "SETTLED";
|
|
11
|
+
intentHash: string;
|
|
12
|
+
txHash: string;
|
|
13
|
+
};
|
|
14
|
+
type GetStatusErrorType = JSONRPCErrorType | AssertionErrorType;
|
|
15
|
+
declare function getStatus(...args: Parameters<typeof getStatus$1>): Promise<GetStatusReturnType>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { GetStatusErrorType, GetStatusReturnType, getStatus };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { JSONRPCErrorType } from "./solverRelayHttpClient/types.js";
|
|
2
|
+
import { getStatus as getStatus$1 } from "./solverRelayHttpClient/apis.js";
|
|
3
|
+
import "./solverRelayHttpClient/index.js";
|
|
4
|
+
import { AssertionErrorType } from "../errors/assert.js";
|
|
5
|
+
|
|
6
|
+
//#region src/solverRelay/getStatus.d.ts
|
|
7
|
+
type GetStatusReturnType = {
|
|
8
|
+
status: "PENDING" | "NOT_FOUND_OR_NOT_VALID";
|
|
9
|
+
intentHash: string;
|
|
10
|
+
} | {
|
|
11
|
+
status: "TX_BROADCASTED" | "SETTLED";
|
|
12
|
+
intentHash: string;
|
|
13
|
+
txHash: string;
|
|
14
|
+
};
|
|
15
|
+
type GetStatusErrorType = JSONRPCErrorType | AssertionErrorType;
|
|
16
|
+
declare function getStatus(...args: Parameters<typeof getStatus$1>): Promise<GetStatusReturnType>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { GetStatusErrorType, GetStatusReturnType, getStatus };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { assert } from "../utils/assert.js";
|
|
2
|
+
import { getStatus as getStatus$1 } from "./solverRelayHttpClient/apis.js";
|
|
3
|
+
|
|
4
|
+
//#region src/solverRelay/getStatus.ts
|
|
5
|
+
async function getStatus(...args) {
|
|
6
|
+
return getStatus$1(...args).then((response) => {
|
|
7
|
+
const status = response.status;
|
|
8
|
+
switch (status) {
|
|
9
|
+
case "SETTLED":
|
|
10
|
+
case "TX_BROADCASTED": return {
|
|
11
|
+
status,
|
|
12
|
+
intentHash: response.intent_hash,
|
|
13
|
+
txHash: response.data.hash
|
|
14
|
+
};
|
|
15
|
+
case "PENDING":
|
|
16
|
+
case "NOT_FOUND_OR_NOT_VALID": return {
|
|
17
|
+
status,
|
|
18
|
+
intentHash: response.intent_hash
|
|
19
|
+
};
|
|
20
|
+
default: assert(false, `Unexpected intent status = ${status}`);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { getStatus };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_apis = require('./solverRelayHttpClient/apis.cjs');
|
|
3
|
+
const require_index = require('./solverRelayHttpClient/index.cjs');
|
|
4
|
+
const require_getQuote = require('./getQuote.cjs');
|
|
5
|
+
const require_getStatus = require('./getStatus.cjs');
|
|
6
|
+
const require_publishIntents = require('./publishIntents.cjs');
|
|
7
|
+
const require_waitForIntentSettlement = require('./waitForIntentSettlement.cjs');
|
|
8
|
+
const require_publishIntent = require('./publishIntent.cjs');
|
|
9
|
+
|
|
10
|
+
//#region src/solverRelay/index.ts
|
|
11
|
+
var solverRelay_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
12
|
+
getQuote: () => require_getQuote.getQuote,
|
|
13
|
+
getStatus: () => require_getStatus.getStatus,
|
|
14
|
+
httpClient: () => require_index.solverRelayHttpClient_exports,
|
|
15
|
+
publishIntent: () => require_publishIntent.publishIntent,
|
|
16
|
+
publishIntents: () => require_publishIntents.publishIntents,
|
|
17
|
+
quote: () => require_apis.quote,
|
|
18
|
+
waitForIntentSettlement: () => require_waitForIntentSettlement.waitForIntentSettlement
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
Object.defineProperty(exports, 'solverRelay_exports', {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () {
|
|
25
|
+
return solverRelay_exports;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FailedQuote, Params, PublishIntentRequest, Quote } from "./solverRelayHttpClient/types.cjs";
|
|
2
|
+
import { quote } from "./solverRelayHttpClient/apis.cjs";
|
|
3
|
+
import { index_d_exports as index_d_exports$1 } from "./solverRelayHttpClient/index.cjs";
|
|
4
|
+
import { GetQuoteErrorType, GetQuoteParams, GetQuoteReturnType, getQuote } from "./getQuote.cjs";
|
|
5
|
+
import { GetStatusErrorType, GetStatusReturnType, getStatus } from "./getStatus.cjs";
|
|
6
|
+
import { PublishIntentsErrorType, PublishIntentsReturnType, publishIntents } from "./publishIntents.cjs";
|
|
7
|
+
import { IntentSettlementError } from "./errors/intentSettlement.cjs";
|
|
8
|
+
import { IntentSettlementCallbacks, WaitForIntentSettlementErrorType, WaitForIntentSettlementReturnType, waitForIntentSettlement } from "./waitForIntentSettlement.cjs";
|
|
9
|
+
import { PublishIntentErrorType, PublishIntentReturnType, publishIntent } from "./publishIntent.cjs";
|
|
10
|
+
|
|
11
|
+
//#region src/solverRelay/index.d.ts
|
|
12
|
+
declare namespace index_d_exports {
|
|
13
|
+
export { FailedQuote, GetQuoteErrorType, GetQuoteParams, GetQuoteReturnType, GetStatusErrorType, GetStatusReturnType, IntentSettlementCallbacks, IntentSettlementError, Params, PublishIntentErrorType, PublishIntentRequest, PublishIntentReturnType, PublishIntentsErrorType, PublishIntentsReturnType, Quote, WaitForIntentSettlementErrorType, WaitForIntentSettlementReturnType, getQuote, getStatus, index_d_exports$1 as httpClient, publishIntent, publishIntents, quote, waitForIntentSettlement };
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { index_d_exports };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FailedQuote, Params, PublishIntentRequest, Quote } from "./solverRelayHttpClient/types.js";
|
|
2
|
+
import { quote } from "./solverRelayHttpClient/apis.js";
|
|
3
|
+
import { index_d_exports as index_d_exports$1 } from "./solverRelayHttpClient/index.js";
|
|
4
|
+
import { GetQuoteErrorType, GetQuoteParams, GetQuoteReturnType, getQuote } from "./getQuote.js";
|
|
5
|
+
import { GetStatusErrorType, GetStatusReturnType, getStatus } from "./getStatus.js";
|
|
6
|
+
import { PublishIntentsErrorType, PublishIntentsReturnType, publishIntents } from "./publishIntents.js";
|
|
7
|
+
import { IntentSettlementError } from "./errors/intentSettlement.js";
|
|
8
|
+
import { IntentSettlementCallbacks, WaitForIntentSettlementErrorType, WaitForIntentSettlementReturnType, waitForIntentSettlement } from "./waitForIntentSettlement.js";
|
|
9
|
+
import { PublishIntentErrorType, PublishIntentReturnType, publishIntent } from "./publishIntent.js";
|
|
10
|
+
|
|
11
|
+
//#region src/solverRelay/index.d.ts
|
|
12
|
+
declare namespace index_d_exports {
|
|
13
|
+
export { FailedQuote, GetQuoteErrorType, GetQuoteParams, GetQuoteReturnType, GetStatusErrorType, GetStatusReturnType, IntentSettlementCallbacks, IntentSettlementError, Params, PublishIntentErrorType, PublishIntentRequest, PublishIntentReturnType, PublishIntentsErrorType, PublishIntentsReturnType, Quote, WaitForIntentSettlementErrorType, WaitForIntentSettlementReturnType, getQuote, getStatus, index_d_exports$1 as httpClient, publishIntent, publishIntents, quote, waitForIntentSettlement };
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { index_d_exports };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/rolldown_runtime.js";
|
|
2
|
+
import { quote } from "./solverRelayHttpClient/apis.js";
|
|
3
|
+
import { solverRelayHttpClient_exports } from "./solverRelayHttpClient/index.js";
|
|
4
|
+
import { getQuote } from "./getQuote.js";
|
|
5
|
+
import { getStatus } from "./getStatus.js";
|
|
6
|
+
import { publishIntents } from "./publishIntents.js";
|
|
7
|
+
import { waitForIntentSettlement } from "./waitForIntentSettlement.js";
|
|
8
|
+
import { publishIntent } from "./publishIntent.js";
|
|
9
|
+
|
|
10
|
+
//#region src/solverRelay/index.ts
|
|
11
|
+
var solverRelay_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
+
getQuote: () => getQuote,
|
|
13
|
+
getStatus: () => getStatus,
|
|
14
|
+
httpClient: () => solverRelayHttpClient_exports,
|
|
15
|
+
publishIntent: () => publishIntent,
|
|
16
|
+
publishIntents: () => publishIntents,
|
|
17
|
+
quote: () => quote,
|
|
18
|
+
waitForIntentSettlement: () => waitForIntentSettlement
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { solverRelay_exports };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const require_assert = require('../utils/assert.cjs');
|
|
2
|
+
const require_prepareBroadcastRequest = require('../utils/prepareBroadcastRequest.cjs');
|
|
3
|
+
const require_publishIntents = require('./publishIntents.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/solverRelay/publishIntent.ts
|
|
6
|
+
function publishIntent(signatureData, userInfo, quoteHashes, config = {}) {
|
|
7
|
+
return require_publishIntents.publishIntents({
|
|
8
|
+
signed_datas: [require_prepareBroadcastRequest.prepareSwapSignedData(signatureData, userInfo)],
|
|
9
|
+
quote_hashes: quoteHashes
|
|
10
|
+
}, config).then((result) => {
|
|
11
|
+
return result.map((intentHashes) => {
|
|
12
|
+
const intentHash = intentHashes[0];
|
|
13
|
+
require_assert.assert(intentHash != null, "Should include at least one intent hash");
|
|
14
|
+
return intentHash;
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.publishIntent = publishIntent;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RequestConfig } from "./solverRelayHttpClient/types.cjs";
|
|
2
|
+
import { PublishIntentsErrorType, PublishIntentsReturnType } from "./publishIntents.cjs";
|
|
3
|
+
import { AuthMethod } from "../types/authHandle.cjs";
|
|
4
|
+
import { WalletSignatureResult } from "../types/walletMessage.cjs";
|
|
5
|
+
import { Result } from "@thames/monads";
|
|
6
|
+
|
|
7
|
+
//#region src/solverRelay/publishIntent.d.ts
|
|
8
|
+
type PublishIntentReturnType = PublishIntentsReturnType[number];
|
|
9
|
+
type PublishIntentErrorType = PublishIntentsErrorType;
|
|
10
|
+
declare function publishIntent(signatureData: WalletSignatureResult, userInfo: {
|
|
11
|
+
userAddress: string;
|
|
12
|
+
userChainType: AuthMethod;
|
|
13
|
+
}, quoteHashes: string[], config?: RequestConfig): Promise<Result<PublishIntentReturnType, PublishIntentErrorType>>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { PublishIntentErrorType, PublishIntentReturnType, publishIntent };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RequestConfig } from "./solverRelayHttpClient/types.js";
|
|
2
|
+
import { PublishIntentsErrorType, PublishIntentsReturnType } from "./publishIntents.js";
|
|
3
|
+
import { AuthMethod } from "../types/authHandle.js";
|
|
4
|
+
import { WalletSignatureResult } from "../types/walletMessage.js";
|
|
5
|
+
import "../index.js";
|
|
6
|
+
import { Result } from "@thames/monads";
|
|
7
|
+
|
|
8
|
+
//#region src/solverRelay/publishIntent.d.ts
|
|
9
|
+
type PublishIntentReturnType = PublishIntentsReturnType[number];
|
|
10
|
+
type PublishIntentErrorType = PublishIntentsErrorType;
|
|
11
|
+
declare function publishIntent(signatureData: WalletSignatureResult, userInfo: {
|
|
12
|
+
userAddress: string;
|
|
13
|
+
userChainType: AuthMethod;
|
|
14
|
+
}, quoteHashes: string[], config?: RequestConfig): Promise<Result<PublishIntentReturnType, PublishIntentErrorType>>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { PublishIntentErrorType, PublishIntentReturnType, publishIntent };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { assert } from "../utils/assert.js";
|
|
2
|
+
import { prepareSwapSignedData } from "../utils/prepareBroadcastRequest.js";
|
|
3
|
+
import { publishIntents } from "./publishIntents.js";
|
|
4
|
+
|
|
5
|
+
//#region src/solverRelay/publishIntent.ts
|
|
6
|
+
function publishIntent(signatureData, userInfo, quoteHashes, config = {}) {
|
|
7
|
+
return publishIntents({
|
|
8
|
+
signed_datas: [prepareSwapSignedData(signatureData, userInfo)],
|
|
9
|
+
quote_hashes: quoteHashes
|
|
10
|
+
}, config).then((result) => {
|
|
11
|
+
return result.map((intentHashes) => {
|
|
12
|
+
const intentHash = intentHashes[0];
|
|
13
|
+
assert(intentHash != null, "Should include at least one intent hash");
|
|
14
|
+
return intentHash;
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { publishIntent };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_apis = require('./solverRelayHttpClient/apis.cjs');
|
|
3
|
+
const require_parseFailedPublishError = require('./utils/parseFailedPublishError.cjs');
|
|
4
|
+
let _thames_monads = require("@thames/monads");
|
|
5
|
+
|
|
6
|
+
//#region src/solverRelay/publishIntents.ts
|
|
7
|
+
async function publishIntents(...args) {
|
|
8
|
+
const [params, requestConfig] = args;
|
|
9
|
+
return require_apis.publishIntents(params, {
|
|
10
|
+
timeout: 3e4,
|
|
11
|
+
...requestConfig,
|
|
12
|
+
retryOptions: {
|
|
13
|
+
delay: 1e3,
|
|
14
|
+
factor: 1.5,
|
|
15
|
+
maxAttempts: 7,
|
|
16
|
+
jitter: true,
|
|
17
|
+
minDelay: 1e3
|
|
18
|
+
}
|
|
19
|
+
}).then((response) => {
|
|
20
|
+
return parsePublishIntentsResponse(params, response);
|
|
21
|
+
}, (err) => {
|
|
22
|
+
return (0, _thames_monads.Err)(new require_parseFailedPublishError.RelayPublishResultUnknownError({
|
|
23
|
+
reason: "Failed to receive a usable publish response from the relay. Publish result is unknown.",
|
|
24
|
+
publishParams: params,
|
|
25
|
+
cause: err
|
|
26
|
+
}));
|
|
27
|
+
}).then((result) => {
|
|
28
|
+
if (result.isErr()) {
|
|
29
|
+
const err = result.unwrapErr();
|
|
30
|
+
args[1]?.logger?.error(err);
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function parsePublishIntentsResponse(publishParams, response) {
|
|
36
|
+
if (response.status === "OK") return (0, _thames_monads.Ok)(response.intent_hashes);
|
|
37
|
+
if (response.reason === "already processed") return (0, _thames_monads.Ok)(response.intent_hashes);
|
|
38
|
+
return (0, _thames_monads.Err)(require_parseFailedPublishError.toRelayPublishError(publishParams, response));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
exports.publishIntents = publishIntents;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { publishIntents as publishIntents$1 } from "./solverRelayHttpClient/apis.cjs";
|
|
2
|
+
import { RelayPublishErrorType } from "./utils/parseFailedPublishError.cjs";
|
|
3
|
+
import { Result } from "@thames/monads";
|
|
4
|
+
|
|
5
|
+
//#region src/solverRelay/publishIntents.d.ts
|
|
6
|
+
declare function publishIntents(...args: Parameters<typeof publishIntents$1>): Promise<Result<PublishIntentsReturnType, PublishIntentsErrorType>>;
|
|
7
|
+
type PublishIntentsReturnType = string[];
|
|
8
|
+
type PublishIntentsErrorType = RelayPublishErrorType;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { PublishIntentsErrorType, PublishIntentsReturnType, publishIntents };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { publishIntents as publishIntents$1 } from "./solverRelayHttpClient/apis.js";
|
|
2
|
+
import "./solverRelayHttpClient/index.js";
|
|
3
|
+
import { RelayPublishErrorType } from "./utils/parseFailedPublishError.js";
|
|
4
|
+
import { Result } from "@thames/monads";
|
|
5
|
+
|
|
6
|
+
//#region src/solverRelay/publishIntents.d.ts
|
|
7
|
+
declare function publishIntents(...args: Parameters<typeof publishIntents$1>): Promise<Result<PublishIntentsReturnType, PublishIntentsErrorType>>;
|
|
8
|
+
type PublishIntentsReturnType = string[];
|
|
9
|
+
type PublishIntentsErrorType = RelayPublishErrorType;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { PublishIntentsErrorType, PublishIntentsReturnType, publishIntents };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { publishIntents as publishIntents$1 } from "./solverRelayHttpClient/apis.js";
|
|
2
|
+
import { RelayPublishResultUnknownError, toRelayPublishError } from "./utils/parseFailedPublishError.js";
|
|
3
|
+
import { Err, Ok } from "@thames/monads";
|
|
4
|
+
|
|
5
|
+
//#region src/solverRelay/publishIntents.ts
|
|
6
|
+
async function publishIntents(...args) {
|
|
7
|
+
const [params, requestConfig] = args;
|
|
8
|
+
return publishIntents$1(params, {
|
|
9
|
+
timeout: 3e4,
|
|
10
|
+
...requestConfig,
|
|
11
|
+
retryOptions: {
|
|
12
|
+
delay: 1e3,
|
|
13
|
+
factor: 1.5,
|
|
14
|
+
maxAttempts: 7,
|
|
15
|
+
jitter: true,
|
|
16
|
+
minDelay: 1e3
|
|
17
|
+
}
|
|
18
|
+
}).then((response) => {
|
|
19
|
+
return parsePublishIntentsResponse(params, response);
|
|
20
|
+
}, (err) => {
|
|
21
|
+
return Err(new RelayPublishResultUnknownError({
|
|
22
|
+
reason: "Failed to receive a usable publish response from the relay. Publish result is unknown.",
|
|
23
|
+
publishParams: params,
|
|
24
|
+
cause: err
|
|
25
|
+
}));
|
|
26
|
+
}).then((result) => {
|
|
27
|
+
if (result.isErr()) {
|
|
28
|
+
const err = result.unwrapErr();
|
|
29
|
+
args[1]?.logger?.error(err);
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function parsePublishIntentsResponse(publishParams, response) {
|
|
35
|
+
if (response.status === "OK") return Ok(response.intent_hashes);
|
|
36
|
+
if (response.reason === "already processed") return Ok(response.intent_hashes);
|
|
37
|
+
return Err(toRelayPublishError(publishParams, response));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { publishIntents };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const require_runtime = require('./runtime.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/solverRelay/solverRelayHttpClient/apis.ts
|
|
4
|
+
async function quote(params, config = {}) {
|
|
5
|
+
return await require_runtime.jsonRPCRequest("quote", params, config);
|
|
6
|
+
}
|
|
7
|
+
async function publishIntent(params, config = {}) {
|
|
8
|
+
return await require_runtime.jsonRPCRequest("publish_intent", params, config);
|
|
9
|
+
}
|
|
10
|
+
async function publishIntents(params, config = {}) {
|
|
11
|
+
return await require_runtime.jsonRPCRequest("publish_intents", params, config);
|
|
12
|
+
}
|
|
13
|
+
async function getStatus(params, config = {}) {
|
|
14
|
+
return await require_runtime.jsonRPCRequest("get_status", params, config);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.getStatus = getStatus;
|
|
19
|
+
exports.publishIntent = publishIntent;
|
|
20
|
+
exports.publishIntents = publishIntents;
|
|
21
|
+
exports.quote = quote;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GetStatusRequest, GetStatusResponse, PublishIntentRequest, PublishIntentResponse, PublishIntentsRequest, PublishIntentsResponse, QuoteRequest, QuoteResponse, RequestConfig } from "./types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/solverRelay/solverRelayHttpClient/apis.d.ts
|
|
4
|
+
declare function quote(params: QuoteRequest["params"][0], config?: RequestConfig): Promise<QuoteResponse["result"]>;
|
|
5
|
+
declare function publishIntent(params: PublishIntentRequest["params"][0], config?: RequestConfig): Promise<PublishIntentResponse["result"]>;
|
|
6
|
+
declare function publishIntents(params: PublishIntentsRequest["params"][0], config?: RequestConfig): Promise<PublishIntentsResponse["result"]>;
|
|
7
|
+
declare function getStatus(params: GetStatusRequest["params"][0], config?: RequestConfig): Promise<GetStatusResponse["result"]>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { getStatus, publishIntent, publishIntents, quote };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GetStatusRequest, GetStatusResponse, PublishIntentRequest, PublishIntentResponse, PublishIntentsRequest, PublishIntentsResponse, QuoteRequest, QuoteResponse, RequestConfig } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/solverRelay/solverRelayHttpClient/apis.d.ts
|
|
4
|
+
declare function quote(params: QuoteRequest["params"][0], config?: RequestConfig): Promise<QuoteResponse["result"]>;
|
|
5
|
+
declare function publishIntent(params: PublishIntentRequest["params"][0], config?: RequestConfig): Promise<PublishIntentResponse["result"]>;
|
|
6
|
+
declare function publishIntents(params: PublishIntentsRequest["params"][0], config?: RequestConfig): Promise<PublishIntentsResponse["result"]>;
|
|
7
|
+
declare function getStatus(params: GetStatusRequest["params"][0], config?: RequestConfig): Promise<GetStatusResponse["result"]>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { getStatus, publishIntent, publishIntents, quote };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsonRPCRequest } from "./runtime.js";
|
|
2
|
+
|
|
3
|
+
//#region src/solverRelay/solverRelayHttpClient/apis.ts
|
|
4
|
+
async function quote(params, config = {}) {
|
|
5
|
+
return await jsonRPCRequest("quote", params, config);
|
|
6
|
+
}
|
|
7
|
+
async function publishIntent(params, config = {}) {
|
|
8
|
+
return await jsonRPCRequest("publish_intent", params, config);
|
|
9
|
+
}
|
|
10
|
+
async function publishIntents(params, config = {}) {
|
|
11
|
+
return await jsonRPCRequest("publish_intents", params, config);
|
|
12
|
+
}
|
|
13
|
+
async function getStatus(params, config = {}) {
|
|
14
|
+
return await jsonRPCRequest("get_status", params, config);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { getStatus, publishIntent, publishIntents, quote };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_apis = require('./apis.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/solverRelay/solverRelayHttpClient/index.ts
|
|
5
|
+
var solverRelayHttpClient_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
6
|
+
getStatus: () => require_apis.getStatus,
|
|
7
|
+
publishIntent: () => require_apis.publishIntent,
|
|
8
|
+
publishIntents: () => require_apis.publishIntents,
|
|
9
|
+
quote: () => require_apis.quote
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
Object.defineProperty(exports, 'solverRelayHttpClient_exports', {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return solverRelayHttpClient_exports;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FailedQuote, GetStatusRequest, GetStatusResponse, JSONRPCErrorType, JSONRPCRequest, JSONRPCResponse, Params, PublishIntentRequest, PublishIntentResponse, PublishIntentResponseFailure, PublishIntentResponseSuccess, PublishIntentsRequest, PublishIntentsResponse, PublishIntentsResponseFailure, PublishIntentsResponseSuccess, Quote, QuoteRequest, QuoteResponse, RequestConfig } from "./types.cjs";
|
|
2
|
+
import { getStatus, publishIntent, publishIntents, quote } from "./apis.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/solverRelay/solverRelayHttpClient/index.d.ts
|
|
5
|
+
declare namespace index_d_exports {
|
|
6
|
+
export { FailedQuote, GetStatusRequest, GetStatusResponse, JSONRPCErrorType, JSONRPCRequest, JSONRPCResponse, Params, PublishIntentRequest, PublishIntentResponse, PublishIntentResponseFailure, PublishIntentResponseSuccess, PublishIntentsRequest, PublishIntentsResponse, PublishIntentsResponseFailure, PublishIntentsResponseSuccess, Quote, QuoteRequest, QuoteResponse, RequestConfig, getStatus, publishIntent, publishIntents, quote };
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { index_d_exports };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FailedQuote, GetStatusRequest, GetStatusResponse, JSONRPCErrorType, JSONRPCRequest, JSONRPCResponse, Params, PublishIntentRequest, PublishIntentResponse, PublishIntentResponseFailure, PublishIntentResponseSuccess, PublishIntentsRequest, PublishIntentsResponse, PublishIntentsResponseFailure, PublishIntentsResponseSuccess, Quote, QuoteRequest, QuoteResponse, RequestConfig } from "./types.js";
|
|
2
|
+
import { getStatus, publishIntent, publishIntents, quote } from "./apis.js";
|
|
3
|
+
|
|
4
|
+
//#region src/solverRelay/solverRelayHttpClient/index.d.ts
|
|
5
|
+
declare namespace index_d_exports {
|
|
6
|
+
export { FailedQuote, GetStatusRequest, GetStatusResponse, JSONRPCErrorType, JSONRPCRequest, JSONRPCResponse, Params, PublishIntentRequest, PublishIntentResponse, PublishIntentResponseFailure, PublishIntentResponseSuccess, PublishIntentsRequest, PublishIntentsResponse, PublishIntentsResponseFailure, PublishIntentsResponseSuccess, Quote, QuoteRequest, QuoteResponse, RequestConfig, getStatus, publishIntent, publishIntents, quote };
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { index_d_exports };
|