@recta/client 0.1.14 → 0.1.15
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/README.md +3 -0
- package/dist/constants.d.ts +2 -2
- package/dist/constants.js +1 -1
- package/dist/preflight.d.ts +5 -5
- package/dist/preflight.js +12 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -106,6 +106,9 @@ and nothing else about you. 20 free preflight checks a day per IP address.
|
|
|
106
106
|
signed: any case, `"Ethereum Mainnet"`, `"BSC"`, `"Arbitrum One"`, a chain ID such as `8453`, `"eip155:8453"`,
|
|
107
107
|
`"Tether"`, `"LI.FI"` (`networkKeyOf`, `assetKeyOf`, `providerKeyOf`, `readTransferNames`). A misspelt name is not
|
|
108
108
|
guessed before a signature; `preflight` sends it as written and the service reads it and says what it understood.
|
|
109
|
+
`preflight` needs only `source_network`, `destination_network` and `amount` (also as `from`, `to` and `value`): the
|
|
110
|
+
service reads USDC when no token is named (USDT from Tron), the same token on arrival when `destination_asset` is left
|
|
111
|
+
out, amounts such as `"1,000"`, `"1k"` or `"1000 USDC"`, and lists what it read, filled or set aside.
|
|
109
112
|
|
|
110
113
|
## Which route to declare
|
|
111
114
|
|
package/dist/constants.d.ts
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const RECTA_ORIGIN = "https://api.recta.build";
|
|
9
9
|
/** This package's version (equal to package.json, checked in CI). */
|
|
10
|
-
export declare const CLIENT_VERSION = "0.1.
|
|
10
|
+
export declare const CLIENT_VERSION = "0.1.15";
|
|
11
11
|
/** Sent on every request so Recta can count real use of this package apart from other clients (no address, no key). */
|
|
12
|
-
export declare const USER_AGENT = "recta-client/0.1.
|
|
12
|
+
export declare const USER_AGENT = "recta-client/0.1.15";
|
|
13
13
|
/** The fee: x402 `upto` on Base, a Permit2 `permitWitnessTransferFrom`. All lowercase. */
|
|
14
14
|
export declare const FEE_CHAIN_ID = 8453;
|
|
15
15
|
export declare const PERMIT2 = "0x000000000022d473030f116ddee9f6b43ac78ba3";
|
package/dist/constants.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export const RECTA_ORIGIN = "https://api.recta.build";
|
|
9
9
|
/** This package's version (equal to package.json, checked in CI). */
|
|
10
|
-
export const CLIENT_VERSION = "0.1.
|
|
10
|
+
export const CLIENT_VERSION = "0.1.15";
|
|
11
11
|
/** Sent on every request so Recta can count real use of this package apart from other clients (no address, no key). */
|
|
12
12
|
export const USER_AGENT = `recta-client/${CLIENT_VERSION}`;
|
|
13
13
|
/** The fee: x402 `upto` on Base, a Permit2 `permitWitnessTransferFrom`. All lowercase. */
|
package/dist/preflight.d.ts
CHANGED
|
@@ -7,15 +7,15 @@ import type { RectaAsset, RectaNetwork, RectaProvider } from "./names.js";
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const PREFLIGHT_PATH = "/v1/preflight";
|
|
9
9
|
/** Sent on every preflight this package makes, so Recta can count use of the wrapper apart from other clients. */
|
|
10
|
-
export declare const PREFLIGHT_USER_AGENT = "recta-client/0.1.
|
|
10
|
+
export declare const PREFLIGHT_USER_AGENT = "recta-client/0.1.15 (preflight)";
|
|
11
11
|
export interface PreflightTransfer {
|
|
12
12
|
/** Recta's network key (your editor lists them), or any name Recta reads: "Ethereum Mainnet", "BSC", 8453… */
|
|
13
13
|
readonly source_network: RectaNetwork | (string & {});
|
|
14
|
-
/** USDC, USDT… (or "usd coin", "tether"…) */
|
|
15
|
-
readonly source_asset
|
|
14
|
+
/** USDC, USDT… (or "usd coin", "tether"…). Optional: without it the preflight reads USDC (USDT from Tron). */
|
|
15
|
+
readonly source_asset?: RectaAsset | (string & {});
|
|
16
16
|
readonly destination_network: RectaNetwork | (string & {});
|
|
17
|
-
/** USDC, USDT…
|
|
18
|
-
readonly destination_asset
|
|
17
|
+
/** USDC, USDT… Optional: without it, the same token as source_asset. */
|
|
18
|
+
readonly destination_asset?: RectaAsset | (string & {});
|
|
19
19
|
/** Whole tokens: "1000" (or 1000) with USDC is 1,000 USDC. */
|
|
20
20
|
readonly amount: string | number | bigint;
|
|
21
21
|
/** The route you would use (one of RECTA_PROVIDER_KEYS). Absent: LI.FI, or Across where LI.FI does not apply. */
|
package/dist/preflight.js
CHANGED
|
@@ -9,7 +9,15 @@ import { PINNED_ROUTES } from "./pinned-routes.js";
|
|
|
9
9
|
export const PREFLIGHT_PATH = "/v1/preflight";
|
|
10
10
|
/** Sent on every preflight this package makes, so Recta can count use of the wrapper apart from other clients. */
|
|
11
11
|
export const PREFLIGHT_USER_AGENT = `recta-client/${CLIENT_VERSION} (preflight)`;
|
|
12
|
-
|
|
12
|
+
/** Only what the preflight cannot fill: it reads USDC (USDT from Tron) without a token and the same token on arrival
|
|
13
|
+
* without destination_asset, and says so in `assumed` (BIT-OPS-208). Other field names (from, to, token…) go as given:
|
|
14
|
+
* the preflight reads them and lists what it read. */
|
|
15
|
+
const REQUIRED_FIELDS = ["source_network", "destination_network", "amount"];
|
|
16
|
+
const OTHER_NAMES = {
|
|
17
|
+
source_network: ["from", "fromChain", "from_chain", "source_chain", "sourceChain", "origin"],
|
|
18
|
+
destination_network: ["to", "toChain", "to_chain", "destination_chain", "destinationChain", "destination"],
|
|
19
|
+
amount: ["value", "quantity", "qty"],
|
|
20
|
+
};
|
|
13
21
|
const FIELD_ALIASES = {
|
|
14
22
|
sourceNetwork: "source_network",
|
|
15
23
|
sourceAsset: "source_asset",
|
|
@@ -26,8 +34,8 @@ export class PreflightInputError extends Error {
|
|
|
26
34
|
...(missing.length > 0 ? [`needs ${missing.join(", ")}`] : []),
|
|
27
35
|
...(invalid.length > 0 ? [`cannot send ${invalid.join("; ")}`] : []),
|
|
28
36
|
];
|
|
29
|
-
super(`Recta Preflight ${parts.join(" and ")}. Pass { source_network: "base", source_asset: "USDC", destination_network: "arbitrum",
|
|
30
|
-
`(
|
|
37
|
+
super(`Recta Preflight ${parts.join(" and ")}. Pass { source_network: "base", source_asset: "USDC", destination_network: "arbitrum", amount: "1000" } ` +
|
|
38
|
+
`(networks and tokens by any common name; amount in whole tokens, e.g. 1000, "1,000" or "1k"; destination_asset defaults to the same token), or build it with lifiTransfer() / transferFromChainTokens().`);
|
|
31
39
|
this.missing = missing;
|
|
32
40
|
this.invalid = invalid;
|
|
33
41
|
this.name = "PreflightInputError";
|
|
@@ -74,7 +82,7 @@ export function preflightBody(transfer) {
|
|
|
74
82
|
else
|
|
75
83
|
body[key] = read.value;
|
|
76
84
|
}
|
|
77
|
-
const missing = REQUIRED_FIELDS.filter((k) => body[k] === undefined && !invalid.some((i) => i.startsWith(`${k} `)));
|
|
85
|
+
const missing = REQUIRED_FIELDS.filter((k) => body[k] === undefined && !(OTHER_NAMES[k] ?? []).some((n) => body[n] !== undefined) && !invalid.some((i) => i.startsWith(`${k} `)));
|
|
78
86
|
return { body, missing, invalid };
|
|
79
87
|
}
|
|
80
88
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@recta/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"description": "Client for Recta (api.recta.build): evaluate a cross-chain stablecoin transfer, authorize Recta's 5 %-of-verified-saving fee, execute the committed route and report it, with local checks before every signature.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Recta (https://recta.build)",
|