@spicenet-io/spiceflow-core 0.1.0 → 0.1.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/authorization.d.ts +58 -0
- package/dist/authorization.d.ts.map +1 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/core.d.ts +61 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/http.d.ts +17 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/index.cjs +226 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +191 -0
- package/dist/relayer.d.ts +31 -0
- package/dist/relayer.d.ts.map +1 -0
- package/dist/rfqt.d.ts +27 -0
- package/dist/rfqt.d.ts.map +1 -0
- package/dist/status.d.ts +17 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/types.d.ts +28 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Address, Hash, PublicClient } from "viem";
|
|
2
|
+
import type { ChainBatch, ChainBatchInput } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* ABI description of a single call in a chain batch.
|
|
5
|
+
*/
|
|
6
|
+
export declare const CallAbi: {
|
|
7
|
+
readonly type: "tuple";
|
|
8
|
+
readonly components: readonly [{
|
|
9
|
+
readonly name: "to";
|
|
10
|
+
readonly type: "address";
|
|
11
|
+
}, {
|
|
12
|
+
readonly name: "value";
|
|
13
|
+
readonly type: "uint";
|
|
14
|
+
}, {
|
|
15
|
+
readonly name: "data";
|
|
16
|
+
readonly type: "bytes";
|
|
17
|
+
}];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* ABI description of the per-chain signature components used by EIP‑7702
|
|
21
|
+
* to derive the chain authorization hash for a batch of calls.
|
|
22
|
+
*/
|
|
23
|
+
export declare const ChainBatchHashComponentsAbi: readonly [{
|
|
24
|
+
readonly name: "chainId";
|
|
25
|
+
readonly type: "uint256";
|
|
26
|
+
}, {
|
|
27
|
+
readonly type: "tuple[]";
|
|
28
|
+
readonly components: readonly [{
|
|
29
|
+
readonly name: "to";
|
|
30
|
+
readonly type: "address";
|
|
31
|
+
}, {
|
|
32
|
+
readonly name: "value";
|
|
33
|
+
readonly type: "uint";
|
|
34
|
+
}, {
|
|
35
|
+
readonly name: "data";
|
|
36
|
+
readonly type: "bytes";
|
|
37
|
+
}];
|
|
38
|
+
readonly name: "calls";
|
|
39
|
+
}];
|
|
40
|
+
/**
|
|
41
|
+
* Hash each chain's call batch into an EIP‑7702 chain authorization tuple.
|
|
42
|
+
*/
|
|
43
|
+
export declare function hashChainBatches(chainCalls: ChainBatchInput[]): ChainBatch[];
|
|
44
|
+
/**
|
|
45
|
+
* Compute the intent hash from an array of per-chain authorization hashes.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getIntentHash(nbf: bigint, exp: bigint, chainBatches: {
|
|
48
|
+
hash: Hash;
|
|
49
|
+
}[]): Hash;
|
|
50
|
+
/**
|
|
51
|
+
* Load the account nonce to be used when signing a chain delegation.
|
|
52
|
+
*/
|
|
53
|
+
export declare function getAccountNonce(address: Address, publicClient: PublicClient): Promise<number>;
|
|
54
|
+
/**
|
|
55
|
+
* Fetch a recent block number used as freshness bound for chain batches.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getRecentBlock(publicClient: PublicClient): Promise<bigint>;
|
|
58
|
+
//# sourceMappingURL=authorization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization.d.ts","sourceRoot":"","sources":["../src/authorization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAExD,OAAO,KAAK,EAAQ,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;CAOV,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;EAG9B,CAAC;AAEX;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,eAAe,EAAE,GAAG,UAAU,EAAE,CAU5E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,EAAE,GAAG,IAAI,CAG5F;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAEnG;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAEhF"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PublicClient } from "viem";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for the generic SpiceFlow core.
|
|
4
|
+
*
|
|
5
|
+
* Consumers provide factories/resolvers for chain-specific details
|
|
6
|
+
* (delegate contract, viem PublicClient, and API base URL).
|
|
7
|
+
*/
|
|
8
|
+
export interface SpiceFlowConfig {
|
|
9
|
+
txApiUrl: string;
|
|
10
|
+
delegateAddressForChain: (chainId: number) => `0x${string}`;
|
|
11
|
+
publicClientForChain: (chainId: number) => PublicClient;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,uBAAuB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,KAAK,MAAM,EAAE,CAAC;IAC5D,oBAAoB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,YAAY,CAAC;CACzD"}
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { PublicClient } from "viem";
|
|
2
|
+
import { hashChainBatches } from "./authorization.js";
|
|
3
|
+
import type { SpiceFlowConfig } from "./config.js";
|
|
4
|
+
import type { Authorization, Call } from "./types.js";
|
|
5
|
+
export interface Signers {
|
|
6
|
+
/** Sign an EIP‑7702 chain delegation for a given delegate contract & chain. */
|
|
7
|
+
authorizationSigner: (args: {
|
|
8
|
+
contractAddress: `0x${string}`;
|
|
9
|
+
chainId: number;
|
|
10
|
+
nonce: number;
|
|
11
|
+
address: `0x${string}`;
|
|
12
|
+
}) => Promise<Authorization>;
|
|
13
|
+
/** Sign the final cross‑chain intent hash. */
|
|
14
|
+
messageSigner: (digest: `0x${string}`) => Promise<`0x${string}`>;
|
|
15
|
+
}
|
|
16
|
+
export declare class SpiceFlowCore {
|
|
17
|
+
private cfg;
|
|
18
|
+
private signers;
|
|
19
|
+
constructor(cfg: SpiceFlowConfig, signers: Signers);
|
|
20
|
+
getConfig(): SpiceFlowConfig;
|
|
21
|
+
getClient(chainId: number): PublicClient;
|
|
22
|
+
/**
|
|
23
|
+
* Create EIP‑7702 authorizations for one or more chains.
|
|
24
|
+
* Will load nonces unless explicitly provided.
|
|
25
|
+
*/
|
|
26
|
+
signDelegations(params: {
|
|
27
|
+
user: `0x${string}`;
|
|
28
|
+
delegations: {
|
|
29
|
+
chainId: number;
|
|
30
|
+
contractAddress: `0x${string}`;
|
|
31
|
+
nonce?: number;
|
|
32
|
+
}[];
|
|
33
|
+
}): Promise<Authorization[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Build chain authorization batches and return the final intent digest.
|
|
36
|
+
*/
|
|
37
|
+
buildChainBatches(nbf: bigint, exp: bigint, callsByChain: {
|
|
38
|
+
chainId: number;
|
|
39
|
+
calls: Call[];
|
|
40
|
+
recentBlock?: bigint;
|
|
41
|
+
}[]): Promise<{
|
|
42
|
+
chainBatches: import("./types.js").ChainBatch[];
|
|
43
|
+
digest: `0x${string}`;
|
|
44
|
+
}>;
|
|
45
|
+
/** Sign the final intent hash (EIP‑7702). */
|
|
46
|
+
signIntent(digest: `0x${string}`): Promise<`0x${string}`>;
|
|
47
|
+
/**
|
|
48
|
+
* Submit a signed intent to the SpiceFlow relayer.
|
|
49
|
+
*/
|
|
50
|
+
submitIntent(req: {
|
|
51
|
+
user: `0x${string}`;
|
|
52
|
+
authorization: Authorization[];
|
|
53
|
+
chainBatches: ReturnType<typeof hashChainBatches>;
|
|
54
|
+
tokenAddress: `0x${string}`;
|
|
55
|
+
tokenAmount: bigint;
|
|
56
|
+
nbf: bigint;
|
|
57
|
+
exp: bigint;
|
|
58
|
+
signature?: `0x${string}`;
|
|
59
|
+
}): Promise<import("./relayer.js").RelayerSubmitResponse>;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAmC,gBAAgB,EAAiB,MAAM,oBAAoB,CAAC;AACtG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGtD,MAAM,WAAW,OAAO;IACtB,+EAA+E;IAC/E,mBAAmB,EAAE,CAAC,IAAI,EAAE;QAAE,eAAe,EAAE,KAAK,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;KAAE,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IAClJ,8CAA8C;IAC9C,aAAa,EAAE,CAAC,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC;CAClE;AAED,qBAAa,aAAa;IACZ,OAAO,CAAC,GAAG;IAAmB,OAAO,CAAC,OAAO;gBAArC,GAAG,EAAE,eAAe,EAAU,OAAO,EAAE,OAAO;IAElE,SAAS,IAAI,eAAe;IAC5B,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY;IAExC;;;OAGG;IACG,eAAe,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,KAAK,MAAM,EAAE,CAAC;QAAC,WAAW,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,eAAe,EAAE,KAAK,MAAM,EAAE,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAapK;;OAEG;IACG,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,IAAI,EAAE,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE;;;;IAW1H,6CAA6C;IACvC,UAAU,CAAC,MAAM,EAAE,KAAK,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC;IAE/D;;OAEG;IACG,YAAY,CAAC,GAAG,EAAE;QACtB,IAAI,EAAE,KAAK,MAAM,EAAE,CAAC;QACpB,aAAa,EAAE,aAAa,EAAE,CAAC;QAC/B,YAAY,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;QAClD,YAAY,EAAE,KAAK,MAAM,EAAE,CAAC;QAC5B,WAAW,EAAE,MAAM,CAAC;QACpB,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;KAC3B;CAWF"}
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type RetryOptions = {
|
|
2
|
+
retries?: number;
|
|
3
|
+
backoffMs?: number;
|
|
4
|
+
maxBackoffMs?: number;
|
|
5
|
+
jitter?: boolean;
|
|
6
|
+
idempotencyKey?: string;
|
|
7
|
+
retryOn?: (errOrRes: Error | Response) => boolean;
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
};
|
|
10
|
+
export declare class HttpError extends Error {
|
|
11
|
+
status: number;
|
|
12
|
+
code?: string;
|
|
13
|
+
body?: unknown;
|
|
14
|
+
constructor(message: string, status: number, code?: string, body?: unknown);
|
|
15
|
+
}
|
|
16
|
+
export declare function fetchWithRetry(url: string, init?: RequestInit, opts?: RetryOptions): Promise<Response>;
|
|
17
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,GAAG,QAAQ,KAAK,OAAO,CAAC;IAClD,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,qBAAa,SAAU,SAAQ,KAAK;IAGzB,MAAM,EAAE,MAAM;IACd,IAAI,CAAC,EAAE,MAAM;IACb,IAAI,CAAC,EAAE,OAAO;gBAHrB,OAAO,EAAE,MAAM,EACR,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,OAAO;CAIxB;AAMD,wBAAsB,cAAc,CAClC,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,WAAgB,EACtB,IAAI,GAAE,YAAiB,GACtB,OAAO,CAAC,QAAQ,CAAC,CA6CnB"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/index.ts
|
|
20
|
+
var index_exports = {};
|
|
21
|
+
__export(index_exports, {
|
|
22
|
+
CallAbi: () => CallAbi,
|
|
23
|
+
ChainBatchHashComponentsAbi: () => ChainBatchHashComponentsAbi,
|
|
24
|
+
SpiceFlowCore: () => SpiceFlowCore,
|
|
25
|
+
getAccountNonce: () => getAccountNonce,
|
|
26
|
+
getIntentHash: () => getIntentHash,
|
|
27
|
+
getIntentStepStatus: () => getIntentStepStatus,
|
|
28
|
+
getRecentBlock: () => getRecentBlock,
|
|
29
|
+
hashChainBatches: () => hashChainBatches,
|
|
30
|
+
prepareRFQT: () => prepareRFQT,
|
|
31
|
+
submitTransaction: () => submitTransaction
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(index_exports);
|
|
34
|
+
|
|
35
|
+
// src/authorization.ts
|
|
36
|
+
var import_viem = require("viem");
|
|
37
|
+
var CallAbi = {
|
|
38
|
+
type: "tuple",
|
|
39
|
+
components: [
|
|
40
|
+
{ name: "to", type: "address" },
|
|
41
|
+
{ name: "value", type: "uint" },
|
|
42
|
+
{ name: "data", type: "bytes" }
|
|
43
|
+
]
|
|
44
|
+
};
|
|
45
|
+
var ChainBatchHashComponentsAbi = [
|
|
46
|
+
{ name: "chainId", type: "uint256" },
|
|
47
|
+
{ name: "calls", ...CallAbi, type: "tuple[]" }
|
|
48
|
+
];
|
|
49
|
+
function hashChainBatches(chainCalls) {
|
|
50
|
+
return chainCalls.map(({ chainId, calls }) => {
|
|
51
|
+
chainId = BigInt(chainId);
|
|
52
|
+
const hash = (0, import_viem.keccak256)(
|
|
53
|
+
(0, import_viem.encodeAbiParameters)(ChainBatchHashComponentsAbi, [chainId, calls])
|
|
54
|
+
);
|
|
55
|
+
return { hash, chainId, calls };
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function getIntentHash(nbf, exp, chainBatches) {
|
|
59
|
+
const hashes = chainBatches.map(({ hash }) => hash);
|
|
60
|
+
return (0, import_viem.keccak256)((0, import_viem.encodeAbiParameters)([{ type: "uint256" }, { type: "uint256" }, { type: "bytes32[]" }], [nbf, exp, hashes]));
|
|
61
|
+
}
|
|
62
|
+
async function getAccountNonce(address, publicClient) {
|
|
63
|
+
return await publicClient.getTransactionCount({ address });
|
|
64
|
+
}
|
|
65
|
+
async function getRecentBlock(publicClient) {
|
|
66
|
+
return await publicClient.getBlockNumber();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/http.ts
|
|
70
|
+
var HttpError = class extends Error {
|
|
71
|
+
constructor(message, status, code, body) {
|
|
72
|
+
super(message);
|
|
73
|
+
this.status = status;
|
|
74
|
+
this.code = code;
|
|
75
|
+
this.body = body;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
function sleep(ms) {
|
|
79
|
+
return new Promise((r) => setTimeout(r, ms));
|
|
80
|
+
}
|
|
81
|
+
async function fetchWithRetry(url, init = {}, opts = {}) {
|
|
82
|
+
const {
|
|
83
|
+
retries = 3,
|
|
84
|
+
backoffMs = 300,
|
|
85
|
+
maxBackoffMs = 5e3,
|
|
86
|
+
jitter = true,
|
|
87
|
+
idempotencyKey,
|
|
88
|
+
retryOn = (e) => e instanceof Error || e instanceof Response && (e.status >= 500 || e.status === 429),
|
|
89
|
+
signal
|
|
90
|
+
} = opts;
|
|
91
|
+
const headers = new Headers(init.headers || {});
|
|
92
|
+
if (idempotencyKey) headers.set("Idempotency-Key", idempotencyKey);
|
|
93
|
+
const reqInit = { ...init, headers, signal };
|
|
94
|
+
let attempt = 0;
|
|
95
|
+
let lastErr;
|
|
96
|
+
while (attempt <= retries) {
|
|
97
|
+
try {
|
|
98
|
+
const res = await fetch(url, reqInit);
|
|
99
|
+
if (!res.ok && retryOn(res) && attempt < retries) {
|
|
100
|
+
attempt++;
|
|
101
|
+
const base = Math.min(maxBackoffMs, backoffMs * 2 ** (attempt - 1));
|
|
102
|
+
const delay = jitter ? Math.floor(base * (0.7 + Math.random() * 0.6)) : base;
|
|
103
|
+
await sleep(delay);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (!res.ok) {
|
|
107
|
+
let body;
|
|
108
|
+
try {
|
|
109
|
+
body = await res.json();
|
|
110
|
+
} catch {
|
|
111
|
+
body = await res.text();
|
|
112
|
+
}
|
|
113
|
+
throw new HttpError(`HTTP ${res.status}`, res.status, body && body.code || void 0, body);
|
|
114
|
+
}
|
|
115
|
+
return res;
|
|
116
|
+
} catch (e) {
|
|
117
|
+
if (attempt >= retries || !retryOn(e)) throw e;
|
|
118
|
+
attempt++;
|
|
119
|
+
const base = Math.min(maxBackoffMs, backoffMs * 2 ** (attempt - 1));
|
|
120
|
+
const delay = jitter ? Math.floor(base * (0.7 + Math.random() * 0.6)) : base;
|
|
121
|
+
await sleep(delay);
|
|
122
|
+
lastErr = e;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
throw lastErr;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// src/relayer.ts
|
|
129
|
+
async function submitTransaction(baseUrl, request, retry) {
|
|
130
|
+
const res = await fetchWithRetry(`${baseUrl}/transaction/submit`, {
|
|
131
|
+
method: "POST",
|
|
132
|
+
headers: { "Content-Type": "application/json" },
|
|
133
|
+
body: JSON.stringify(request, (k, v) => typeof v === "bigint" ? v.toString() : v)
|
|
134
|
+
}, retry);
|
|
135
|
+
const result = await res.json();
|
|
136
|
+
return { hash: result.hash, intentId: result.intentId || request.intentAuthorization.signature };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// src/core.ts
|
|
140
|
+
var SpiceFlowCore = class {
|
|
141
|
+
constructor(cfg, signers) {
|
|
142
|
+
this.cfg = cfg;
|
|
143
|
+
this.signers = signers;
|
|
144
|
+
}
|
|
145
|
+
getConfig() {
|
|
146
|
+
return this.cfg;
|
|
147
|
+
}
|
|
148
|
+
getClient(chainId) {
|
|
149
|
+
return this.cfg.publicClientForChain(chainId);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Create EIP‑7702 authorizations for one or more chains.
|
|
153
|
+
* Will load nonces unless explicitly provided.
|
|
154
|
+
*/
|
|
155
|
+
async signDelegations(params) {
|
|
156
|
+
const out = [];
|
|
157
|
+
for (const d of params.delegations) {
|
|
158
|
+
const client = this.getClient(d.chainId);
|
|
159
|
+
const nonce = typeof d.nonce === "number" ? d.nonce : await getAccountNonce(params.user, client);
|
|
160
|
+
const auth = await this.signers.authorizationSigner({ contractAddress: d.contractAddress, chainId: d.chainId, nonce, address: params.user });
|
|
161
|
+
delete auth.v;
|
|
162
|
+
out.push(auth);
|
|
163
|
+
}
|
|
164
|
+
return out;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Build chain authorization batches and return the final intent digest.
|
|
168
|
+
*/
|
|
169
|
+
async buildChainBatches(nbf, exp, callsByChain) {
|
|
170
|
+
const filled = [];
|
|
171
|
+
for (const c of callsByChain) {
|
|
172
|
+
const recent = typeof c.recentBlock === "bigint" ? c.recentBlock : await getRecentBlock(this.getClient(c.chainId));
|
|
173
|
+
filled.push({ chainId: c.chainId, calls: c.calls, recentBlock: recent });
|
|
174
|
+
}
|
|
175
|
+
const chainBatches = hashChainBatches(filled);
|
|
176
|
+
const digest = getIntentHash(nbf, exp, chainBatches);
|
|
177
|
+
return { chainBatches, digest };
|
|
178
|
+
}
|
|
179
|
+
/** Sign the final intent hash (EIP‑7702). */
|
|
180
|
+
async signIntent(digest) {
|
|
181
|
+
return this.signers.messageSigner(digest);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Submit a signed intent to the SpiceFlow relayer.
|
|
185
|
+
*/
|
|
186
|
+
async submitIntent(req) {
|
|
187
|
+
const signature = req.signature ?? await this.signIntent(getIntentHash(req.nbf, req.exp, req.chainBatches));
|
|
188
|
+
const resp = await submitTransaction(this.cfg.txApiUrl, {
|
|
189
|
+
tokenAddress: req.tokenAddress,
|
|
190
|
+
tokenAmount: req.tokenAmount,
|
|
191
|
+
address: req.user,
|
|
192
|
+
authorization: req.authorization,
|
|
193
|
+
intentAuthorization: { signature, chainBatches: req.chainBatches }
|
|
194
|
+
});
|
|
195
|
+
return resp;
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// src/status.ts
|
|
200
|
+
async function getIntentStepStatus(txApiUrl, intentId, stepId, retry) {
|
|
201
|
+
const res = await fetchWithRetry(`${txApiUrl}/intent/${intentId}/step/${stepId}/status`, {}, retry);
|
|
202
|
+
return res.json();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// src/rfqt.ts
|
|
206
|
+
async function prepareRFQT(txApiUrl, request, retry) {
|
|
207
|
+
const res = await fetchWithRetry(`${txApiUrl}/rfqt`, {
|
|
208
|
+
method: "POST",
|
|
209
|
+
headers: { "Content-Type": "application/json" },
|
|
210
|
+
body: JSON.stringify(request)
|
|
211
|
+
}, retry);
|
|
212
|
+
return res.json();
|
|
213
|
+
}
|
|
214
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
215
|
+
0 && (module.exports = {
|
|
216
|
+
CallAbi,
|
|
217
|
+
ChainBatchHashComponentsAbi,
|
|
218
|
+
SpiceFlowCore,
|
|
219
|
+
getAccountNonce,
|
|
220
|
+
getIntentHash,
|
|
221
|
+
getIntentStepStatus,
|
|
222
|
+
getRecentBlock,
|
|
223
|
+
hashChainBatches,
|
|
224
|
+
prepareRFQT,
|
|
225
|
+
submitTransaction
|
|
226
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SpiceFlow SDK public API surface.
|
|
3
|
+
*
|
|
4
|
+
* This entry re-exports the minimal generic building blocks for
|
|
5
|
+
* constructing and submitting EIP‑7702 intent payloads.
|
|
6
|
+
*/
|
|
7
|
+
export * from "./config.js";
|
|
8
|
+
export * from "./types.js";
|
|
9
|
+
export * from "./authorization.js";
|
|
10
|
+
export * from "./relayer.js";
|
|
11
|
+
export * from "./core.js";
|
|
12
|
+
export * from "./status.js";
|
|
13
|
+
export * from "./rfqt.js";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// src/authorization.ts
|
|
2
|
+
import { encodeAbiParameters, keccak256 } from "viem";
|
|
3
|
+
var CallAbi = {
|
|
4
|
+
type: "tuple",
|
|
5
|
+
components: [
|
|
6
|
+
{ name: "to", type: "address" },
|
|
7
|
+
{ name: "value", type: "uint" },
|
|
8
|
+
{ name: "data", type: "bytes" }
|
|
9
|
+
]
|
|
10
|
+
};
|
|
11
|
+
var ChainBatchHashComponentsAbi = [
|
|
12
|
+
{ name: "chainId", type: "uint256" },
|
|
13
|
+
{ name: "calls", ...CallAbi, type: "tuple[]" }
|
|
14
|
+
];
|
|
15
|
+
function hashChainBatches(chainCalls) {
|
|
16
|
+
return chainCalls.map(({ chainId, calls }) => {
|
|
17
|
+
chainId = BigInt(chainId);
|
|
18
|
+
const hash = keccak256(
|
|
19
|
+
encodeAbiParameters(ChainBatchHashComponentsAbi, [chainId, calls])
|
|
20
|
+
);
|
|
21
|
+
return { hash, chainId, calls };
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function getIntentHash(nbf, exp, chainBatches) {
|
|
25
|
+
const hashes = chainBatches.map(({ hash }) => hash);
|
|
26
|
+
return keccak256(encodeAbiParameters([{ type: "uint256" }, { type: "uint256" }, { type: "bytes32[]" }], [nbf, exp, hashes]));
|
|
27
|
+
}
|
|
28
|
+
async function getAccountNonce(address, publicClient) {
|
|
29
|
+
return await publicClient.getTransactionCount({ address });
|
|
30
|
+
}
|
|
31
|
+
async function getRecentBlock(publicClient) {
|
|
32
|
+
return await publicClient.getBlockNumber();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/http.ts
|
|
36
|
+
var HttpError = class extends Error {
|
|
37
|
+
constructor(message, status, code, body) {
|
|
38
|
+
super(message);
|
|
39
|
+
this.status = status;
|
|
40
|
+
this.code = code;
|
|
41
|
+
this.body = body;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
function sleep(ms) {
|
|
45
|
+
return new Promise((r) => setTimeout(r, ms));
|
|
46
|
+
}
|
|
47
|
+
async function fetchWithRetry(url, init = {}, opts = {}) {
|
|
48
|
+
const {
|
|
49
|
+
retries = 3,
|
|
50
|
+
backoffMs = 300,
|
|
51
|
+
maxBackoffMs = 5e3,
|
|
52
|
+
jitter = true,
|
|
53
|
+
idempotencyKey,
|
|
54
|
+
retryOn = (e) => e instanceof Error || e instanceof Response && (e.status >= 500 || e.status === 429),
|
|
55
|
+
signal
|
|
56
|
+
} = opts;
|
|
57
|
+
const headers = new Headers(init.headers || {});
|
|
58
|
+
if (idempotencyKey) headers.set("Idempotency-Key", idempotencyKey);
|
|
59
|
+
const reqInit = { ...init, headers, signal };
|
|
60
|
+
let attempt = 0;
|
|
61
|
+
let lastErr;
|
|
62
|
+
while (attempt <= retries) {
|
|
63
|
+
try {
|
|
64
|
+
const res = await fetch(url, reqInit);
|
|
65
|
+
if (!res.ok && retryOn(res) && attempt < retries) {
|
|
66
|
+
attempt++;
|
|
67
|
+
const base = Math.min(maxBackoffMs, backoffMs * 2 ** (attempt - 1));
|
|
68
|
+
const delay = jitter ? Math.floor(base * (0.7 + Math.random() * 0.6)) : base;
|
|
69
|
+
await sleep(delay);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (!res.ok) {
|
|
73
|
+
let body;
|
|
74
|
+
try {
|
|
75
|
+
body = await res.json();
|
|
76
|
+
} catch {
|
|
77
|
+
body = await res.text();
|
|
78
|
+
}
|
|
79
|
+
throw new HttpError(`HTTP ${res.status}`, res.status, body && body.code || void 0, body);
|
|
80
|
+
}
|
|
81
|
+
return res;
|
|
82
|
+
} catch (e) {
|
|
83
|
+
if (attempt >= retries || !retryOn(e)) throw e;
|
|
84
|
+
attempt++;
|
|
85
|
+
const base = Math.min(maxBackoffMs, backoffMs * 2 ** (attempt - 1));
|
|
86
|
+
const delay = jitter ? Math.floor(base * (0.7 + Math.random() * 0.6)) : base;
|
|
87
|
+
await sleep(delay);
|
|
88
|
+
lastErr = e;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
throw lastErr;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/relayer.ts
|
|
95
|
+
async function submitTransaction(baseUrl, request, retry) {
|
|
96
|
+
const res = await fetchWithRetry(`${baseUrl}/transaction/submit`, {
|
|
97
|
+
method: "POST",
|
|
98
|
+
headers: { "Content-Type": "application/json" },
|
|
99
|
+
body: JSON.stringify(request, (k, v) => typeof v === "bigint" ? v.toString() : v)
|
|
100
|
+
}, retry);
|
|
101
|
+
const result = await res.json();
|
|
102
|
+
return { hash: result.hash, intentId: result.intentId || request.intentAuthorization.signature };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/core.ts
|
|
106
|
+
var SpiceFlowCore = class {
|
|
107
|
+
constructor(cfg, signers) {
|
|
108
|
+
this.cfg = cfg;
|
|
109
|
+
this.signers = signers;
|
|
110
|
+
}
|
|
111
|
+
getConfig() {
|
|
112
|
+
return this.cfg;
|
|
113
|
+
}
|
|
114
|
+
getClient(chainId) {
|
|
115
|
+
return this.cfg.publicClientForChain(chainId);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Create EIP‑7702 authorizations for one or more chains.
|
|
119
|
+
* Will load nonces unless explicitly provided.
|
|
120
|
+
*/
|
|
121
|
+
async signDelegations(params) {
|
|
122
|
+
const out = [];
|
|
123
|
+
for (const d of params.delegations) {
|
|
124
|
+
const client = this.getClient(d.chainId);
|
|
125
|
+
const nonce = typeof d.nonce === "number" ? d.nonce : await getAccountNonce(params.user, client);
|
|
126
|
+
const auth = await this.signers.authorizationSigner({ contractAddress: d.contractAddress, chainId: d.chainId, nonce, address: params.user });
|
|
127
|
+
delete auth.v;
|
|
128
|
+
out.push(auth);
|
|
129
|
+
}
|
|
130
|
+
return out;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Build chain authorization batches and return the final intent digest.
|
|
134
|
+
*/
|
|
135
|
+
async buildChainBatches(nbf, exp, callsByChain) {
|
|
136
|
+
const filled = [];
|
|
137
|
+
for (const c of callsByChain) {
|
|
138
|
+
const recent = typeof c.recentBlock === "bigint" ? c.recentBlock : await getRecentBlock(this.getClient(c.chainId));
|
|
139
|
+
filled.push({ chainId: c.chainId, calls: c.calls, recentBlock: recent });
|
|
140
|
+
}
|
|
141
|
+
const chainBatches = hashChainBatches(filled);
|
|
142
|
+
const digest = getIntentHash(nbf, exp, chainBatches);
|
|
143
|
+
return { chainBatches, digest };
|
|
144
|
+
}
|
|
145
|
+
/** Sign the final intent hash (EIP‑7702). */
|
|
146
|
+
async signIntent(digest) {
|
|
147
|
+
return this.signers.messageSigner(digest);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Submit a signed intent to the SpiceFlow relayer.
|
|
151
|
+
*/
|
|
152
|
+
async submitIntent(req) {
|
|
153
|
+
const signature = req.signature ?? await this.signIntent(getIntentHash(req.nbf, req.exp, req.chainBatches));
|
|
154
|
+
const resp = await submitTransaction(this.cfg.txApiUrl, {
|
|
155
|
+
tokenAddress: req.tokenAddress,
|
|
156
|
+
tokenAmount: req.tokenAmount,
|
|
157
|
+
address: req.user,
|
|
158
|
+
authorization: req.authorization,
|
|
159
|
+
intentAuthorization: { signature, chainBatches: req.chainBatches }
|
|
160
|
+
});
|
|
161
|
+
return resp;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// src/status.ts
|
|
166
|
+
async function getIntentStepStatus(txApiUrl, intentId, stepId, retry) {
|
|
167
|
+
const res = await fetchWithRetry(`${txApiUrl}/intent/${intentId}/step/${stepId}/status`, {}, retry);
|
|
168
|
+
return res.json();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// src/rfqt.ts
|
|
172
|
+
async function prepareRFQT(txApiUrl, request, retry) {
|
|
173
|
+
const res = await fetchWithRetry(`${txApiUrl}/rfqt`, {
|
|
174
|
+
method: "POST",
|
|
175
|
+
headers: { "Content-Type": "application/json" },
|
|
176
|
+
body: JSON.stringify(request)
|
|
177
|
+
}, retry);
|
|
178
|
+
return res.json();
|
|
179
|
+
}
|
|
180
|
+
export {
|
|
181
|
+
CallAbi,
|
|
182
|
+
ChainBatchHashComponentsAbi,
|
|
183
|
+
SpiceFlowCore,
|
|
184
|
+
getAccountNonce,
|
|
185
|
+
getIntentHash,
|
|
186
|
+
getIntentStepStatus,
|
|
187
|
+
getRecentBlock,
|
|
188
|
+
hashChainBatches,
|
|
189
|
+
prepareRFQT,
|
|
190
|
+
submitTransaction
|
|
191
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request payload to submit an EIP‑7702 intent via the SpiceFlow relayer.
|
|
3
|
+
* Values like bigint are stringified for transport.
|
|
4
|
+
*/
|
|
5
|
+
export interface RelayerSubmitRequest {
|
|
6
|
+
tokenAddress: string;
|
|
7
|
+
tokenAmount: bigint;
|
|
8
|
+
address: string;
|
|
9
|
+
authorization: any[];
|
|
10
|
+
intentAuthorization: {
|
|
11
|
+
signature: string;
|
|
12
|
+
chainBatches: Array<{
|
|
13
|
+
hash: string;
|
|
14
|
+
chainId: bigint;
|
|
15
|
+
calls: any[];
|
|
16
|
+
recentBlock: bigint;
|
|
17
|
+
}>;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** Response from the relayer on successful submission. */
|
|
21
|
+
export interface RelayerSubmitResponse {
|
|
22
|
+
hash: string;
|
|
23
|
+
intentId: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Submit an intent to the relayer.
|
|
27
|
+
* The relayer broadcasts the transaction(s) and returns a cross‑chain intent id.
|
|
28
|
+
*/
|
|
29
|
+
import { type RetryOptions } from "./http.js";
|
|
30
|
+
export declare function submitTransaction(baseUrl: string, request: RelayerSubmitRequest, retry?: RetryOptions): Promise<RelayerSubmitResponse>;
|
|
31
|
+
//# sourceMappingURL=relayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relayer.d.ts","sourceRoot":"","sources":["../src/relayer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,GAAG,EAAE,CAAC;IACrB,mBAAmB,EAAE;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,GAAG,EAAE,CAAC;YAAC,WAAW,EAAE,MAAM,CAAC;SAAE,CAAC,CAAC;KAC5F,CAAC;CACH;AAED,0DAA0D;AAC1D,MAAM,WAAW,qBAAqB;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;CAAE;AAE1E;;;GAGG;AACH,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9D,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,oBAAoB,EAC7B,KAAK,CAAC,EAAE,YAAY,GACnB,OAAO,CAAC,qBAAqB,CAAC,CAOhC"}
|
package/dist/rfqt.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type RetryOptions } from "./http.js";
|
|
2
|
+
/**
|
|
3
|
+
* RFQT request shape used by SpiceFlow to prepare a user-executed trade.
|
|
4
|
+
*/
|
|
5
|
+
export interface RFQTRequest {
|
|
6
|
+
user: `0x${string}`;
|
|
7
|
+
/** Input asset identifier (symbol, address, or provider-defined key). */
|
|
8
|
+
tokenIn: string;
|
|
9
|
+
/** Output asset identifier (symbol, address, or provider-defined key). */
|
|
10
|
+
tokenOut: string;
|
|
11
|
+
amountIn: string;
|
|
12
|
+
amountOut: string;
|
|
13
|
+
expiry: number;
|
|
14
|
+
quoteId: `0x${string}`;
|
|
15
|
+
}
|
|
16
|
+
/** RFQT response payload used to build a call {to, value, data}. */
|
|
17
|
+
export interface RFQTResponse {
|
|
18
|
+
to: `0x${string}`;
|
|
19
|
+
value: string;
|
|
20
|
+
data: `0x${string}`;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Prepare an RFQT transaction request.
|
|
24
|
+
* POST {txApiUrl}/rfqt
|
|
25
|
+
*/
|
|
26
|
+
export declare function prepareRFQT(txApiUrl: string, request: RFQTRequest, retry?: RetryOptions): Promise<RFQTResponse>;
|
|
27
|
+
//# sourceMappingURL=rfqt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rfqt.d.ts","sourceRoot":"","sources":["../src/rfqt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9D;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,KAAK,MAAM,EAAE,CAAC;IACpB,yEAAyE;IACzE,OAAO,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;CACxB;AAED,oEAAoE;AACpE,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,KAAK,MAAM,EAAE,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,WAAW,EACpB,KAAK,CAAC,EAAE,YAAY,GACnB,OAAO,CAAC,YAAY,CAAC,CAOvB"}
|
package/dist/status.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type RetryOptions } from "./http.js";
|
|
2
|
+
/**
|
|
3
|
+
* Intent step status response payload.
|
|
4
|
+
*/
|
|
5
|
+
export interface IntentStepStatusResponse {
|
|
6
|
+
success: boolean;
|
|
7
|
+
data: {
|
|
8
|
+
status: 'created' | 'executing' | 'success' | 'reverted';
|
|
9
|
+
transactionHash?: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Fetch the status of a specific intent step.
|
|
14
|
+
* GET {txApiUrl}/intent/{intentId}/step/{stepId}/status
|
|
15
|
+
*/
|
|
16
|
+
export declare function getIntentStepStatus(txApiUrl: string, intentId: string, stepId: number, retry?: RetryOptions): Promise<IntentStepStatusResponse>;
|
|
17
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9D;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE;QACJ,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAC;QACzD,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAA;CACF;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,YAAY,GACnB,OAAO,CAAC,wBAAwB,CAAC,CAGnC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Address, Hash, Hex } from "viem";
|
|
2
|
+
/** A single call packed into a chain batch. */
|
|
3
|
+
export type Call = {
|
|
4
|
+
to: Address;
|
|
5
|
+
value: bigint;
|
|
6
|
+
data: Hex;
|
|
7
|
+
};
|
|
8
|
+
/** Signed authorization (EIP‑7702) for a specific chain & delegate contract. */
|
|
9
|
+
export type Authorization = {
|
|
10
|
+
address: string;
|
|
11
|
+
chainId: number;
|
|
12
|
+
nonce: number;
|
|
13
|
+
r: string;
|
|
14
|
+
s: string;
|
|
15
|
+
yParity: number;
|
|
16
|
+
};
|
|
17
|
+
/** Input for hashing a per-chain authorization (preimage). */
|
|
18
|
+
export type ChainBatchInput = {
|
|
19
|
+
chainId: bigint | number;
|
|
20
|
+
calls: Call[];
|
|
21
|
+
};
|
|
22
|
+
/** Output of hashing: the EIP‑7702 chain authorization tuple. */
|
|
23
|
+
export type ChainBatch = {
|
|
24
|
+
hash: Hash;
|
|
25
|
+
chainId: bigint;
|
|
26
|
+
calls: Call[];
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAE/C,+CAA+C;AAC/C,MAAM,MAAM,IAAI,GAAG;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAE,CAAC;AAC7D,gFAAgF;AAChF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,8DAA8D;AAC9D,MAAM,MAAM,eAAe,GAAG;IAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,KAAK,EAAE,IAAI,EAAE,CAAA;CAAE,CAAC;AAC1E,iEAAiE;AACjE,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,IAAI,EAAE,CAAA;CAAE,CAAC"}
|