@usesigil/kit 0.8.1 → 0.11.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.
- package/README.md +350 -164
- package/dist/alt-config.d.ts +4 -2
- package/dist/alt-config.d.ts.map +1 -1
- package/dist/alt-config.js +4 -2
- package/dist/alt-config.js.map +1 -1
- package/dist/alt-loader.d.ts.map +1 -1
- package/dist/alt-loader.js +2 -1
- package/dist/alt-loader.js.map +1 -1
- package/dist/balance-tracker.d.ts.map +1 -1
- package/dist/balance-tracker.js +2 -1
- package/dist/balance-tracker.js.map +1 -1
- package/dist/create-vault.d.ts +40 -3
- package/dist/create-vault.d.ts.map +1 -1
- package/dist/create-vault.js +52 -18
- package/dist/create-vault.js.map +1 -1
- package/dist/dashboard/discover.d.ts.map +1 -1
- package/dist/dashboard/discover.js +2 -1
- package/dist/dashboard/discover.js.map +1 -1
- package/dist/dashboard/from-json.d.ts +1 -0
- package/dist/dashboard/from-json.d.ts.map +1 -1
- package/dist/dashboard/from-json.js +3 -1
- package/dist/dashboard/from-json.js.map +1 -1
- package/dist/dashboard/mutations.d.ts.map +1 -1
- package/dist/dashboard/mutations.js +2 -1
- package/dist/dashboard/mutations.js.map +1 -1
- package/dist/dashboard/reads.d.ts.map +1 -1
- package/dist/dashboard/reads.js +5 -4
- package/dist/dashboard/reads.js.map +1 -1
- package/dist/errors/codes.d.ts +8 -2
- package/dist/errors/codes.d.ts.map +1 -1
- package/dist/errors/codes.js +6 -0
- package/dist/errors/codes.js.map +1 -1
- package/dist/errors/context.d.ts +17 -1
- package/dist/errors/context.d.ts.map +1 -1
- package/dist/errors/public.d.ts +24 -0
- package/dist/errors/public.d.ts.map +1 -0
- package/dist/errors/public.js +30 -0
- package/dist/errors/public.js.map +1 -0
- package/dist/errors/walk.d.ts.map +1 -1
- package/dist/errors/walk.js +2 -1
- package/dist/errors/walk.js.map +1 -1
- package/dist/helpers/ata.d.ts +73 -0
- package/dist/helpers/ata.d.ts.map +1 -0
- package/dist/helpers/ata.js +107 -0
- package/dist/helpers/ata.js.map +1 -0
- package/dist/helpers/parse-usd.d.ts +43 -0
- package/dist/helpers/parse-usd.d.ts.map +1 -0
- package/dist/helpers/parse-usd.js +81 -0
- package/dist/helpers/parse-usd.js.map +1 -0
- package/dist/helpers/validate-cap-aggregate.d.ts +41 -0
- package/dist/helpers/validate-cap-aggregate.d.ts.map +1 -0
- package/dist/helpers/validate-cap-aggregate.js +61 -0
- package/dist/helpers/validate-cap-aggregate.js.map +1 -0
- package/dist/hooks.d.ts +114 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +118 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +17 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -17
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +77 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +153 -0
- package/dist/logger.js.map +1 -0
- package/dist/plugin.d.ts +110 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +119 -0
- package/dist/plugin.js.map +1 -0
- package/dist/presets.d.ts +73 -6
- package/dist/presets.d.ts.map +1 -1
- package/dist/presets.js +75 -6
- package/dist/presets.js.map +1 -1
- package/dist/priority-fees.d.ts.map +1 -1
- package/dist/priority-fees.js +3 -2
- package/dist/priority-fees.js.map +1 -1
- package/dist/react/index.d.ts +69 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +118 -0
- package/dist/react/index.js.map +1 -0
- package/dist/seal.d.ts +113 -15
- package/dist/seal.d.ts.map +1 -1
- package/dist/seal.js +269 -10
- package/dist/seal.js.map +1 -1
- package/dist/shield.d.ts.map +1 -1
- package/dist/shield.js +8 -7
- package/dist/shield.js.map +1 -1
- package/dist/sigil.d.ts +187 -0
- package/dist/sigil.d.ts.map +1 -0
- package/dist/sigil.js +194 -0
- package/dist/sigil.js.map +1 -0
- package/dist/tee/verify.d.ts.map +1 -1
- package/dist/tee/verify.js +6 -5
- package/dist/tee/verify.js.map +1 -1
- package/dist/transaction-executor.d.ts.map +1 -1
- package/dist/transaction-executor.js +3 -2
- package/dist/transaction-executor.js.map +1 -1
- package/dist/types.d.ts +3 -31
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +45 -106
- package/dist/types.js.map +1 -1
- package/dist/vault-handle.d.ts +123 -0
- package/dist/vault-handle.d.ts.map +1 -0
- package/dist/vault-handle.js +136 -0
- package/dist/vault-handle.js.map +1 -0
- package/dist/x402/shielded-fetch.d.ts.map +1 -1
- package/dist/x402/shielded-fetch.js +7 -4
- package/dist/x402/shielded-fetch.js.map +1 -1
- package/package.json +21 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-executor.js","sourceRoot":"","sources":["../src/transaction-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAUH,OAAO,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAC;AAEnE,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,WAAW,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EACL,kBAAkB,EAClB,QAAQ,EACR,oBAAoB,GAKrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAmB,MAAM,aAAa,CAAC;AAChE,OAAO,EACL,cAAc,EACd,aAAa,EACb,yBAAyB,GAE1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,mCAAmC,EACnC,gCAAgC,GACjC,MAAM,mBAAmB,CAAC;AAkE3B,+EAA+E;AAE/E,MAAM,OAAO,mBAAmB;IACrB,GAAG,CAAoB;IACvB,KAAK,CAAoB;IACjB,cAAc,CAAiB;IAC/B,cAAc,CAAwB;IACtC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AC;YACJ,CAAC;YAED,6DAA6D;YAC7D,IAAI,UAAU,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACpC,IAAI,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAAC;oBACxD,MAAM,IAAI,aAAa,CACrB,gCAAgC,EAChC,mDAAmD,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EACrF,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CACxD,CAAC;gBACJ,CAAC;gBACD,YAAY,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;YAC7C,CAAC;YAED,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC;YAC1B,aAAa,GAAG,UAAU,CAAC,aAAa,CAAC;YACzC,IAAI,YAAY,EAAE,CAAC;gBACjB,QAAQ,GAAG,YAAY,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,mCAAmC;QACnC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QAE3D,kDAAkD;QAClD,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAExD,OAAO;YACL,SAAS;YACT,aAAa;YACb,IAAI,EAAE,OAAO;YACb,MAAM;YACN,QAAQ,EAAE,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;SAC7D,CAAC;IACJ,CAAC;CACF"}
|
package/dist/types.d.ts
CHANGED
|
@@ -80,12 +80,6 @@ export declare const MAX_ALLOWED_PROTOCOLS = 10;
|
|
|
80
80
|
export declare const FULL_CAPABILITY: CapabilityTier;
|
|
81
81
|
/** @deprecated Use FULL_CAPABILITY instead. Kept for backward compatibility. */
|
|
82
82
|
export declare const FULL_PERMISSIONS: CapabilityTier;
|
|
83
|
-
export declare const SWAP_ONLY: bigint;
|
|
84
|
-
export declare const PERPS_ONLY: bigint;
|
|
85
|
-
export declare const TRANSFER_ONLY: bigint;
|
|
86
|
-
export declare const ESCROW_ONLY: bigint;
|
|
87
|
-
/** Full perps permission set: open, close, increase, decrease, deposit, withdraw, add/remove collateral, triggers, limits */
|
|
88
|
-
export declare const PERPS_FULL: bigint;
|
|
89
83
|
export declare const MAX_ESCROW_DURATION = 2592000;
|
|
90
84
|
/** Maximum u64 value — used for BigInt clamping to match on-chain Rust math. */
|
|
91
85
|
export declare const U64_MAX: bigint;
|
|
@@ -144,35 +138,13 @@ export declare function toInstruction(ix: {
|
|
|
144
138
|
}): Instruction;
|
|
145
139
|
/** Check if a mint address is a recognized stablecoin (network-aware). */
|
|
146
140
|
export declare function isStablecoinMint(mint: Address, network: Network): boolean;
|
|
147
|
-
/**
|
|
148
|
-
* @deprecated v6: Permission bits replaced by capability bitmask. Retained for backward compat.
|
|
149
|
-
* Permission bit mapping for each legacy ActionType variant (21 total).
|
|
150
|
-
*/
|
|
151
|
-
export declare const ACTION_PERMISSION_MAP: Record<string, bigint>;
|
|
152
|
-
/** Check if a permission bitmask includes the permission for a given action type */
|
|
153
|
-
export declare function hasPermission(permissions: bigint, actionType: string): boolean;
|
|
154
|
-
/** Convert a permission bitmask to an array of action type strings */
|
|
155
|
-
export declare function permissionsToStrings(permissions: bigint): string[];
|
|
156
|
-
/**
|
|
157
|
-
* Convert an array of action type strings to a permission bitmask.
|
|
158
|
-
* Inverse of permissionsToStrings().
|
|
159
|
-
*
|
|
160
|
-
* @throws Error if any string is not a recognized action type.
|
|
161
|
-
* @example stringsToPermissions(["swap", "deposit"]) // => 33n (bit 0 + bit 5)
|
|
162
|
-
*/
|
|
163
|
-
export declare function stringsToPermissions(strings: string[]): bigint;
|
|
164
141
|
/**
|
|
165
142
|
* Parse an action type to its string key.
|
|
166
|
-
* Accepts either a numeric ActionType enum value or an
|
|
143
|
+
* Accepts either a numeric ActionType enum value (0-20) or an
|
|
144
|
+
* Anchor-style `{ Swap: {} }` object. Returns `undefined` for
|
|
145
|
+
* out-of-range numeric values or empty objects.
|
|
167
146
|
*/
|
|
168
147
|
export declare function parseActionType(actionType: number | Record<string, unknown>): string | undefined;
|
|
169
|
-
/** Builder for constructing permission bitmasks */
|
|
170
|
-
export declare class PermissionBuilder {
|
|
171
|
-
private permissions;
|
|
172
|
-
add(actionType: string): this;
|
|
173
|
-
remove(actionType: string): this;
|
|
174
|
-
build(): bigint;
|
|
175
|
-
}
|
|
176
148
|
export type PositionEffect = "increment" | "decrement" | "none";
|
|
177
149
|
export declare function isSpendingAction(actionType: string): boolean;
|
|
178
150
|
export declare function getPositionEffect(actionType: string): PositionEffect;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAM7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAGtE,oFAAoF;AACpF,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC;AAC/B,YAAY,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACpE,YAAY,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACtE,YAAY,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,YAAY,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACpE,YAAY,EAAE,eAAe,EAAE,MA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
* and `bigint` instead of `BN`.
|
|
6
6
|
*/
|
|
7
7
|
import { SigilSdkDomainError } from "./errors/sdk.js";
|
|
8
|
-
import { SIGIL_ERROR__SDK__INVALID_NETWORK
|
|
8
|
+
import { SIGIL_ERROR__SDK__INVALID_NETWORK } from "./errors/codes.js";
|
|
9
9
|
// Re-export the program address from generated code
|
|
10
10
|
export { SIGIL_PROGRAM_ADDRESS } from "./generated/programs/sigil.js";
|
|
11
11
|
// ─── Fee Constants ────────────────────────────────────────────────────────────
|
|
@@ -50,24 +50,11 @@ export const MAX_ALLOWED_PROTOCOLS = 10;
|
|
|
50
50
|
export const FULL_CAPABILITY = capability(2n);
|
|
51
51
|
/** @deprecated Use FULL_CAPABILITY instead. Kept for backward compatibility. */
|
|
52
52
|
export const FULL_PERMISSIONS = FULL_CAPABILITY;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
export const PERPS_FULL = PERPS_ONLY |
|
|
59
|
-
(1n << 5n) |
|
|
60
|
-
(1n << 6n) |
|
|
61
|
-
(1n << 8n) |
|
|
62
|
-
(1n << 9n) |
|
|
63
|
-
(1n << 10n) |
|
|
64
|
-
(1n << 11n) |
|
|
65
|
-
(1n << 12n) |
|
|
66
|
-
(1n << 13n) |
|
|
67
|
-
(1n << 14n) |
|
|
68
|
-
(1n << 15n) |
|
|
69
|
-
(1n << 16n) |
|
|
70
|
-
(1n << 17n);
|
|
53
|
+
// Legacy 21-bit permission bitmasks (SWAP_ONLY, PERPS_ONLY, TRANSFER_ONLY,
|
|
54
|
+
// ESCROW_ONLY, PERPS_FULL) were removed in the A11 cleanup — they encoded a
|
|
55
|
+
// pre-v6 permission model the on-chain program no longer supports. Use
|
|
56
|
+
// FULL_CAPABILITY (2n) for operator agents and put granular per-action
|
|
57
|
+
// restrictions in InstructionConstraints.
|
|
71
58
|
// ─── Escrow Constants ─────────────────────────────────────────────────────────
|
|
72
59
|
export const MAX_ESCROW_DURATION = 2_592_000; // 30 days in seconds
|
|
73
60
|
// ─── u64 Boundary ────────────────────────────────────────────────────────────
|
|
@@ -177,103 +164,55 @@ export function isStablecoinMint(mint, network) {
|
|
|
177
164
|
}
|
|
178
165
|
return mint === USDC_MINT_MAINNET || mint === USDT_MINT_MAINNET;
|
|
179
166
|
}
|
|
180
|
-
// ───
|
|
167
|
+
// ─── ActionType Parsing ──────────────────────────────────────────────────────
|
|
168
|
+
//
|
|
169
|
+
// The v6 on-chain program eliminated per-action permission bits in favor of a
|
|
170
|
+
// 2-bit capability enum. `parseActionType` is preserved because
|
|
171
|
+
// `event-analytics.ts` still reads numeric ActionType values from on-chain
|
|
172
|
+
// events and needs the string label for UI display. It does NOT grant or
|
|
173
|
+
// check any permission — the v6 program enforces capability (0/1/2), not
|
|
174
|
+
// ActionType.
|
|
181
175
|
/**
|
|
182
|
-
*
|
|
183
|
-
*
|
|
176
|
+
* Canonical action-type names indexed by the v6 on-chain ActionType enum
|
|
177
|
+
* variant. Index 0 = `Swap`, index 20 = `RefundEscrow`. This is the ONLY
|
|
178
|
+
* permission-related state still in this file post-A11 — it powers
|
|
179
|
+
* `parseActionType` for event decoding and nothing else.
|
|
184
180
|
*/
|
|
185
|
-
|
|
186
|
-
swap
|
|
187
|
-
openPosition
|
|
188
|
-
closePosition
|
|
189
|
-
increasePosition
|
|
190
|
-
decreasePosition
|
|
191
|
-
deposit
|
|
192
|
-
withdraw
|
|
193
|
-
transfer
|
|
194
|
-
addCollateral
|
|
195
|
-
removeCollateral
|
|
196
|
-
placeTriggerOrder
|
|
197
|
-
editTriggerOrder
|
|
198
|
-
cancelTriggerOrder
|
|
199
|
-
placeLimitOrder
|
|
200
|
-
editLimitOrder
|
|
201
|
-
cancelLimitOrder
|
|
202
|
-
swapAndOpenPosition
|
|
203
|
-
closeAndSwapPosition
|
|
204
|
-
createEscrow
|
|
205
|
-
settleEscrow
|
|
206
|
-
refundEscrow
|
|
207
|
-
|
|
208
|
-
/** Check if a permission bitmask includes the permission for a given action type */
|
|
209
|
-
export function hasPermission(permissions, actionType) {
|
|
210
|
-
if (!Object.prototype.hasOwnProperty.call(ACTION_PERMISSION_MAP, actionType)) {
|
|
211
|
-
return false;
|
|
212
|
-
}
|
|
213
|
-
const bit = ACTION_PERMISSION_MAP[actionType];
|
|
214
|
-
return (permissions & bit) !== 0n;
|
|
215
|
-
}
|
|
216
|
-
/** Convert a permission bitmask to an array of action type strings */
|
|
217
|
-
export function permissionsToStrings(permissions) {
|
|
218
|
-
const result = [];
|
|
219
|
-
for (const [name, bit] of Object.entries(ACTION_PERMISSION_MAP)) {
|
|
220
|
-
if ((permissions & bit) !== 0n) {
|
|
221
|
-
result.push(name);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return result;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Convert an array of action type strings to a permission bitmask.
|
|
228
|
-
* Inverse of permissionsToStrings().
|
|
229
|
-
*
|
|
230
|
-
* @throws Error if any string is not a recognized action type.
|
|
231
|
-
* @example stringsToPermissions(["swap", "deposit"]) // => 33n (bit 0 + bit 5)
|
|
232
|
-
*/
|
|
233
|
-
export function stringsToPermissions(strings) {
|
|
234
|
-
let result = 0n;
|
|
235
|
-
for (const s of strings) {
|
|
236
|
-
if (!Object.prototype.hasOwnProperty.call(ACTION_PERMISSION_MAP, s)) {
|
|
237
|
-
const valid = Object.keys(ACTION_PERMISSION_MAP).join(", ");
|
|
238
|
-
throw new SigilSdkDomainError(SIGIL_ERROR__SDK__INVALID_ACTION_TYPE, `Unknown action type: "${s}". Valid types: ${valid}`, {
|
|
239
|
-
context: { received: s, valid: Object.keys(ACTION_PERMISSION_MAP) },
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
const bit = ACTION_PERMISSION_MAP[s];
|
|
243
|
-
result |= bit;
|
|
244
|
-
}
|
|
245
|
-
return result;
|
|
246
|
-
}
|
|
181
|
+
const ACTION_TYPE_NAMES_BY_INDEX = [
|
|
182
|
+
"swap", // 0
|
|
183
|
+
"openPosition", // 1
|
|
184
|
+
"closePosition", // 2
|
|
185
|
+
"increasePosition", // 3
|
|
186
|
+
"decreasePosition", // 4
|
|
187
|
+
"deposit", // 5
|
|
188
|
+
"withdraw", // 6
|
|
189
|
+
"transfer", // 7
|
|
190
|
+
"addCollateral", // 8
|
|
191
|
+
"removeCollateral", // 9
|
|
192
|
+
"placeTriggerOrder", // 10
|
|
193
|
+
"editTriggerOrder", // 11
|
|
194
|
+
"cancelTriggerOrder", // 12
|
|
195
|
+
"placeLimitOrder", // 13
|
|
196
|
+
"editLimitOrder", // 14
|
|
197
|
+
"cancelLimitOrder", // 15
|
|
198
|
+
"swapAndOpenPosition", // 16
|
|
199
|
+
"closeAndSwapPosition", // 17
|
|
200
|
+
"createEscrow", // 18
|
|
201
|
+
"settleEscrow", // 19
|
|
202
|
+
"refundEscrow", // 20
|
|
203
|
+
];
|
|
247
204
|
/**
|
|
248
205
|
* Parse an action type to its string key.
|
|
249
|
-
* Accepts either a numeric ActionType enum value or an
|
|
206
|
+
* Accepts either a numeric ActionType enum value (0-20) or an
|
|
207
|
+
* Anchor-style `{ Swap: {} }` object. Returns `undefined` for
|
|
208
|
+
* out-of-range numeric values or empty objects.
|
|
250
209
|
*/
|
|
251
210
|
export function parseActionType(actionType) {
|
|
252
211
|
if (typeof actionType === "number") {
|
|
253
|
-
|
|
254
|
-
return entries[actionType]?.[0];
|
|
212
|
+
return ACTION_TYPE_NAMES_BY_INDEX[actionType];
|
|
255
213
|
}
|
|
256
214
|
return Object.keys(actionType)[0];
|
|
257
215
|
}
|
|
258
|
-
/** Builder for constructing permission bitmasks */
|
|
259
|
-
export class PermissionBuilder {
|
|
260
|
-
permissions = 0n;
|
|
261
|
-
add(actionType) {
|
|
262
|
-
if (Object.prototype.hasOwnProperty.call(ACTION_PERMISSION_MAP, actionType)) {
|
|
263
|
-
this.permissions |= ACTION_PERMISSION_MAP[actionType];
|
|
264
|
-
}
|
|
265
|
-
return this;
|
|
266
|
-
}
|
|
267
|
-
remove(actionType) {
|
|
268
|
-
if (Object.prototype.hasOwnProperty.call(ACTION_PERMISSION_MAP, actionType)) {
|
|
269
|
-
this.permissions &= ~ACTION_PERMISSION_MAP[actionType];
|
|
270
|
-
}
|
|
271
|
-
return this;
|
|
272
|
-
}
|
|
273
|
-
build() {
|
|
274
|
-
return this.permissions;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
216
|
export function isSpendingAction(actionType) {
|
|
278
217
|
return [
|
|
279
218
|
"swap",
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,iCAAiC,EAAE,MAAM,mBAAmB,CAAC;AAEtE,oDAAoD;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AActE,iFAAiF;AAEjF,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAC;AAC9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC,CAAC,QAAQ;AAC9C,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC,CAAC,QAAQ;AACnD,MAAM,CAAC,MAAM,iBAAiB,GAC5B,8CAAyD,CAAC;AA2C5D,oEAAoE;AACpE,MAAM,UAAU,GAAG,CAAC,MAAc;IAChC,OAAO,MAAsB,CAAC;AAChC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,IAAkB;IAC3C,OAAO,IAAsB,CAAC;AAChC,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAA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AC,CAAC,CAAC;AACpC,CAAC;AAMD,MAAM,UAAU,gBAAgB,CAAC,UAAkB;IACjD,OAAO;QACL,MAAM;QACN,cAAc;QACd,kBAAkB;QAClB,SAAS;QACT,UAAU;QACV,eAAe;QACf,iBAAiB;QACjB,qBAAqB;QACrB,cAAc;KACf,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,UAAkB;IAClD,IACE,CAAC,cAAc,EAAE,qBAAqB,EAAE,iBAAiB,CAAC,CAAC,QAAQ,CACjE,UAAU,CACX,EACD,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,IACE,CAAC,eAAe,EAAE,sBAAsB,EAAE,kBAAkB,CAAC,CAAC,QAAQ,CACpE,UAAU,CACX,EACD,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SigilVault — handle over an on-chain Sigil vault.
|
|
3
|
+
*
|
|
4
|
+
* Represents a single vault + agent pair. Consumers get one via
|
|
5
|
+
* `Sigil.quickstart()` (new vault) or `Sigil.fromVault()` (existing
|
|
6
|
+
* vault). The constructor is private — construction tokens prevent
|
|
7
|
+
* external call sites from synthesizing the symbol and bypassing the
|
|
8
|
+
* factory validation path.
|
|
9
|
+
*
|
|
10
|
+
* Internally composes two Sprint 1 primitives:
|
|
11
|
+
* - `createSigilClient` / `SigilClient.create` for agent-side
|
|
12
|
+
* operations (`execute`, `budget`).
|
|
13
|
+
* - `createOwnerClient` for owner-only operations (`overview`,
|
|
14
|
+
* `freeze`, `fund`). Agent-only handles don't get an ownerClient;
|
|
15
|
+
* owner-gated methods throw `SIGIL_ERROR__SDK__OWNER_REQUIRED`.
|
|
16
|
+
*
|
|
17
|
+
* Per-call hooks passed to `execute({ hooks })` compose with the
|
|
18
|
+
* client-level hooks registered at handle construction — client hooks
|
|
19
|
+
* run first, then per-call hooks. Both go through `invokeHook` which
|
|
20
|
+
* swallows throws.
|
|
21
|
+
*/
|
|
22
|
+
import type { Address, Instruction, Rpc, SolanaRpcApi, TransactionSigner } from "./kit-adapter.js";
|
|
23
|
+
import type { SigilClientApi, ClientSealOpts, ExecuteResult } from "./seal.js";
|
|
24
|
+
import type { OwnerClient } from "./dashboard/index.js";
|
|
25
|
+
import type { OverviewData, GetOverviewOptions } from "./dashboard/types.js";
|
|
26
|
+
import type { ResolvedBudget } from "./state-resolver.js";
|
|
27
|
+
import type { SigilLogger } from "./logger.js";
|
|
28
|
+
import type { SealHooks } from "./hooks.js";
|
|
29
|
+
import type { SigilPolicyPlugin } from "./plugin.js";
|
|
30
|
+
import type { UsdBaseUnits } from "./types.js";
|
|
31
|
+
/**
|
|
32
|
+
* Module-private symbol that enforces "no direct `new SigilVault()`" at
|
|
33
|
+
* runtime. Factory methods in `sigil.ts` hold the only reference.
|
|
34
|
+
* Class constructor rejects anything that isn't this exact symbol.
|
|
35
|
+
*/
|
|
36
|
+
declare const CONSTRUCT_TOKEN: unique symbol;
|
|
37
|
+
export type _ConstructToken = typeof CONSTRUCT_TOKEN;
|
|
38
|
+
export interface SigilVaultInternalState {
|
|
39
|
+
readonly rpc: Rpc<SolanaRpcApi>;
|
|
40
|
+
readonly vault: Address;
|
|
41
|
+
readonly agent: TransactionSigner;
|
|
42
|
+
readonly owner?: TransactionSigner;
|
|
43
|
+
readonly network: "devnet" | "mainnet";
|
|
44
|
+
readonly client: SigilClientApi;
|
|
45
|
+
readonly ownerClient?: OwnerClient;
|
|
46
|
+
readonly logger: SigilLogger;
|
|
47
|
+
readonly hooks?: SealHooks;
|
|
48
|
+
readonly plugins?: readonly SigilPolicyPlugin[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Per-call options for `SigilVault.execute()`. Extends the standalone
|
|
52
|
+
* `ClientSealOpts` shape with a `hooks` override that composes with
|
|
53
|
+
* client-level hooks.
|
|
54
|
+
*/
|
|
55
|
+
export interface SigilVaultExecuteOptions extends ClientSealOpts {
|
|
56
|
+
/** Per-call hooks. Compose with client-level hooks (client runs first). */
|
|
57
|
+
hooks?: SealHooks;
|
|
58
|
+
}
|
|
59
|
+
/** Standard transaction option shape for owner-only methods. */
|
|
60
|
+
export interface TxOpts {
|
|
61
|
+
computeUnits?: number;
|
|
62
|
+
priorityFeeMicroLamports?: number;
|
|
63
|
+
}
|
|
64
|
+
/** Minimal result shape for owner-only mutations. */
|
|
65
|
+
export interface TxResult {
|
|
66
|
+
signature: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Handle over a Sigil vault. Constructor is private — use
|
|
70
|
+
* `Sigil.quickstart()` or `Sigil.fromVault()` to obtain one.
|
|
71
|
+
*/
|
|
72
|
+
export declare class SigilVault {
|
|
73
|
+
#private;
|
|
74
|
+
readonly address: Address;
|
|
75
|
+
readonly network: "devnet" | "mainnet";
|
|
76
|
+
readonly agent: TransactionSigner;
|
|
77
|
+
readonly owner?: TransactionSigner;
|
|
78
|
+
/**
|
|
79
|
+
* Private constructor — enforced via `CONSTRUCT_TOKEN`. External
|
|
80
|
+
* callers that synthesize a fake token via TypeScript casting will
|
|
81
|
+
* still trigger the runtime check and throw.
|
|
82
|
+
*/
|
|
83
|
+
private constructor();
|
|
84
|
+
/**
|
|
85
|
+
* @internal — used by `Sigil.quickstart()` and `Sigil.fromVault()`.
|
|
86
|
+
* Not part of the public API; the underscore prefix signals this.
|
|
87
|
+
*/
|
|
88
|
+
static _fromResolved(state: SigilVaultInternalState): SigilVault;
|
|
89
|
+
/**
|
|
90
|
+
* Execute DeFi instructions under the vault's seal. Composes
|
|
91
|
+
* client-level and per-call hooks, then delegates to the underlying
|
|
92
|
+
* `SigilClientApi.executeAndConfirm`.
|
|
93
|
+
*
|
|
94
|
+
* The composed hooks are threaded through as an extension field on
|
|
95
|
+
* `ClientSealOpts`; `seal.ts` picks them up in the hook-invocation
|
|
96
|
+
* step (landed in a subsequent commit of this sprint).
|
|
97
|
+
*/
|
|
98
|
+
execute(instructions: Instruction[], opts: SigilVaultExecuteOptions): Promise<ExecuteResult>;
|
|
99
|
+
/**
|
|
100
|
+
* Full vault overview — delegates to `OwnerClient.getOverview()`.
|
|
101
|
+
* Requires an `owner` signer on the handle; throws
|
|
102
|
+
* `SIGIL_ERROR__SDK__OWNER_REQUIRED` when called agent-only.
|
|
103
|
+
*/
|
|
104
|
+
overview(options?: GetOverviewOptions): Promise<OverviewData>;
|
|
105
|
+
/**
|
|
106
|
+
* Cheapest read — just the current rolling-24h budget. Uses agent
|
|
107
|
+
* identity regardless of whether owner is present; either works.
|
|
108
|
+
*/
|
|
109
|
+
budget(): Promise<ResolvedBudget>;
|
|
110
|
+
/**
|
|
111
|
+
* Freeze the vault — owner-only. Agents + pending operations are
|
|
112
|
+
* rejected on-chain until `resume()` is called. Delegates to
|
|
113
|
+
* `OwnerClient.freezeVault()`.
|
|
114
|
+
*/
|
|
115
|
+
freeze(opts?: TxOpts): Promise<TxResult>;
|
|
116
|
+
/**
|
|
117
|
+
* Deposit `amount` of `mint` from the owner's wallet into the vault.
|
|
118
|
+
* Owner-only. Delegates to `OwnerClient.deposit()`.
|
|
119
|
+
*/
|
|
120
|
+
fund(mint: Address, amount: UsdBaseUnits, opts?: TxOpts): Promise<TxResult>;
|
|
121
|
+
}
|
|
122
|
+
export {};
|
|
123
|
+
//# sourceMappingURL=vault-handle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault-handle.d.ts","sourceRoot":"","sources":["../src/vault-handle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EACV,OAAO,EACP,WAAW,EACX,GAAG,EACH,YAAY,EACZ,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;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,EAAE,MAAM,CAAC;IACtB,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,qDAAqD;AACrD,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB;AAID;;;GAGG;AACH,qBAAa,UAAU;;IACrB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAInC;;;;OAIG;IACH,OAAO;IAaP;;;OAGG;IACH,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,uBAAuB,GAAG,UAAU;IAMhE;;;;;;;;OAQG;IACG,OAAO,CACX,YAAY,EAAE,WAAW,EAAE,EAC3B,IAAI,EAAE,wBAAwB,GAC7B,OAAO,CAAC,aAAa,CAAC;IAYzB;;;;OAIG;IACG,QAAQ,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;IAOnE;;;OAGG;IACG,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC;IAUvC;;;;OAIG;IACG,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAO9C;;;OAGG;IACG,IAAI,CACR,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,YAAY,EACpB,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,QAAQ,CAAC;CAuBrB"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SigilVault — handle over an on-chain Sigil vault.
|
|
3
|
+
*
|
|
4
|
+
* Represents a single vault + agent pair. Consumers get one via
|
|
5
|
+
* `Sigil.quickstart()` (new vault) or `Sigil.fromVault()` (existing
|
|
6
|
+
* vault). The constructor is private — construction tokens prevent
|
|
7
|
+
* external call sites from synthesizing the symbol and bypassing the
|
|
8
|
+
* factory validation path.
|
|
9
|
+
*
|
|
10
|
+
* Internally composes two Sprint 1 primitives:
|
|
11
|
+
* - `createSigilClient` / `SigilClient.create` for agent-side
|
|
12
|
+
* operations (`execute`, `budget`).
|
|
13
|
+
* - `createOwnerClient` for owner-only operations (`overview`,
|
|
14
|
+
* `freeze`, `fund`). Agent-only handles don't get an ownerClient;
|
|
15
|
+
* owner-gated methods throw `SIGIL_ERROR__SDK__OWNER_REQUIRED`.
|
|
16
|
+
*
|
|
17
|
+
* Per-call hooks passed to `execute({ hooks })` compose with the
|
|
18
|
+
* client-level hooks registered at handle construction — client hooks
|
|
19
|
+
* run first, then per-call hooks. Both go through `invokeHook` which
|
|
20
|
+
* swallows throws.
|
|
21
|
+
*/
|
|
22
|
+
import { resolveVaultBudget } from "./state-resolver.js";
|
|
23
|
+
import { SigilSdkDomainError } from "./errors/sdk.js";
|
|
24
|
+
import { SIGIL_ERROR__SDK__OWNER_REQUIRED } from "./errors/codes.js";
|
|
25
|
+
import { composeHooks } from "./hooks.js";
|
|
26
|
+
// ─── Internal construction token ────────────────────────────────────────────
|
|
27
|
+
/**
|
|
28
|
+
* Module-private symbol that enforces "no direct `new SigilVault()`" at
|
|
29
|
+
* runtime. Factory methods in `sigil.ts` hold the only reference.
|
|
30
|
+
* Class constructor rejects anything that isn't this exact symbol.
|
|
31
|
+
*/
|
|
32
|
+
const CONSTRUCT_TOKEN = Symbol("SigilVault.construct");
|
|
33
|
+
// ─── Class ──────────────────────────────────────────────────────────────────
|
|
34
|
+
/**
|
|
35
|
+
* Handle over a Sigil vault. Constructor is private — use
|
|
36
|
+
* `Sigil.quickstart()` or `Sigil.fromVault()` to obtain one.
|
|
37
|
+
*/
|
|
38
|
+
export class SigilVault {
|
|
39
|
+
address;
|
|
40
|
+
network;
|
|
41
|
+
agent;
|
|
42
|
+
owner;
|
|
43
|
+
#state;
|
|
44
|
+
/**
|
|
45
|
+
* Private constructor — enforced via `CONSTRUCT_TOKEN`. External
|
|
46
|
+
* callers that synthesize a fake token via TypeScript casting will
|
|
47
|
+
* still trigger the runtime check and throw.
|
|
48
|
+
*/
|
|
49
|
+
constructor(token, state) {
|
|
50
|
+
if (token !== CONSTRUCT_TOKEN) {
|
|
51
|
+
throw new Error("SigilVault: direct construction is not allowed. Use Sigil.quickstart() or Sigil.fromVault().");
|
|
52
|
+
}
|
|
53
|
+
this.#state = state;
|
|
54
|
+
this.address = state.vault;
|
|
55
|
+
this.network = state.network;
|
|
56
|
+
this.agent = state.agent;
|
|
57
|
+
this.owner = state.owner;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* @internal — used by `Sigil.quickstart()` and `Sigil.fromVault()`.
|
|
61
|
+
* Not part of the public API; the underscore prefix signals this.
|
|
62
|
+
*/
|
|
63
|
+
static _fromResolved(state) {
|
|
64
|
+
return new SigilVault(CONSTRUCT_TOKEN, state);
|
|
65
|
+
}
|
|
66
|
+
// ─── Execute ─────────────────────────────────────────────────────────────
|
|
67
|
+
/**
|
|
68
|
+
* Execute DeFi instructions under the vault's seal. Composes
|
|
69
|
+
* client-level and per-call hooks, then delegates to the underlying
|
|
70
|
+
* `SigilClientApi.executeAndConfirm`.
|
|
71
|
+
*
|
|
72
|
+
* The composed hooks are threaded through as an extension field on
|
|
73
|
+
* `ClientSealOpts`; `seal.ts` picks them up in the hook-invocation
|
|
74
|
+
* step (landed in a subsequent commit of this sprint).
|
|
75
|
+
*/
|
|
76
|
+
async execute(instructions, opts) {
|
|
77
|
+
const composedHooks = composeHooks(this.#state.hooks, opts.hooks);
|
|
78
|
+
const { hooks: _ignored, ...rest } = opts;
|
|
79
|
+
const sealOpts = {
|
|
80
|
+
...rest,
|
|
81
|
+
...(composedHooks ? { hooks: composedHooks } : {}),
|
|
82
|
+
};
|
|
83
|
+
return this.#state.client.executeAndConfirm(instructions, sealOpts);
|
|
84
|
+
}
|
|
85
|
+
// ─── Overview ────────────────────────────────────────────────────────────
|
|
86
|
+
/**
|
|
87
|
+
* Full vault overview — delegates to `OwnerClient.getOverview()`.
|
|
88
|
+
* Requires an `owner` signer on the handle; throws
|
|
89
|
+
* `SIGIL_ERROR__SDK__OWNER_REQUIRED` when called agent-only.
|
|
90
|
+
*/
|
|
91
|
+
async overview(options) {
|
|
92
|
+
const ownerClient = this.#requireOwnerClient("overview");
|
|
93
|
+
return ownerClient.getOverview(options);
|
|
94
|
+
}
|
|
95
|
+
// ─── Budget ──────────────────────────────────────────────────────────────
|
|
96
|
+
/**
|
|
97
|
+
* Cheapest read — just the current rolling-24h budget. Uses agent
|
|
98
|
+
* identity regardless of whether owner is present; either works.
|
|
99
|
+
*/
|
|
100
|
+
async budget() {
|
|
101
|
+
return resolveVaultBudget(this.#state.rpc, this.address, this.agent.address);
|
|
102
|
+
}
|
|
103
|
+
// ─── Lifecycle: freeze ───────────────────────────────────────────────────
|
|
104
|
+
/**
|
|
105
|
+
* Freeze the vault — owner-only. Agents + pending operations are
|
|
106
|
+
* rejected on-chain until `resume()` is called. Delegates to
|
|
107
|
+
* `OwnerClient.freezeVault()`.
|
|
108
|
+
*/
|
|
109
|
+
async freeze(opts) {
|
|
110
|
+
const ownerClient = this.#requireOwnerClient("freeze");
|
|
111
|
+
return ownerClient.freezeVault(opts);
|
|
112
|
+
}
|
|
113
|
+
// ─── Funds: fund ─────────────────────────────────────────────────────────
|
|
114
|
+
/**
|
|
115
|
+
* Deposit `amount` of `mint` from the owner's wallet into the vault.
|
|
116
|
+
* Owner-only. Delegates to `OwnerClient.deposit()`.
|
|
117
|
+
*/
|
|
118
|
+
async fund(mint, amount, opts) {
|
|
119
|
+
const ownerClient = this.#requireOwnerClient("fund");
|
|
120
|
+
return ownerClient.deposit(mint, amount, opts);
|
|
121
|
+
}
|
|
122
|
+
// ─── Internals ───────────────────────────────────────────────────────────
|
|
123
|
+
/**
|
|
124
|
+
* Assert that this handle has an owner-capable `ownerClient` before
|
|
125
|
+
* invoking an owner-only method. Throws a structured error with the
|
|
126
|
+
* method name so consumers can pinpoint which call needs the owner.
|
|
127
|
+
*/
|
|
128
|
+
#requireOwnerClient(method) {
|
|
129
|
+
const oc = this.#state.ownerClient;
|
|
130
|
+
if (!oc) {
|
|
131
|
+
throw new SigilSdkDomainError(SIGIL_ERROR__SDK__OWNER_REQUIRED, `SigilVault.${method}() requires an owner signer. Reconstruct the handle via Sigil.fromVault({ ..., owner }) to enable this method.`, { context: { method, vault: this.address } });
|
|
132
|
+
}
|
|
133
|
+
return oc;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=vault-handle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault-handle.js","sourceRoot":"","sources":["../src/vault-handle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAkBH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,eAAe,GAAkB,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAyCtE,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,OAAO,UAAU;IACZ,OAAO,CAAU;IACjB,OAAO,CAAuB;IAC9B,KAAK,CAAoB;IACzB,KAAK,CAAqB;IAE1B,MAAM,CAA0B;IAEzC;;;;OAIG;IACH,YAAoB,KAAsB,EAAE,KAA8B;QACxE,IAAI,KAAK,KAAK,eAAe,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CACb,8FAA8F,CAC/F,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,KA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AAC,MAAM,CAAC,IAAa;QACxB,MAAM,WAAW,GAAG,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QACvD,OAAO,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,4EAA4E;IAE5E;;;OAGG;IACH,KAAK,CAAC,IAAI,CACR,IAAa,EACb,MAAoB,EACpB,IAAa;QAEb,MAAM,WAAW,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;QACrD,OAAO,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACjD,CAAC;IAED,4EAA4E;IAE5E;;;;OAIG;IACH,mBAAmB,CAAC,MAAc;QAChC,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACnC,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,MAAM,IAAI,mBAAmB,CAC3B,gCAAgC,EAChC,cAAc,MAAM,gHAAgH,EACpI,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,CAC7C,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shielded-fetch.d.ts","sourceRoot":"","sources":["../../src/x402/shielded-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAEV,GAAG,EACH,YAAY,EACZ,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAU3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"shielded-fetch.d.ts","sourceRoot":"","sources":["../../src/x402/shielded-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAEV,GAAG,EACH,YAAY,EACZ,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAU3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,KAAK,EACV,UAAU,EACV,oBAAoB,EACpB,qBAAqB,EAEtB,MAAM,YAAY,CAAC;AAiEpB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,iBAAiB,EACzB,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,MAAM,CAAC,EAAE,UAAU,EACnB,SAAS,CAAC,EAAE,eAAe,EAC3B,GAAG,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,EACvB,YAAY,CAAC,EAAE,oBAAoB,GAClC,OAAO,CAAC,qBAAqB,CAAC,CAgVhC;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,iBAAiB,EACzB,MAAM,CAAC,EAAE,UAAU,EACnB,SAAS,CAAC,EAAE,eAAe,EAC3B,GAAG,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,GACtB,CACD,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,IAAI,CAAC,EAAE,oBAAoB,KACxB,OAAO,CAAC,qBAAqB,CAAC,CAGlC"}
|