@pegaroute/sdk 0.0.0-stage → 0.1.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.
@@ -0,0 +1,64 @@
1
+ //#region src/types/status.ts
2
+ /** How each internal status maps to the public one (mirrors Pegaroute's own mapping). */
3
+ const EXTERNAL_STATUS_BY_INTERNAL = {
4
+ pending: "pending",
5
+ submitted: "executing",
6
+ executing: "executing",
7
+ confirming: "executing",
8
+ completed: "success",
9
+ failed: "fail",
10
+ refunded: "fail"
11
+ };
12
+ /** Statuses a swap never leaves, in both sets. The two sets share only `pending` and `executing`, which are not terminal. */
13
+ const TERMINAL_STATUSES = /* @__PURE__ */ new Set([
14
+ "success",
15
+ "fail",
16
+ "completed",
17
+ "failed",
18
+ "refunded"
19
+ ]);
20
+ /**
21
+ * Converts an internal status to the public one.
22
+ *
23
+ * @example
24
+ * toExternalStatus("submitted"); // "executing"
25
+ * toExternalStatus("refunded"); // "fail" — check the swap's `refund` for details
26
+ */
27
+ function toExternalStatus(status) {
28
+ return EXTERNAL_STATUS_BY_INTERNAL[status];
29
+ }
30
+ /**
31
+ * Whether a swap in this status is finished and will not change status again. Accepts either status set.
32
+ *
33
+ * A `refunded` swap's `refund` object may still progress (e.g. `pending` → `completed`) after this returns `true`.
34
+ */
35
+ function isTerminalStatus(status) {
36
+ return TERMINAL_STATUSES.has(status);
37
+ }
38
+ //#endregion
39
+ //#region src/types/execution.ts
40
+ /**
41
+ * Narrows an execution to the variants of one mode, whatever the family.
42
+ * Within a single family, a `switch` on `mode` is usually clearer.
43
+ *
44
+ * @example
45
+ * if (isExecutionMode(execution, "deposit-transfer")) {
46
+ * showDepositAddress(execution.to, execution.amount.display, execution.memo); // any chain
47
+ * }
48
+ */
49
+ function isExecutionMode(execution, mode) {
50
+ return execution.mode === mode;
51
+ }
52
+ /**
53
+ * Narrows an execution to the variants of one family.
54
+ *
55
+ * @example
56
+ * if (isExecutionFamily(execution, "evm")) {
57
+ * // execution.mode is "contract-call" | "native-transfer" | "erc20-transfer"
58
+ * }
59
+ */
60
+ function isExecutionFamily(execution, family) {
61
+ return execution.family === family;
62
+ }
63
+ //#endregion
64
+ export { toExternalStatus as i, isExecutionMode as n, isTerminalStatus as r, isExecutionFamily as t };
@@ -0,0 +1,2 @@
1
+ import { $ as KnownErrorCode, A as toExternalStatus, B as JsonSwapExecution, C as SwapInput, Ct as Token, D as InternalSwapStatus, E as SwapTimestamps, F as EvmSwapExecution, G as UtxoSwapExecution, H as OtherDepositSwapExecution, I as ExecutionFamily, J as GetQuoteParams, K as isExecutionFamily, L as ExecutionMode, M as CosmosMsgDepositSwapExecution, N as CosmosMsgExecuteSwapExecution, O as SwapStatus, P as EvmApproval, Q as ErrorCode, R as ExecutionOfFamily, S as SwapFailure, St as ProvidersResponse, T as SwapProviderInfo, U as SerializedSwapExecution, V as NamedDepositSwapExecution, W as SwapExecution, X as QuoteRoute, Y as QuoteResponse, Z as RouteWarning, _ as ProviderStatusInfo, _t as ProviderFeeStructure, a as WebhookEvent, at as QuoteFees, b as SwapEvent, bt as ProviderTakeStructure, c as ExpectedAffiliateEntry, ct as StreamingProgress, d as TransactionsResponse, dt as ChainsResponse, et as AffiliateFeeBreakdown, f as CreateSwapParams, ft as HealthResponse, g as InstaswapSwapLiteSnapshot, gt as ProviderAffiliateFeeStructure, h as InstaswapFeeLine, ht as PingResponse, i as TransactionWebhookEventType, it as Provider, j as CosmosBankSendSwapExecution, k as isTerminalStatus, l as ListTransactionsParams, lt as TokenAmount, m as GetSwapResponse, mt as ListProvidersParams, n as TransactionWebhookData, nt as OpenOceanRouteMeta, o as WebhookStreamingProgress, ot as RefundInfo, p as CreateSwapResponse, pt as KnownProviderType, q as isExecutionMode, r as TransactionWebhookEvent, rt as PrivateSwapMode, s as CursorPagination, st as RouteInfo, t as TestWebhookEvent, tt as KnownProvider, u as Transaction, ut as Chain, v as SubmitTxHashParams, vt as ProviderHealth, w as SwapOutput, wt as TokensResponse, x as SwapEventsResponse, xt as ProviderType, y as SubmitTxHashResponse, yt as ProviderInfo, z as ExecutionOfMode } from "./index-CeY_5Z4u.js";
2
+ export { type AffiliateFeeBreakdown, type Chain, type ChainsResponse, type CosmosBankSendSwapExecution, type CosmosMsgDepositSwapExecution, type CosmosMsgExecuteSwapExecution, type CreateSwapParams, type CreateSwapResponse, type CursorPagination, type ErrorCode, type EvmApproval, type EvmSwapExecution, type ExecutionFamily, type ExecutionMode, type ExecutionOfFamily, type ExecutionOfMode, type ExpectedAffiliateEntry, type GetQuoteParams, type GetSwapResponse, type HealthResponse, type InstaswapFeeLine, type InstaswapSwapLiteSnapshot, type InternalSwapStatus, type JsonSwapExecution, type KnownErrorCode, type KnownProvider, type KnownProviderType, type ListProvidersParams, type ListTransactionsParams, type NamedDepositSwapExecution, type OpenOceanRouteMeta, type OtherDepositSwapExecution, type PingResponse, type PrivateSwapMode, type Provider, type ProviderAffiliateFeeStructure, type ProviderFeeStructure, type ProviderHealth, type ProviderInfo, type ProviderStatusInfo, type ProviderTakeStructure, type ProviderType, type ProvidersResponse, type QuoteFees, type QuoteResponse, type QuoteRoute, type RefundInfo, type RouteInfo, type RouteWarning, type SerializedSwapExecution, type StreamingProgress, type SubmitTxHashParams, type SubmitTxHashResponse, type SwapEvent, type SwapEventsResponse, type SwapExecution, type SwapFailure, type SwapInput, type SwapOutput, type SwapProviderInfo, type SwapStatus, type SwapTimestamps, type TestWebhookEvent, type Token, type TokenAmount, type TokensResponse, type Transaction, type TransactionWebhookData, type TransactionWebhookEvent, type TransactionWebhookEventType, type TransactionsResponse, type UtxoSwapExecution, type WebhookEvent, type WebhookStreamingProgress, isExecutionFamily, isExecutionMode, isTerminalStatus, toExternalStatus };
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ import { i as toExternalStatus, n as isExecutionMode, r as isTerminalStatus, t as isExecutionFamily } from "./types-Cz8gDMIR.js";
2
+ export { isExecutionFamily, isExecutionMode, isTerminalStatus, toExternalStatus };
package/package.json CHANGED
@@ -1,6 +1,65 @@
1
1
  {
2
2
  "name": "@pegaroute/sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK for the Pegaroute cross-chain swap API",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/SimplyStaking/pegaroute-sdk.git"
10
+ },
11
+ "engines": {
12
+ "node": ">=22.12"
13
+ },
14
+ "packageManager": "bun@1.2.22",
15
+ "sideEffects": false,
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "main": "./dist/index.js",
20
+ "types": "./dist/index.d.ts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "default": "./dist/index.js"
25
+ },
26
+ "./types": {
27
+ "types": "./dist/types.d.ts",
28
+ "default": "./dist/types.js"
29
+ },
30
+ "./package.json": "./package.json"
31
+ },
32
+ "typesVersions": {
33
+ "*": {
34
+ "types": [
35
+ "./dist/types.d.ts"
36
+ ]
37
+ }
38
+ },
39
+ "scripts": {
40
+ "build": "bun --bun tsdown",
41
+ "prepack": "bun run build",
42
+ "typecheck": "tsc --noEmit",
43
+ "typecheck:examples": "bun run build && tsc -p examples",
44
+ "lint": "biome check .",
45
+ "check:package": "bun run prepack && publint && attw --pack . --profile esm-only",
46
+ "format": "biome check --write .",
47
+ "test": "bun test",
48
+ "test:node": "bun run build && node --test \"test/node/*.node.mjs\"",
49
+ "test:e2e": "bun test --timeout 60000 --preload ./test/e2e/setup.ts ./test/e2e/*.e2e.ts",
50
+ "test:e2e:examples": "bun run build && bun test --timeout 60000 ./examples/examples.e2e.ts"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
55
+ "devDependencies": {
56
+ "@arethetypeswrong/cli": "^0.18.5",
57
+ "@biomejs/biome": "^2.5.14",
58
+ "@types/bun": "^1.4.2",
59
+ "hono": "^4.13.12",
60
+ "publint": "^0.3.25",
61
+ "tsdown": "^0.23.0",
62
+ "typescript": "^7.0.2",
63
+ "viem": "^2.57.2"
64
+ }
65
+ }