@spicenet-io/spiceflow-core 0.8.1-conditional-intents.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +6 -45
- package/dist/api.d.ts.map +1 -1
- package/dist/fees.d.ts +37 -0
- package/dist/fees.d.ts.map +1 -0
- package/dist/index.cjs +6 -182
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -168
- package/package.json +1 -2
- package/dist/conditionalIntents.d.ts +0 -68
- package/dist/conditionalIntents.d.ts.map +0 -1
package/dist/api.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FeePolicy, FeeAssessment } from "./fees.js";
|
|
2
|
+
import type { Address, Hex } from "viem";
|
|
2
3
|
import type { Call, TokenTransferConfig } from "./types.js";
|
|
3
|
-
import type { ConditionalIntentAuthorization, ConditionalSignal, ConditionalCancellation } from "./conditionalIntents.js";
|
|
4
4
|
export type { Call, TokenTransferConfig };
|
|
5
5
|
export interface SignedCall extends Call {
|
|
6
6
|
signature: Hex;
|
|
@@ -55,6 +55,8 @@ export interface CreateActionRequest {
|
|
|
55
55
|
intents: ApiIntent[];
|
|
56
56
|
}
|
|
57
57
|
export interface FeeEstimateBatch {
|
|
58
|
+
batchIndex?: number;
|
|
59
|
+
paymentToken?: Address;
|
|
58
60
|
chainId: number;
|
|
59
61
|
quotedAmount: string;
|
|
60
62
|
totalDebit: string;
|
|
@@ -70,6 +72,8 @@ export interface FeeEstimateIntent {
|
|
|
70
72
|
batches: FeeEstimateBatch[];
|
|
71
73
|
}
|
|
72
74
|
export interface FeeEstimateSummary {
|
|
75
|
+
policy?: FeePolicy;
|
|
76
|
+
assessments?: FeeAssessment[];
|
|
73
77
|
intents: FeeEstimateIntent[];
|
|
74
78
|
}
|
|
75
79
|
export interface CreateActionResponse {
|
|
@@ -87,49 +91,6 @@ export interface EstimateActionFeesResponse {
|
|
|
87
91
|
code?: string;
|
|
88
92
|
};
|
|
89
93
|
}
|
|
90
|
-
export interface RegisterConditionalIntentRequest {
|
|
91
|
-
authorization: ConditionalIntentAuthorization;
|
|
92
|
-
authorizationSignature: Hex;
|
|
93
|
-
triggerSpecification: Hex;
|
|
94
|
-
action: {
|
|
95
|
-
user: Address;
|
|
96
|
-
intents: Intent7702[];
|
|
97
|
-
chainAuthorizations?: ChainAuthorization7702[];
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
export interface RegisterConditionalIntentResponse {
|
|
101
|
-
conditionalIntentId: Hash;
|
|
102
|
-
state: "armed" | "eligible" | "executing" | "reconciling" | "completed" | "cancelled" | "expired" | "failed" | "needs_attention";
|
|
103
|
-
readToken?: string;
|
|
104
|
-
}
|
|
105
|
-
export interface ConditionalIntentStatus {
|
|
106
|
-
executionStatus?: string;
|
|
107
|
-
executionStopped?: boolean;
|
|
108
|
-
conditionalIntentId: Hash;
|
|
109
|
-
state: RegisterConditionalIntentResponse["state"];
|
|
110
|
-
validAfter: number;
|
|
111
|
-
expiresAt: number;
|
|
112
|
-
acceptedSignal?: {
|
|
113
|
-
signalId: string;
|
|
114
|
-
observedAt: number;
|
|
115
|
-
};
|
|
116
|
-
owner?: Address;
|
|
117
|
-
clientId?: string;
|
|
118
|
-
executionDigest?: Hash;
|
|
119
|
-
triggerSpecificationHash?: Hash;
|
|
120
|
-
/** Returned only to an authenticated owner reader, never execution credentials. */
|
|
121
|
-
triggerSpecification?: Hex;
|
|
122
|
-
evaluator?: Address;
|
|
123
|
-
semantics?: "state" | "event";
|
|
124
|
-
actionId?: string;
|
|
125
|
-
reason?: string;
|
|
126
|
-
}
|
|
127
|
-
export interface SubmitConditionalSignalRequest extends ConditionalSignal {
|
|
128
|
-
signature: Hex;
|
|
129
|
-
}
|
|
130
|
-
export interface CancelConditionalIntentRequest extends ConditionalCancellation {
|
|
131
|
-
signature: Hex;
|
|
132
|
-
}
|
|
133
94
|
export interface StepIdParams {
|
|
134
95
|
actionId: string;
|
|
135
96
|
intentIndex: number;
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAG5D,YAAY,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC;AAE1C,MAAM,WAAW,UAAW,SAAQ,IAAI;IACtC,SAAS,EAAE,GAAG,CAAC;CAChB;AAMD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,mBAAmB,EAAE,CAAC;IACtC,KAAK,EAAE,IAAI,EAAE,CAAC;CACf;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,GAAG,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,cAAc,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,mBAAmB,EAAE,CAAC;IACtC,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,kBAAkB,CAAC;IACzB,YAAY,EAAE,wBAAwB,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,yBAAyB;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M,CAAC;KAChB,CAAC,CAAC;CACJ;AAMD,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,MAAM,CAAC;CACxB"}
|
package/dist/fees.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
export interface FeePolicy {
|
|
3
|
+
version: "actual-input-v1";
|
|
4
|
+
platformBps: string;
|
|
5
|
+
rounding: "ceil";
|
|
6
|
+
platformRecipient: Address;
|
|
7
|
+
gasRecipient: Address;
|
|
8
|
+
enforcement: "observe" | "enforce";
|
|
9
|
+
}
|
|
10
|
+
export interface FeeAssessment {
|
|
11
|
+
version: 1;
|
|
12
|
+
intentIndex: number;
|
|
13
|
+
batchIndex: number;
|
|
14
|
+
chainId: number;
|
|
15
|
+
callsHash: Hex;
|
|
16
|
+
planId: Hex;
|
|
17
|
+
basis: "calldata-input" | "legacy-payout" | "gas-only" | "unsupported" | "internal";
|
|
18
|
+
reason?: string;
|
|
19
|
+
principal: Array<{
|
|
20
|
+
token: Address;
|
|
21
|
+
amount: string;
|
|
22
|
+
}>;
|
|
23
|
+
paymentToken?: Address;
|
|
24
|
+
required?: {
|
|
25
|
+
platform: string;
|
|
26
|
+
gas: string;
|
|
27
|
+
bridge: string;
|
|
28
|
+
};
|
|
29
|
+
signed?: {
|
|
30
|
+
platform: string;
|
|
31
|
+
gasAndBridge: string;
|
|
32
|
+
};
|
|
33
|
+
status: "quoted" | "sufficient" | "underpaid" | "unsupported" | "exempt";
|
|
34
|
+
platformRecipient: Address;
|
|
35
|
+
gasRecipient: Address;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=fees.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fees.d.ts","sourceRoot":"","sources":["../src/fees.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEzC,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,SAAS,GAAG,SAAS,CAAC;CACpC;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,CAAC,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,GAAG,CAAC;IACZ,KAAK,EAAE,gBAAgB,GAAG,eAAe,GAAG,UAAU,GAAG,aAAa,GAAG,UAAU,CAAC;IACpF,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,SAAS,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7D,MAAM,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;IACpD,MAAM,EAAE,QAAQ,GAAG,YAAY,GAAG,WAAW,GAAG,aAAa,GAAG,QAAQ,CAAC;IACzE,iBAAiB,EAAE,OAAO,CAAC;IAC3B,YAAY,EAAE,OAAO,CAAC;CACvB"}
|
package/dist/index.cjs
CHANGED
|
@@ -20,7 +20,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
var index_exports = {};
|
|
21
21
|
__export(index_exports, {
|
|
22
22
|
CHAINS: () => CHAINS,
|
|
23
|
-
CONDITIONAL_INTENT_VERSION: () => CONDITIONAL_INTENT_VERSION,
|
|
24
23
|
ChainBatchHashAbi: () => ChainBatchHashAbi,
|
|
25
24
|
DELEGATE_ABI: () => DELEGATE_ABI,
|
|
26
25
|
ERC20_ABI: () => ERC20_ABI,
|
|
@@ -41,7 +40,6 @@ __export(index_exports, {
|
|
|
41
40
|
applySlippage: () => applySlippage,
|
|
42
41
|
areEquivalent: () => areEquivalent,
|
|
43
42
|
buildUniV3SwapCalls: () => buildUniV3SwapCalls,
|
|
44
|
-
conditionalHashMessage: () => conditionalHashMessage,
|
|
45
43
|
convertAmountBetweenDecimals: () => convertAmountBetweenDecimals,
|
|
46
44
|
fetchWithRetry: () => fetchWithRetry,
|
|
47
45
|
formatTokenAmount: () => formatTokenAmount,
|
|
@@ -50,7 +48,6 @@ __export(index_exports, {
|
|
|
50
48
|
getChainIdsByNetwork: () => getChainIdsByNetwork,
|
|
51
49
|
getChainMeta: () => getChainMeta,
|
|
52
50
|
getChainsByNetwork: () => getChainsByNetwork,
|
|
53
|
-
getConditionalIntentId: () => getConditionalIntentId,
|
|
54
51
|
getDelegateContract: () => getDelegateContract,
|
|
55
52
|
getDeployment: () => getDeployment,
|
|
56
53
|
getEquivalenceGroup: () => getEquivalenceGroup,
|
|
@@ -68,11 +65,6 @@ __export(index_exports, {
|
|
|
68
65
|
getTokensForChain: () => getTokensForChain,
|
|
69
66
|
getViemChain: () => getViemChain,
|
|
70
67
|
hashChainBatches: () => hashChainBatches,
|
|
71
|
-
hashConditionalCancellation: () => hashConditionalCancellation,
|
|
72
|
-
hashConditionalExecutionPlan: () => hashConditionalExecutionPlan,
|
|
73
|
-
hashConditionalIntentAuthorization: () => hashConditionalIntentAuthorization,
|
|
74
|
-
hashConditionalReadAuthorization: () => hashConditionalReadAuthorization,
|
|
75
|
-
hashConditionalSignal: () => hashConditionalSignal,
|
|
76
68
|
isBtcDenominated: () => isBtcDenominated,
|
|
77
69
|
isNativeToken: () => isNativeToken,
|
|
78
70
|
isSpicenetChainId: () => isSpicenetChainId,
|
|
@@ -147,166 +139,6 @@ async function getRecentBlock(publicClient) {
|
|
|
147
139
|
return await publicClient.getBlockNumber();
|
|
148
140
|
}
|
|
149
141
|
|
|
150
|
-
// src/conditionalIntents.ts
|
|
151
|
-
var import_viem2 = require("viem");
|
|
152
|
-
var CONDITIONAL_INTENT_VERSION = 1;
|
|
153
|
-
var callTuple = [
|
|
154
|
-
{ name: "to", type: "address" },
|
|
155
|
-
{ name: "value", type: "uint256" },
|
|
156
|
-
{ name: "data", type: "bytes" }
|
|
157
|
-
];
|
|
158
|
-
var transferTuple = [
|
|
159
|
-
{ name: "fromKind", type: "uint8" },
|
|
160
|
-
{ name: "fromAddress", type: "address" },
|
|
161
|
-
{ name: "to", type: "address" },
|
|
162
|
-
{ name: "token", type: "address" },
|
|
163
|
-
{ name: "amount", type: "uint256" }
|
|
164
|
-
];
|
|
165
|
-
var batchTuple = [
|
|
166
|
-
{ name: "chainId", type: "uint256" },
|
|
167
|
-
{ name: "calls", type: "tuple[]", components: callTuple },
|
|
168
|
-
{ name: "tokenTransfers", type: "tuple[]", components: transferTuple }
|
|
169
|
-
];
|
|
170
|
-
var zeroAddress = "0x0000000000000000000000000000000000000000";
|
|
171
|
-
function encodePlanTransfer(transfer) {
|
|
172
|
-
if (transfer.from === "solver") return [1, zeroAddress, transfer.to, transfer.token, transfer.amount];
|
|
173
|
-
if (transfer.from === "escrow") return [2, zeroAddress, transfer.to, transfer.token, transfer.amount];
|
|
174
|
-
return [0, transfer.from, transfer.to, transfer.token, transfer.amount];
|
|
175
|
-
}
|
|
176
|
-
function hashConditionalExecutionPlan(batches, delegationAuthorizations = []) {
|
|
177
|
-
const normalized = batches.map((batch) => [
|
|
178
|
-
BigInt(batch.chainId),
|
|
179
|
-
batch.calls,
|
|
180
|
-
batch.tokenTransfers.map(encodePlanTransfer)
|
|
181
|
-
]);
|
|
182
|
-
return (0, import_viem2.keccak256)((0, import_viem2.encodeAbiParameters)(
|
|
183
|
-
[
|
|
184
|
-
{ type: "bytes32" },
|
|
185
|
-
{ type: "uint256" },
|
|
186
|
-
{ type: "tuple[]", components: batchTuple },
|
|
187
|
-
{ type: "tuple[]", components: [
|
|
188
|
-
{ name: "address", type: "address" },
|
|
189
|
-
{ name: "chainId", type: "uint256" },
|
|
190
|
-
{ name: "nonce", type: "uint256" },
|
|
191
|
-
{ name: "r", type: "bytes32" },
|
|
192
|
-
{ name: "s", type: "bytes32" },
|
|
193
|
-
{ name: "yParity", type: "uint8" }
|
|
194
|
-
] }
|
|
195
|
-
],
|
|
196
|
-
[
|
|
197
|
-
(0, import_viem2.keccak256)((0, import_viem2.stringToHex)("spice.conditional.execution-plan")),
|
|
198
|
-
BigInt(CONDITIONAL_INTENT_VERSION),
|
|
199
|
-
normalized,
|
|
200
|
-
delegationAuthorizations.map((auth) => [
|
|
201
|
-
auth.address,
|
|
202
|
-
BigInt(auth.chainId),
|
|
203
|
-
BigInt(auth.nonce),
|
|
204
|
-
auth.r,
|
|
205
|
-
auth.s,
|
|
206
|
-
auth.yParity ?? 0
|
|
207
|
-
])
|
|
208
|
-
]
|
|
209
|
-
));
|
|
210
|
-
}
|
|
211
|
-
var authorizationTypes = [
|
|
212
|
-
{ name: "domain", type: "bytes32" },
|
|
213
|
-
{ name: "version", type: "uint256" },
|
|
214
|
-
{ name: "owner", type: "address" },
|
|
215
|
-
{ name: "clientIdHash", type: "bytes32" },
|
|
216
|
-
{ name: "serviceIdHash", type: "bytes32" },
|
|
217
|
-
{ name: "authorizationNonce", type: "uint256" },
|
|
218
|
-
{ name: "executionDigest", type: "bytes32" },
|
|
219
|
-
{ name: "executionPlanHash", type: "bytes32" },
|
|
220
|
-
{ name: "triggerSpecificationHash", type: "bytes32" },
|
|
221
|
-
{ name: "evaluator", type: "address" },
|
|
222
|
-
{ name: "semantics", type: "uint8" },
|
|
223
|
-
{ name: "maxSignalAgeSeconds", type: "uint256" },
|
|
224
|
-
{ name: "validAfter", type: "uint256" },
|
|
225
|
-
{ name: "expiresAt", type: "uint256" },
|
|
226
|
-
{ name: "maxExecutions", type: "uint256" }
|
|
227
|
-
];
|
|
228
|
-
function hashText(value) {
|
|
229
|
-
return (0, import_viem2.keccak256)((0, import_viem2.stringToHex)(value));
|
|
230
|
-
}
|
|
231
|
-
function semanticsValue(value) {
|
|
232
|
-
return value === "state" ? 0 : 1;
|
|
233
|
-
}
|
|
234
|
-
function hashConditionalIntentAuthorization(value) {
|
|
235
|
-
return (0, import_viem2.keccak256)((0, import_viem2.encodeAbiParameters)(authorizationTypes, [
|
|
236
|
-
hashText("spice.conditional.authorization"),
|
|
237
|
-
BigInt(CONDITIONAL_INTENT_VERSION),
|
|
238
|
-
value.owner,
|
|
239
|
-
hashText(value.clientId),
|
|
240
|
-
hashText(value.serviceId),
|
|
241
|
-
value.authorizationNonce,
|
|
242
|
-
value.executionDigest,
|
|
243
|
-
value.executionPlanHash,
|
|
244
|
-
value.triggerSpecificationHash,
|
|
245
|
-
value.evaluator,
|
|
246
|
-
semanticsValue(value.semantics),
|
|
247
|
-
value.maxSignalAgeSeconds,
|
|
248
|
-
value.validAfter,
|
|
249
|
-
value.expiresAt,
|
|
250
|
-
BigInt(value.maxExecutions)
|
|
251
|
-
]));
|
|
252
|
-
}
|
|
253
|
-
function getConditionalIntentId(authorizationHash) {
|
|
254
|
-
return (0, import_viem2.keccak256)((0, import_viem2.encodeAbiParameters)(
|
|
255
|
-
[{ type: "bytes32" }, { type: "bytes32" }],
|
|
256
|
-
[hashText("spice.conditional.intent-id"), authorizationHash]
|
|
257
|
-
));
|
|
258
|
-
}
|
|
259
|
-
function hashConditionalSignal(value, serviceId) {
|
|
260
|
-
return (0, import_viem2.keccak256)((0, import_viem2.encodeAbiParameters)(
|
|
261
|
-
[
|
|
262
|
-
{ name: "domain", type: "bytes32" },
|
|
263
|
-
{ name: "version", type: "uint256" },
|
|
264
|
-
{ name: "serviceIdHash", type: "bytes32" },
|
|
265
|
-
{ name: "intentId", type: "bytes32" },
|
|
266
|
-
{ name: "executionDigest", type: "bytes32" },
|
|
267
|
-
{ name: "triggerSpecificationHash", type: "bytes32" },
|
|
268
|
-
{ name: "signalIdHash", type: "bytes32" },
|
|
269
|
-
{ name: "observedAt", type: "uint256" },
|
|
270
|
-
{ name: "validUntil", type: "uint256" },
|
|
271
|
-
{ name: "satisfied", type: "bool" },
|
|
272
|
-
{ name: "evidenceHash", type: "bytes32" }
|
|
273
|
-
],
|
|
274
|
-
[hashText("spice.conditional.signal"), BigInt(CONDITIONAL_INTENT_VERSION), hashText(serviceId), value.intentId, value.executionDigest, value.triggerSpecificationHash, hashText(value.signalId), value.observedAt, value.validUntil, value.satisfied, value.evidenceHash ?? "0x" + "00".repeat(32)]
|
|
275
|
-
));
|
|
276
|
-
}
|
|
277
|
-
function hashConditionalCancellation(value) {
|
|
278
|
-
return (0, import_viem2.keccak256)((0, import_viem2.encodeAbiParameters)(
|
|
279
|
-
[
|
|
280
|
-
{ name: "domain", type: "bytes32" },
|
|
281
|
-
{ name: "version", type: "uint256" },
|
|
282
|
-
{ name: "owner", type: "address" },
|
|
283
|
-
{ name: "serviceIdHash", type: "bytes32" },
|
|
284
|
-
{ name: "intentId", type: "bytes32" },
|
|
285
|
-
{ name: "cancellationNonce", type: "uint256" },
|
|
286
|
-
{ name: "expiresAt", type: "uint256" }
|
|
287
|
-
],
|
|
288
|
-
[hashText("spice.conditional.cancel"), BigInt(CONDITIONAL_INTENT_VERSION), value.owner, hashText(value.serviceId), value.intentId, value.cancellationNonce, value.expiresAt]
|
|
289
|
-
));
|
|
290
|
-
}
|
|
291
|
-
function hashConditionalReadAuthorization(value) {
|
|
292
|
-
return (0, import_viem2.keccak256)((0, import_viem2.encodeAbiParameters)(
|
|
293
|
-
[
|
|
294
|
-
{ name: "domain", type: "bytes32" },
|
|
295
|
-
{ name: "version", type: "uint256" },
|
|
296
|
-
{ name: "owner", type: "address" },
|
|
297
|
-
{ name: "reader", type: "address" },
|
|
298
|
-
{ name: "serviceIdHash", type: "bytes32" },
|
|
299
|
-
{ name: "intentId", type: "bytes32" },
|
|
300
|
-
{ name: "expiresAt", type: "uint256" },
|
|
301
|
-
{ name: "nonce", type: "uint256" }
|
|
302
|
-
],
|
|
303
|
-
[hashText("spice.conditional.read"), BigInt(CONDITIONAL_INTENT_VERSION), value.owner, value.reader, hashText(value.serviceId), value.intentId ?? "0x" + "00".repeat(32), value.expiresAt, value.nonce]
|
|
304
|
-
));
|
|
305
|
-
}
|
|
306
|
-
function conditionalHashMessage(hash) {
|
|
307
|
-
return hash;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
142
|
// src/http.ts
|
|
311
143
|
var HttpError = class extends Error {
|
|
312
144
|
constructor(message, status, code, body) {
|
|
@@ -1313,7 +1145,7 @@ var CHAINS = {
|
|
|
1313
1145
|
};
|
|
1314
1146
|
|
|
1315
1147
|
// src/chains/index.ts
|
|
1316
|
-
var
|
|
1148
|
+
var import_viem2 = require("viem");
|
|
1317
1149
|
function getChainMeta(chainId) {
|
|
1318
1150
|
return CHAINS[chainId];
|
|
1319
1151
|
}
|
|
@@ -1342,7 +1174,7 @@ function getEscrowContract(chainId) {
|
|
|
1342
1174
|
}
|
|
1343
1175
|
function toViemChain(meta) {
|
|
1344
1176
|
if (meta.chainType === "starknet") return void 0;
|
|
1345
|
-
return (0,
|
|
1177
|
+
return (0, import_viem2.defineChain)({
|
|
1346
1178
|
id: meta.id,
|
|
1347
1179
|
name: meta.name,
|
|
1348
1180
|
nativeCurrency: meta.nativeCurrency,
|
|
@@ -3097,7 +2929,7 @@ var spicenetEscrowAbi = [
|
|
|
3097
2929
|
];
|
|
3098
2930
|
|
|
3099
2931
|
// src/swap.ts
|
|
3100
|
-
var
|
|
2932
|
+
var import_viem3 = require("viem");
|
|
3101
2933
|
function applySlippage(amount, slippage = 0.03) {
|
|
3102
2934
|
const slippageBps = BigInt(Math.floor((1 - slippage) * 1e4));
|
|
3103
2935
|
return amount * slippageBps / 10000n;
|
|
@@ -3116,8 +2948,8 @@ function buildUniV3SwapCalls(params) {
|
|
|
3116
2948
|
{
|
|
3117
2949
|
to: tokenIn,
|
|
3118
2950
|
value: 0n,
|
|
3119
|
-
data: (0,
|
|
3120
|
-
abi:
|
|
2951
|
+
data: (0, import_viem3.encodeFunctionData)({
|
|
2952
|
+
abi: import_viem3.erc20Abi,
|
|
3121
2953
|
functionName: "approve",
|
|
3122
2954
|
args: [config.swapRouter, amountIn]
|
|
3123
2955
|
})
|
|
@@ -3125,7 +2957,7 @@ function buildUniV3SwapCalls(params) {
|
|
|
3125
2957
|
{
|
|
3126
2958
|
to: config.swapRouter,
|
|
3127
2959
|
value: 0n,
|
|
3128
|
-
data: (0,
|
|
2960
|
+
data: (0, import_viem3.encodeFunctionData)({
|
|
3129
2961
|
abi: uniV3SwapRouterAbi,
|
|
3130
2962
|
functionName: "exactInputSingle",
|
|
3131
2963
|
args: [
|
|
@@ -3152,7 +2984,6 @@ var SPICE_COMBINED_FEE_RECIPIENT = SPICE_GAS_FEE_RECIPIENT;
|
|
|
3152
2984
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3153
2985
|
0 && (module.exports = {
|
|
3154
2986
|
CHAINS,
|
|
3155
|
-
CONDITIONAL_INTENT_VERSION,
|
|
3156
2987
|
ChainBatchHashAbi,
|
|
3157
2988
|
DELEGATE_ABI,
|
|
3158
2989
|
ERC20_ABI,
|
|
@@ -3173,7 +3004,6 @@ var SPICE_COMBINED_FEE_RECIPIENT = SPICE_GAS_FEE_RECIPIENT;
|
|
|
3173
3004
|
applySlippage,
|
|
3174
3005
|
areEquivalent,
|
|
3175
3006
|
buildUniV3SwapCalls,
|
|
3176
|
-
conditionalHashMessage,
|
|
3177
3007
|
convertAmountBetweenDecimals,
|
|
3178
3008
|
fetchWithRetry,
|
|
3179
3009
|
formatTokenAmount,
|
|
@@ -3182,7 +3012,6 @@ var SPICE_COMBINED_FEE_RECIPIENT = SPICE_GAS_FEE_RECIPIENT;
|
|
|
3182
3012
|
getChainIdsByNetwork,
|
|
3183
3013
|
getChainMeta,
|
|
3184
3014
|
getChainsByNetwork,
|
|
3185
|
-
getConditionalIntentId,
|
|
3186
3015
|
getDelegateContract,
|
|
3187
3016
|
getDeployment,
|
|
3188
3017
|
getEquivalenceGroup,
|
|
@@ -3200,11 +3029,6 @@ var SPICE_COMBINED_FEE_RECIPIENT = SPICE_GAS_FEE_RECIPIENT;
|
|
|
3200
3029
|
getTokensForChain,
|
|
3201
3030
|
getViemChain,
|
|
3202
3031
|
hashChainBatches,
|
|
3203
|
-
hashConditionalCancellation,
|
|
3204
|
-
hashConditionalExecutionPlan,
|
|
3205
|
-
hashConditionalIntentAuthorization,
|
|
3206
|
-
hashConditionalReadAuthorization,
|
|
3207
|
-
hashConditionalSignal,
|
|
3208
3032
|
isBtcDenominated,
|
|
3209
3033
|
isNativeToken,
|
|
3210
3034
|
isSpicenetChainId,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from "./config.js";
|
|
2
2
|
export * from "./types.js";
|
|
3
3
|
export * from "./authorization.js";
|
|
4
|
-
export * from "./conditionalIntents.js";
|
|
5
4
|
export * from "./relayer.js";
|
|
6
5
|
export * from "./core.js";
|
|
7
6
|
export * from "./status.js";
|
|
@@ -14,4 +13,5 @@ export * from "./abis/index.js";
|
|
|
14
13
|
export * from "./swap.js";
|
|
15
14
|
export * from "./api.js";
|
|
16
15
|
export * from "./constants.js";
|
|
16
|
+
export type { FeePolicy, FeeAssessment } from "./fees.js";
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,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;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAE/B,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -51,166 +51,6 @@ async function getRecentBlock(publicClient) {
|
|
|
51
51
|
return await publicClient.getBlockNumber();
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
// src/conditionalIntents.ts
|
|
55
|
-
import { encodeAbiParameters as encodeAbiParameters2, keccak256 as keccak2562, stringToHex } from "viem";
|
|
56
|
-
var CONDITIONAL_INTENT_VERSION = 1;
|
|
57
|
-
var callTuple = [
|
|
58
|
-
{ name: "to", type: "address" },
|
|
59
|
-
{ name: "value", type: "uint256" },
|
|
60
|
-
{ name: "data", type: "bytes" }
|
|
61
|
-
];
|
|
62
|
-
var transferTuple = [
|
|
63
|
-
{ name: "fromKind", type: "uint8" },
|
|
64
|
-
{ name: "fromAddress", type: "address" },
|
|
65
|
-
{ name: "to", type: "address" },
|
|
66
|
-
{ name: "token", type: "address" },
|
|
67
|
-
{ name: "amount", type: "uint256" }
|
|
68
|
-
];
|
|
69
|
-
var batchTuple = [
|
|
70
|
-
{ name: "chainId", type: "uint256" },
|
|
71
|
-
{ name: "calls", type: "tuple[]", components: callTuple },
|
|
72
|
-
{ name: "tokenTransfers", type: "tuple[]", components: transferTuple }
|
|
73
|
-
];
|
|
74
|
-
var zeroAddress = "0x0000000000000000000000000000000000000000";
|
|
75
|
-
function encodePlanTransfer(transfer) {
|
|
76
|
-
if (transfer.from === "solver") return [1, zeroAddress, transfer.to, transfer.token, transfer.amount];
|
|
77
|
-
if (transfer.from === "escrow") return [2, zeroAddress, transfer.to, transfer.token, transfer.amount];
|
|
78
|
-
return [0, transfer.from, transfer.to, transfer.token, transfer.amount];
|
|
79
|
-
}
|
|
80
|
-
function hashConditionalExecutionPlan(batches, delegationAuthorizations = []) {
|
|
81
|
-
const normalized = batches.map((batch) => [
|
|
82
|
-
BigInt(batch.chainId),
|
|
83
|
-
batch.calls,
|
|
84
|
-
batch.tokenTransfers.map(encodePlanTransfer)
|
|
85
|
-
]);
|
|
86
|
-
return keccak2562(encodeAbiParameters2(
|
|
87
|
-
[
|
|
88
|
-
{ type: "bytes32" },
|
|
89
|
-
{ type: "uint256" },
|
|
90
|
-
{ type: "tuple[]", components: batchTuple },
|
|
91
|
-
{ type: "tuple[]", components: [
|
|
92
|
-
{ name: "address", type: "address" },
|
|
93
|
-
{ name: "chainId", type: "uint256" },
|
|
94
|
-
{ name: "nonce", type: "uint256" },
|
|
95
|
-
{ name: "r", type: "bytes32" },
|
|
96
|
-
{ name: "s", type: "bytes32" },
|
|
97
|
-
{ name: "yParity", type: "uint8" }
|
|
98
|
-
] }
|
|
99
|
-
],
|
|
100
|
-
[
|
|
101
|
-
keccak2562(stringToHex("spice.conditional.execution-plan")),
|
|
102
|
-
BigInt(CONDITIONAL_INTENT_VERSION),
|
|
103
|
-
normalized,
|
|
104
|
-
delegationAuthorizations.map((auth) => [
|
|
105
|
-
auth.address,
|
|
106
|
-
BigInt(auth.chainId),
|
|
107
|
-
BigInt(auth.nonce),
|
|
108
|
-
auth.r,
|
|
109
|
-
auth.s,
|
|
110
|
-
auth.yParity ?? 0
|
|
111
|
-
])
|
|
112
|
-
]
|
|
113
|
-
));
|
|
114
|
-
}
|
|
115
|
-
var authorizationTypes = [
|
|
116
|
-
{ name: "domain", type: "bytes32" },
|
|
117
|
-
{ name: "version", type: "uint256" },
|
|
118
|
-
{ name: "owner", type: "address" },
|
|
119
|
-
{ name: "clientIdHash", type: "bytes32" },
|
|
120
|
-
{ name: "serviceIdHash", type: "bytes32" },
|
|
121
|
-
{ name: "authorizationNonce", type: "uint256" },
|
|
122
|
-
{ name: "executionDigest", type: "bytes32" },
|
|
123
|
-
{ name: "executionPlanHash", type: "bytes32" },
|
|
124
|
-
{ name: "triggerSpecificationHash", type: "bytes32" },
|
|
125
|
-
{ name: "evaluator", type: "address" },
|
|
126
|
-
{ name: "semantics", type: "uint8" },
|
|
127
|
-
{ name: "maxSignalAgeSeconds", type: "uint256" },
|
|
128
|
-
{ name: "validAfter", type: "uint256" },
|
|
129
|
-
{ name: "expiresAt", type: "uint256" },
|
|
130
|
-
{ name: "maxExecutions", type: "uint256" }
|
|
131
|
-
];
|
|
132
|
-
function hashText(value) {
|
|
133
|
-
return keccak2562(stringToHex(value));
|
|
134
|
-
}
|
|
135
|
-
function semanticsValue(value) {
|
|
136
|
-
return value === "state" ? 0 : 1;
|
|
137
|
-
}
|
|
138
|
-
function hashConditionalIntentAuthorization(value) {
|
|
139
|
-
return keccak2562(encodeAbiParameters2(authorizationTypes, [
|
|
140
|
-
hashText("spice.conditional.authorization"),
|
|
141
|
-
BigInt(CONDITIONAL_INTENT_VERSION),
|
|
142
|
-
value.owner,
|
|
143
|
-
hashText(value.clientId),
|
|
144
|
-
hashText(value.serviceId),
|
|
145
|
-
value.authorizationNonce,
|
|
146
|
-
value.executionDigest,
|
|
147
|
-
value.executionPlanHash,
|
|
148
|
-
value.triggerSpecificationHash,
|
|
149
|
-
value.evaluator,
|
|
150
|
-
semanticsValue(value.semantics),
|
|
151
|
-
value.maxSignalAgeSeconds,
|
|
152
|
-
value.validAfter,
|
|
153
|
-
value.expiresAt,
|
|
154
|
-
BigInt(value.maxExecutions)
|
|
155
|
-
]));
|
|
156
|
-
}
|
|
157
|
-
function getConditionalIntentId(authorizationHash) {
|
|
158
|
-
return keccak2562(encodeAbiParameters2(
|
|
159
|
-
[{ type: "bytes32" }, { type: "bytes32" }],
|
|
160
|
-
[hashText("spice.conditional.intent-id"), authorizationHash]
|
|
161
|
-
));
|
|
162
|
-
}
|
|
163
|
-
function hashConditionalSignal(value, serviceId) {
|
|
164
|
-
return keccak2562(encodeAbiParameters2(
|
|
165
|
-
[
|
|
166
|
-
{ name: "domain", type: "bytes32" },
|
|
167
|
-
{ name: "version", type: "uint256" },
|
|
168
|
-
{ name: "serviceIdHash", type: "bytes32" },
|
|
169
|
-
{ name: "intentId", type: "bytes32" },
|
|
170
|
-
{ name: "executionDigest", type: "bytes32" },
|
|
171
|
-
{ name: "triggerSpecificationHash", type: "bytes32" },
|
|
172
|
-
{ name: "signalIdHash", type: "bytes32" },
|
|
173
|
-
{ name: "observedAt", type: "uint256" },
|
|
174
|
-
{ name: "validUntil", type: "uint256" },
|
|
175
|
-
{ name: "satisfied", type: "bool" },
|
|
176
|
-
{ name: "evidenceHash", type: "bytes32" }
|
|
177
|
-
],
|
|
178
|
-
[hashText("spice.conditional.signal"), BigInt(CONDITIONAL_INTENT_VERSION), hashText(serviceId), value.intentId, value.executionDigest, value.triggerSpecificationHash, hashText(value.signalId), value.observedAt, value.validUntil, value.satisfied, value.evidenceHash ?? "0x" + "00".repeat(32)]
|
|
179
|
-
));
|
|
180
|
-
}
|
|
181
|
-
function hashConditionalCancellation(value) {
|
|
182
|
-
return keccak2562(encodeAbiParameters2(
|
|
183
|
-
[
|
|
184
|
-
{ name: "domain", type: "bytes32" },
|
|
185
|
-
{ name: "version", type: "uint256" },
|
|
186
|
-
{ name: "owner", type: "address" },
|
|
187
|
-
{ name: "serviceIdHash", type: "bytes32" },
|
|
188
|
-
{ name: "intentId", type: "bytes32" },
|
|
189
|
-
{ name: "cancellationNonce", type: "uint256" },
|
|
190
|
-
{ name: "expiresAt", type: "uint256" }
|
|
191
|
-
],
|
|
192
|
-
[hashText("spice.conditional.cancel"), BigInt(CONDITIONAL_INTENT_VERSION), value.owner, hashText(value.serviceId), value.intentId, value.cancellationNonce, value.expiresAt]
|
|
193
|
-
));
|
|
194
|
-
}
|
|
195
|
-
function hashConditionalReadAuthorization(value) {
|
|
196
|
-
return keccak2562(encodeAbiParameters2(
|
|
197
|
-
[
|
|
198
|
-
{ name: "domain", type: "bytes32" },
|
|
199
|
-
{ name: "version", type: "uint256" },
|
|
200
|
-
{ name: "owner", type: "address" },
|
|
201
|
-
{ name: "reader", type: "address" },
|
|
202
|
-
{ name: "serviceIdHash", type: "bytes32" },
|
|
203
|
-
{ name: "intentId", type: "bytes32" },
|
|
204
|
-
{ name: "expiresAt", type: "uint256" },
|
|
205
|
-
{ name: "nonce", type: "uint256" }
|
|
206
|
-
],
|
|
207
|
-
[hashText("spice.conditional.read"), BigInt(CONDITIONAL_INTENT_VERSION), value.owner, value.reader, hashText(value.serviceId), value.intentId ?? "0x" + "00".repeat(32), value.expiresAt, value.nonce]
|
|
208
|
-
));
|
|
209
|
-
}
|
|
210
|
-
function conditionalHashMessage(hash) {
|
|
211
|
-
return hash;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
54
|
// src/http.ts
|
|
215
55
|
var HttpError = class extends Error {
|
|
216
56
|
constructor(message, status, code, body) {
|
|
@@ -3055,7 +2895,6 @@ var SPICE_PLATFORM_FEE_RECIPIENT = "0xa4bB4c1D188B94c0cF691Dad213dE24169fA0A50";
|
|
|
3055
2895
|
var SPICE_COMBINED_FEE_RECIPIENT = SPICE_GAS_FEE_RECIPIENT;
|
|
3056
2896
|
export {
|
|
3057
2897
|
CHAINS,
|
|
3058
|
-
CONDITIONAL_INTENT_VERSION,
|
|
3059
2898
|
ChainBatchHashAbi,
|
|
3060
2899
|
DELEGATE_ABI,
|
|
3061
2900
|
ERC20_ABI,
|
|
@@ -3076,7 +2915,6 @@ export {
|
|
|
3076
2915
|
applySlippage,
|
|
3077
2916
|
areEquivalent,
|
|
3078
2917
|
buildUniV3SwapCalls,
|
|
3079
|
-
conditionalHashMessage,
|
|
3080
2918
|
convertAmountBetweenDecimals,
|
|
3081
2919
|
fetchWithRetry,
|
|
3082
2920
|
formatTokenAmount,
|
|
@@ -3085,7 +2923,6 @@ export {
|
|
|
3085
2923
|
getChainIdsByNetwork,
|
|
3086
2924
|
getChainMeta,
|
|
3087
2925
|
getChainsByNetwork,
|
|
3088
|
-
getConditionalIntentId,
|
|
3089
2926
|
getDelegateContract,
|
|
3090
2927
|
getDeployment,
|
|
3091
2928
|
getEquivalenceGroup,
|
|
@@ -3103,11 +2940,6 @@ export {
|
|
|
3103
2940
|
getTokensForChain,
|
|
3104
2941
|
getViemChain,
|
|
3105
2942
|
hashChainBatches,
|
|
3106
|
-
hashConditionalCancellation,
|
|
3107
|
-
hashConditionalExecutionPlan,
|
|
3108
|
-
hashConditionalIntentAuthorization,
|
|
3109
|
-
hashConditionalReadAuthorization,
|
|
3110
|
-
hashConditionalSignal,
|
|
3111
2943
|
isBtcDenominated,
|
|
3112
2944
|
isNativeToken,
|
|
3113
2945
|
isSpicenetChainId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spicenet-io/spiceflow-core",
|
|
3
|
-
"version": "0.8.1
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
"validate:tokens": "tsx scripts/validate-tokens.ts",
|
|
13
13
|
"generate:logos": "tsx scripts/generate-logos.ts && prettier --write src/logos.ts --log-level silent",
|
|
14
14
|
"build": "bun run generate:logos && bun run validate:tokens && rimraf dist && tsup src/index.ts --format esm,cjs --out-dir dist --clean && tsc -p tsconfig.json --emitDeclarationOnly",
|
|
15
|
-
"test:conditional-intents": "bun test test/conditionalIntents.test.ts",
|
|
16
15
|
"setup:hooks": "cp scripts/hooks/pre-push .git/hooks/pre-push && chmod +x .git/hooks/pre-push",
|
|
17
16
|
"format": "prettier --write . --ignore-unknown",
|
|
18
17
|
"docs:build": "typedoc --options typedoc.json",
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { Address, Hash, Hex } from "viem";
|
|
2
|
-
import type { Call, TokenTransferConfig } from "./types.js";
|
|
3
|
-
export declare const CONDITIONAL_INTENT_VERSION: 1;
|
|
4
|
-
export type ConditionalTriggerSemantics = "state" | "event";
|
|
5
|
-
export interface ConditionalExecutionBatch {
|
|
6
|
-
chainId: bigint | number;
|
|
7
|
-
calls: Call[];
|
|
8
|
-
tokenTransfers: TokenTransferConfig[];
|
|
9
|
-
}
|
|
10
|
-
export interface ConditionalDelegationAuthorization {
|
|
11
|
-
address: Address;
|
|
12
|
-
chainId: bigint | number;
|
|
13
|
-
nonce: bigint | number;
|
|
14
|
-
r: Hex;
|
|
15
|
-
s: Hex;
|
|
16
|
-
yParity?: number;
|
|
17
|
-
}
|
|
18
|
-
export interface ConditionalIntentAuthorization {
|
|
19
|
-
owner: Address;
|
|
20
|
-
clientId: string;
|
|
21
|
-
serviceId: string;
|
|
22
|
-
authorizationNonce: bigint;
|
|
23
|
-
executionDigest: Hash;
|
|
24
|
-
executionPlanHash: Hash;
|
|
25
|
-
triggerSpecificationHash: Hash;
|
|
26
|
-
evaluator: Address;
|
|
27
|
-
semantics: ConditionalTriggerSemantics;
|
|
28
|
-
maxSignalAgeSeconds: bigint;
|
|
29
|
-
validAfter: bigint;
|
|
30
|
-
expiresAt: bigint;
|
|
31
|
-
maxExecutions: 1;
|
|
32
|
-
}
|
|
33
|
-
export interface ConditionalSignal {
|
|
34
|
-
intentId: Hash;
|
|
35
|
-
executionDigest: Hash;
|
|
36
|
-
triggerSpecificationHash: Hash;
|
|
37
|
-
signalId: string;
|
|
38
|
-
observedAt: bigint;
|
|
39
|
-
validUntil: bigint;
|
|
40
|
-
satisfied: true;
|
|
41
|
-
evidenceHash?: Hash;
|
|
42
|
-
}
|
|
43
|
-
export interface ConditionalCancellation {
|
|
44
|
-
owner: Address;
|
|
45
|
-
serviceId: string;
|
|
46
|
-
intentId: Hash;
|
|
47
|
-
cancellationNonce: bigint;
|
|
48
|
-
expiresAt: bigint;
|
|
49
|
-
}
|
|
50
|
-
export interface ConditionalReadAuthorization {
|
|
51
|
-
owner: Address;
|
|
52
|
-
reader: Address;
|
|
53
|
-
serviceId: string;
|
|
54
|
-
/** zero hash grants owner-scoped list reads; otherwise it scopes one intent. */
|
|
55
|
-
intentId: Hash | null;
|
|
56
|
-
expiresAt: bigint;
|
|
57
|
-
nonce: bigint;
|
|
58
|
-
}
|
|
59
|
-
/** Commits to ordered calls and service-consumed funding metadata, never signatures or display text. */
|
|
60
|
-
export declare function hashConditionalExecutionPlan(batches: ConditionalExecutionBatch[], delegationAuthorizations?: ConditionalDelegationAuthorization[]): Hash;
|
|
61
|
-
/** Hash to pass to the wallet's existing EIP-191 signMessage({ message: { raw } }) path. */
|
|
62
|
-
export declare function hashConditionalIntentAuthorization(value: ConditionalIntentAuthorization): Hash;
|
|
63
|
-
export declare function getConditionalIntentId(authorizationHash: Hash): Hash;
|
|
64
|
-
export declare function hashConditionalSignal(value: ConditionalSignal, serviceId: string): Hash;
|
|
65
|
-
export declare function hashConditionalCancellation(value: ConditionalCancellation): Hash;
|
|
66
|
-
export declare function hashConditionalReadAuthorization(value: ConditionalReadAuthorization): Hash;
|
|
67
|
-
export declare function conditionalHashMessage(hash: Hash): Hex;
|
|
68
|
-
//# sourceMappingURL=conditionalIntents.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conditionalIntents.d.ts","sourceRoot":"","sources":["../src/conditionalIntents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAE/C,OAAO,KAAK,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAE5D,eAAO,MAAM,0BAA0B,EA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