@polyester/sdk 0.4.5 → 0.5.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/CHANGELOG.md +14 -0
- package/dist/services/candles/candles.schemas.d.ts +10 -10
- package/dist/services/heatmap/heatmap.schemas.d.ts +13 -13
- package/dist/services/market-overview/market-overview.schemas.d.ts +3 -3
- package/dist/services/orderbook/orderbook.schemas.d.ts +1 -1
- package/dist/services/orders/orders-input.schemas.d.ts +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +1 -1
- package/dist/smart-account/index.d.ts +2 -2
- package/dist/smart-account/index.js +2 -2
- package/dist/smart-account/smart-account.d.ts +22 -2
- package/dist/smart-account/smart-account.d.ts.map +1 -1
- package/dist/smart-account/smart-account.js +62 -19
- package/dist/smart-account/smart-account.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @polyester/sdk
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#66](https://github.com/Fabric-Labs/polyester-sdk-typescript/pull/66) [`e8a5721`](https://github.com/Fabric-Labs/polyester-sdk-typescript/commit/e8a5721b57be7ebd0b7edf80c4ed85919fccdb0a) Thanks [@huntabyte](https://github.com/huntabyte)! - `sendPolyesterUserOperation` now prepares the operation in a single pass, halving the network round-trips before the wallet signature prompt appears. Gas estimation errors now propagate instead of triggering a silent resend.
|
|
8
|
+
|
|
9
|
+
- [#66](https://github.com/Fabric-Labs/polyester-sdk-typescript/pull/66) [`e8a5721`](https://github.com/Fabric-Labs/polyester-sdk-typescript/commit/e8a5721b57be7ebd0b7edf80c4ed85919fccdb0a) Thanks [@huntabyte](https://github.com/huntabyte)! - `sendPolyesterUserOperation` accepts a new `onWalletSignatureRequested` callback that fires right before the wallet is asked to sign, so UIs can show an accurate "confirm in your wallet" state.
|
|
10
|
+
|
|
11
|
+
- [#66](https://github.com/Fabric-Labs/polyester-sdk-typescript/pull/66) [`e8a5721`](https://github.com/Fabric-Labs/polyester-sdk-typescript/commit/e8a5721b57be7ebd0b7edf80c4ed85919fccdb0a) Thanks [@huntabyte](https://github.com/huntabyte)! - New `warmPolyesterSmartAccountClient` helper pre-fetches the gas price and warms RPC connections ahead of a submission. The smart account client now caches gas prices, for 10 seconds by default, configurable via the new `options.gasPriceCacheTtlMs` setting.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#66](https://github.com/Fabric-Labs/polyester-sdk-typescript/pull/66) [`e8a5721`](https://github.com/Fabric-Labs/polyester-sdk-typescript/commit/e8a5721b57be7ebd0b7edf80c4ed85919fccdb0a) Thanks [@huntabyte](https://github.com/huntabyte)! - The smart account client polls for UserOperation receipts every second instead of every 4 seconds, configurable via the new `options.pollingIntervalMs` setting.
|
|
16
|
+
|
|
3
17
|
## 0.4.5
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -11,7 +11,7 @@ type TimestampInit = {
|
|
|
11
11
|
};
|
|
12
12
|
declare function createCandleRowSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
13
13
|
readonly symbolId: v.NumberSchema<undefined>;
|
|
14
|
-
readonly timeframe: v.SchemaWithPipe<readonly [v.EnumSchema<typeof Timeframe$1, undefined>, v.TransformAction<Timeframe$1, DecodedEnum<"1d" | "
|
|
14
|
+
readonly timeframe: v.SchemaWithPipe<readonly [v.EnumSchema<typeof Timeframe$1, undefined>, v.TransformAction<Timeframe$1, DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">>]>;
|
|
15
15
|
readonly tsSec: v.BigintSchema<undefined>;
|
|
16
16
|
readonly open: v.BigintSchema<undefined>;
|
|
17
17
|
readonly high: v.BigintSchema<undefined>;
|
|
@@ -21,7 +21,7 @@ declare function createCandleRowSchema(scales: SdkScales): v.SchemaWithPipe<read
|
|
|
21
21
|
readonly isClosed: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
22
22
|
}, undefined>, v.TransformAction<{
|
|
23
23
|
symbolId: number;
|
|
24
|
-
timeframe: DecodedEnum<"1d" | "
|
|
24
|
+
timeframe: DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">;
|
|
25
25
|
tsSec: bigint;
|
|
26
26
|
open: bigint;
|
|
27
27
|
high: bigint;
|
|
@@ -31,7 +31,7 @@ declare function createCandleRowSchema(scales: SdkScales): v.SchemaWithPipe<read
|
|
|
31
31
|
isClosed: boolean;
|
|
32
32
|
}, {
|
|
33
33
|
symbolId: number;
|
|
34
|
-
timeframe: DecodedEnum<"1d" | "
|
|
34
|
+
timeframe: DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">;
|
|
35
35
|
time: number;
|
|
36
36
|
open: string;
|
|
37
37
|
high: string;
|
|
@@ -43,7 +43,7 @@ declare function createCandleRowSchema(scales: SdkScales): v.SchemaWithPipe<read
|
|
|
43
43
|
declare const createCandleRowIntSchema: typeof createCandleRowSchema;
|
|
44
44
|
declare function createCandleColumnarSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
45
45
|
readonly symbolId: v.NumberSchema<undefined>;
|
|
46
|
-
readonly timeframe: v.SchemaWithPipe<readonly [v.EnumSchema<typeof Timeframe$1, undefined>, v.TransformAction<Timeframe$1, DecodedEnum<"1d" | "
|
|
46
|
+
readonly timeframe: v.SchemaWithPipe<readonly [v.EnumSchema<typeof Timeframe$1, undefined>, v.TransformAction<Timeframe$1, DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">>]>;
|
|
47
47
|
readonly tsSec: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
|
|
48
48
|
readonly open: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
|
|
49
49
|
readonly high: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
|
|
@@ -59,7 +59,7 @@ declare function createCandleColumnarSchema(scales: SdkScales): v.SchemaWithPipe
|
|
|
59
59
|
readonly nextPageToken: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
60
60
|
}, undefined>, v.TransformAction<{
|
|
61
61
|
symbolId: number;
|
|
62
|
-
timeframe: DecodedEnum<"1d" | "
|
|
62
|
+
timeframe: DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">;
|
|
63
63
|
tsSec: bigint[];
|
|
64
64
|
open: bigint[];
|
|
65
65
|
high: bigint[];
|
|
@@ -75,7 +75,7 @@ declare function createCandleColumnarSchema(scales: SdkScales): v.SchemaWithPipe
|
|
|
75
75
|
nextPageToken: string;
|
|
76
76
|
}, {
|
|
77
77
|
symbolId: number;
|
|
78
|
-
timeframe: DecodedEnum<"1d" | "
|
|
78
|
+
timeframe: DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">;
|
|
79
79
|
time: number[];
|
|
80
80
|
open: string[];
|
|
81
81
|
high: string[];
|
|
@@ -94,7 +94,7 @@ declare function createCandleColumnarSchema(scales: SdkScales): v.SchemaWithPipe
|
|
|
94
94
|
}>]>;
|
|
95
95
|
declare function createCandleColumnarIntSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
96
96
|
readonly symbolId: v.NumberSchema<undefined>;
|
|
97
|
-
readonly timeframe: v.SchemaWithPipe<readonly [v.EnumSchema<typeof Timeframe$1, undefined>, v.TransformAction<Timeframe$1, DecodedEnum<"1d" | "
|
|
97
|
+
readonly timeframe: v.SchemaWithPipe<readonly [v.EnumSchema<typeof Timeframe$1, undefined>, v.TransformAction<Timeframe$1, DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">>]>;
|
|
98
98
|
readonly tsSec: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
|
|
99
99
|
readonly open: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
|
|
100
100
|
readonly high: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
|
|
@@ -110,7 +110,7 @@ declare function createCandleColumnarIntSchema(scales: SdkScales): v.SchemaWithP
|
|
|
110
110
|
readonly nextPageToken: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
111
111
|
}, undefined>, v.TransformAction<{
|
|
112
112
|
symbolId: number;
|
|
113
|
-
timeframe: DecodedEnum<"1d" | "
|
|
113
|
+
timeframe: DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">;
|
|
114
114
|
tsSec: bigint[];
|
|
115
115
|
open: bigint[];
|
|
116
116
|
high: bigint[];
|
|
@@ -126,7 +126,7 @@ declare function createCandleColumnarIntSchema(scales: SdkScales): v.SchemaWithP
|
|
|
126
126
|
nextPageToken: string;
|
|
127
127
|
}, {
|
|
128
128
|
symbolId: number;
|
|
129
|
-
timeframe: DecodedEnum<"1d" | "
|
|
129
|
+
timeframe: DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">;
|
|
130
130
|
tsSec: number[];
|
|
131
131
|
open: string[];
|
|
132
132
|
high: string[];
|
|
@@ -149,7 +149,7 @@ type CandleColumnar = v.InferOutput<ReturnType<typeof createCandleColumnarSchema
|
|
|
149
149
|
type CandleColumnarInt = v.InferOutput<ReturnType<typeof createCandleColumnarIntSchema>>;
|
|
150
150
|
declare function createListCandlesInputSchema(): v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
151
151
|
readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
152
|
-
readonly timeframe: v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["1s", "1m", "5m", "15m", "30m", "1h", "4h", "12h", "1d", "1w", "1mo"], undefined>, v.TransformAction<"1d" | "
|
|
152
|
+
readonly timeframe: v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["1s", "1m", "5m", "15m", "30m", "1h", "4h", "12h", "1d", "1w", "1mo"], undefined>, v.TransformAction<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo", Timeframe$1.SEC_1 | Timeframe$1.MIN_1 | Timeframe$1.MIN_5 | Timeframe$1.MIN_15 | Timeframe$1.MIN_30 | Timeframe$1.HOUR_1 | Timeframe$1.HOUR_4 | Timeframe$1.DAY_1 | Timeframe$1.HOUR_12 | Timeframe$1.WEEK_1 | Timeframe$1.MONTH_1>]>;
|
|
153
153
|
readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 10000, undefined>]>, undefined>;
|
|
154
154
|
readonly includeIncomplete: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
155
155
|
readonly includeReference: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
@@ -13,8 +13,8 @@ type TimestampInit = {
|
|
|
13
13
|
};
|
|
14
14
|
declare const GetOrderbookHeatmapInputSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
15
15
|
readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
16
|
-
readonly interval: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["1s", "1m", "5m", "1h"], undefined>, "1s">, v.TransformAction<"
|
|
17
|
-
readonly depth: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly [1, 5, 10, 20, 50, 100, 200, 500, 1000], undefined>, 50>, v.TransformAction<5 | 10 | 20 | 1 | 200 |
|
|
16
|
+
readonly interval: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["1s", "1m", "5m", "1h"], undefined>, "1s">, v.TransformAction<"1h" | "1m" | "1s" | "5m", HeatmapInterval>]>;
|
|
17
|
+
readonly depth: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly [1, 5, 10, 20, 50, 100, 200, 500, 1000], undefined>, 50>, v.TransformAction<5 | 10 | 20 | 1 | 200 | 1000 | 500 | 50 | 100, HeatmapDepth>]>;
|
|
18
18
|
readonly quantityMode: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["close", "peak"], undefined>, "close">, v.TransformAction<"close" | "peak", HeatmapQuantityMode>]>;
|
|
19
19
|
readonly limit: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 20000, undefined>]>;
|
|
20
20
|
readonly startTsSec: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, number, undefined>, v.TransformAction<number, bigint>]>, undefined>;
|
|
@@ -122,7 +122,7 @@ declare function convertHeatmapDeltaBucket(bucket: OrderbookHeatmapDeltaBucketRa
|
|
|
122
122
|
type OrderbookHeatmapDeltaBucket = ReturnType<typeof convertHeatmapDeltaBucket>;
|
|
123
123
|
declare const OrderbookHeatmapLiveBucketRawSchema: v.ObjectSchema<{
|
|
124
124
|
readonly symbolId: v.NumberSchema<undefined>;
|
|
125
|
-
readonly interval: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"
|
|
125
|
+
readonly interval: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"1h" | "1m" | "1s" | "5m">>]>;
|
|
126
126
|
readonly tsSec: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
127
127
|
readonly isFinal: v.BooleanSchema<undefined>;
|
|
128
128
|
readonly bids: v.OptionalSchema<v.ObjectSchema<{
|
|
@@ -142,7 +142,7 @@ declare const OrderbookHeatmapLiveBucketRawSchema: v.ObjectSchema<{
|
|
|
142
142
|
type OrderbookHeatmapLiveBucketRaw = v.InferOutput<typeof OrderbookHeatmapLiveBucketRawSchema>;
|
|
143
143
|
declare function convertHeatmapLiveBucket(bucket: OrderbookHeatmapLiveBucketRaw, scales: SdkScales): {
|
|
144
144
|
symbolId: number;
|
|
145
|
-
interval: DecodedEnum<"
|
|
145
|
+
interval: DecodedEnum<"1h" | "1m" | "1s" | "5m">;
|
|
146
146
|
tsSec: number;
|
|
147
147
|
isFinal: boolean;
|
|
148
148
|
bids: {
|
|
@@ -226,8 +226,8 @@ declare function convertHeatmapDeltaChain(chain: OrderbookHeatmapDeltaChainRaw,
|
|
|
226
226
|
type OrderbookHeatmapDeltaChain = ReturnType<typeof convertHeatmapDeltaChain>;
|
|
227
227
|
declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
228
228
|
readonly symbolId: v.NumberSchema<undefined>;
|
|
229
|
-
readonly interval: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"
|
|
230
|
-
readonly depth: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, 5 | 10 | 20 | 1 | "unspecified" | 200 |
|
|
229
|
+
readonly interval: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"1h" | "1m" | "1s" | "5m">>]>;
|
|
230
|
+
readonly depth: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, 5 | 10 | 20 | 1 | "unspecified" | 200 | 1000 | 500 | 50 | 100>]>;
|
|
231
231
|
readonly chain: v.OptionalSchema<v.ObjectSchema<{
|
|
232
232
|
readonly baseKeyframe: v.OptionalSchema<v.ObjectSchema<{
|
|
233
233
|
readonly tsSec: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
@@ -267,7 +267,7 @@ declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.Sche
|
|
|
267
267
|
readonly quantityMode: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"close" | "peak">>]>;
|
|
268
268
|
readonly liveBucket: v.OptionalSchema<v.ObjectSchema<{
|
|
269
269
|
readonly symbolId: v.NumberSchema<undefined>;
|
|
270
|
-
readonly interval: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"
|
|
270
|
+
readonly interval: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"1h" | "1m" | "1s" | "5m">>]>;
|
|
271
271
|
readonly tsSec: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
272
272
|
readonly isFinal: v.BooleanSchema<undefined>;
|
|
273
273
|
readonly bids: v.OptionalSchema<v.ObjectSchema<{
|
|
@@ -286,8 +286,8 @@ declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.Sche
|
|
|
286
286
|
}, undefined>, undefined>;
|
|
287
287
|
}, undefined>, v.TransformAction<{
|
|
288
288
|
symbolId: number;
|
|
289
|
-
interval: DecodedEnum<"
|
|
290
|
-
depth: 5 | 10 | 20 | 1 | "unspecified" | 200 |
|
|
289
|
+
interval: DecodedEnum<"1h" | "1m" | "1s" | "5m">;
|
|
290
|
+
depth: 5 | 10 | 20 | 1 | "unspecified" | 200 | 1000 | 500 | 50 | 100;
|
|
291
291
|
chain?: {
|
|
292
292
|
baseKeyframe?: {
|
|
293
293
|
tsSec: number;
|
|
@@ -327,7 +327,7 @@ declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.Sche
|
|
|
327
327
|
quantityMode: DecodedEnum<"close" | "peak">;
|
|
328
328
|
liveBucket?: {
|
|
329
329
|
symbolId: number;
|
|
330
|
-
interval: DecodedEnum<"
|
|
330
|
+
interval: DecodedEnum<"1h" | "1m" | "1s" | "5m">;
|
|
331
331
|
tsSec: number;
|
|
332
332
|
isFinal: boolean;
|
|
333
333
|
bids?: {
|
|
@@ -346,8 +346,8 @@ declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.Sche
|
|
|
346
346
|
} | undefined;
|
|
347
347
|
}, {
|
|
348
348
|
symbolId: number;
|
|
349
|
-
interval: DecodedEnum<"
|
|
350
|
-
depth: 5 | 10 | 20 | 1 | "unspecified" | 200 |
|
|
349
|
+
interval: DecodedEnum<"1h" | "1m" | "1s" | "5m">;
|
|
350
|
+
depth: 5 | 10 | 20 | 1 | "unspecified" | 200 | 1000 | 500 | 50 | 100;
|
|
351
351
|
chain: {
|
|
352
352
|
baseKeyframe: {
|
|
353
353
|
tsSec: number;
|
|
@@ -387,7 +387,7 @@ declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.Sche
|
|
|
387
387
|
quantityMode: DecodedEnum<"close" | "peak">;
|
|
388
388
|
liveBucket: {
|
|
389
389
|
symbolId: number;
|
|
390
|
-
interval: DecodedEnum<"
|
|
390
|
+
interval: DecodedEnum<"1h" | "1m" | "1s" | "5m">;
|
|
391
391
|
tsSec: number;
|
|
392
392
|
isFinal: boolean;
|
|
393
393
|
bids: {
|
|
@@ -30,7 +30,7 @@ declare function createMarketOverviewSchema(scales: SdkScales): v.SchemaWithPipe
|
|
|
30
30
|
readonly bestAskTicks: v.BigintSchema<undefined>;
|
|
31
31
|
readonly bestAskQtyScaled: v.BigintSchema<undefined>;
|
|
32
32
|
readonly sparklines: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
33
|
-
readonly interval: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SparklineInterval, undefined>, v.TransformAction<SparklineInterval, "unspecified" | "
|
|
33
|
+
readonly interval: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SparklineInterval, undefined>, v.TransformAction<SparklineInterval, "unspecified" | "1h" | "24h" | "1w" | "1m">]>;
|
|
34
34
|
readonly closeTicks: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
|
|
35
35
|
}, undefined>, undefined>, readonly []>;
|
|
36
36
|
readonly indexPriceTicks: v.BigintSchema<undefined>;
|
|
@@ -50,7 +50,7 @@ declare function createMarketOverviewSchema(scales: SdkScales): v.SchemaWithPipe
|
|
|
50
50
|
bestAskTicks: bigint;
|
|
51
51
|
bestAskQtyScaled: bigint;
|
|
52
52
|
sparklines: {
|
|
53
|
-
interval: "unspecified" | "
|
|
53
|
+
interval: "unspecified" | "1h" | "24h" | "1w" | "1m";
|
|
54
54
|
closeTicks: bigint[];
|
|
55
55
|
}[];
|
|
56
56
|
indexPriceTicks: bigint;
|
|
@@ -80,7 +80,7 @@ declare const ListMarketOverviewInputSchema: v.ObjectSchema<{
|
|
|
80
80
|
readonly orderBy: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["change_24h_bps", "volume_24h_quote", "last_price", "date_added"], undefined>, "volume_24h_quote">, v.TransformAction<"change_24h_bps" | "volume_24h_quote" | "last_price" | "date_added", MarketOrderBy.ORDER_BY_CHANGE_24H_BPS | MarketOrderBy.ORDER_BY_VOLUME_24H_QUOTE | MarketOrderBy.ORDER_BY_LAST_PRICE | MarketOrderBy.ORDER_BY_DATE_ADDED>]>;
|
|
81
81
|
readonly sort: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["asc", "desc"], undefined>, "desc">, v.TransformAction<"asc" | "desc", SortDirection.SORT_ASC | SortDirection.SORT_DESC>]>;
|
|
82
82
|
readonly includeSparklines: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
|
|
83
|
-
readonly sparklineIntervals: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["1h", "24h", "1w", "1m"], undefined>, undefined>, readonly ["24h"]>, v.TransformAction<("
|
|
83
|
+
readonly sparklineIntervals: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["1h", "24h", "1w", "1m"], undefined>, undefined>, readonly ["24h"]>, v.TransformAction<("1h" | "24h" | "1w" | "1m")[], (SparklineInterval.SPARKLINE_1H | SparklineInterval.SPARKLINE_24H | SparklineInterval.SPARKLINE_1W | SparklineInterval.SPARKLINE_1M)[]>]>;
|
|
84
84
|
}, undefined>;
|
|
85
85
|
type ListMarketOverviewInput = v.InferInput<typeof ListMarketOverviewInputSchema>;
|
|
86
86
|
//#endregion
|
|
@@ -11,7 +11,7 @@ declare const GetOrderbookInputSchema: v.SchemaWithPipe<readonly [v.ObjectSchema
|
|
|
11
11
|
depth: number;
|
|
12
12
|
}, {
|
|
13
13
|
symbol: string;
|
|
14
|
-
depth: 5 | 10 | 20 | 1 | 200 |
|
|
14
|
+
depth: 5 | 10 | 20 | 1 | 200 | 1000 | 500 | 50 | 100;
|
|
15
15
|
protoDepth: Depth;
|
|
16
16
|
}>]>;
|
|
17
17
|
type GetOrderbookInput = v.InferInput<typeof GetOrderbookInputSchema>;
|
|
@@ -40,7 +40,7 @@ type OpenOrdersInput = v.InferInput<typeof OpenOrdersInputSchema>;
|
|
|
40
40
|
declare const OrderHistoryInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
41
41
|
readonly includeAttachedRisk: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
|
|
42
42
|
readonly includeAttachedRiskState: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
43
|
-
readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["FILLED", "CANCELED", "REJECTED"], undefined>, undefined>, v.TransformAction<"
|
|
43
|
+
readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["FILLED", "CANCELED", "REJECTED"], undefined>, undefined>, v.TransformAction<"FILLED" | "CANCELED" | "REJECTED" | undefined, OrderStatus.FILLED | OrderStatus.CANCELED | OrderStatus.REJECTED | undefined>]>;
|
|
44
44
|
readonly startTsNs: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
|
|
45
45
|
readonly endTsNs: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
|
|
46
46
|
readonly symbolId: v.OptionalSchema<v.ArraySchema<v.NumberSchema<undefined>, undefined>, undefined>;
|
|
@@ -243,7 +243,7 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
|
|
|
243
243
|
seconds: bigint;
|
|
244
244
|
nanos: number;
|
|
245
245
|
} | undefined, number | undefined>]>;
|
|
246
|
-
readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "
|
|
246
|
+
readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "policy" | "member" | "invite" | "security">]>;
|
|
247
247
|
readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "deleted" | "created" | "updated" | "removed" | "role_set" | "received" | "replied" | "failed" | "revoked" | "blocked" | "hold_placed" | "hold_released">]>;
|
|
248
248
|
readonly source: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventSource, undefined>, v.TransformAction<ActivityEventSource, "unspecified" | "web" | "mobile" | "api">]>;
|
|
249
249
|
readonly ip: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CreateSmartAccountParams, PolyesterSmartAccountClient, PredictPolyesterSmartAccountAddressParams, SafeSmartAccountInstance, createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation } from "./smart-account.js";
|
|
2
|
-
export { type CreateSmartAccountParams, type PolyesterSmartAccountClient, type PredictPolyesterSmartAccountAddressParams, type SafeSmartAccountInstance, createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation };
|
|
1
|
+
import { CreateSmartAccountParams, PolyesterSmartAccountClient, PolyesterSmartAccountClientOptions, PredictPolyesterSmartAccountAddressParams, SafeSmartAccountInstance, SendPolyesterUserOperationOptions, createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation, warmPolyesterSmartAccountClient } from "./smart-account.js";
|
|
2
|
+
export { type CreateSmartAccountParams, type PolyesterSmartAccountClient, type PolyesterSmartAccountClientOptions, type PredictPolyesterSmartAccountAddressParams, type SafeSmartAccountInstance, type SendPolyesterUserOperationOptions, createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation, warmPolyesterSmartAccountClient };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation } from "./smart-account.js";
|
|
2
|
-
export { createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation };
|
|
1
|
+
import { createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation, warmPolyesterSmartAccountClient } from "./smart-account.js";
|
|
2
|
+
export { createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation, warmPolyesterSmartAccountClient };
|
|
@@ -20,11 +20,18 @@ declare function predictPolyesterSmartAccountAddress({ environment, ownerAddress
|
|
|
20
20
|
* Creates a Polyester smart account instance.
|
|
21
21
|
*/
|
|
22
22
|
declare function createPolyesterSmartAccount({ environment, owner, saltNonce, publicClient }: CreateSmartAccountParams): Promise<SafeSmartAccountInstance>;
|
|
23
|
+
interface PolyesterSmartAccountClientOptions {
|
|
24
|
+
/** How long a fetched gas price is reused, in milliseconds. Defaults to 10s. */
|
|
25
|
+
gasPriceCacheTtlMs?: number;
|
|
26
|
+
/** How often to poll for UserOperation receipts, in milliseconds. Defaults to 1s. */
|
|
27
|
+
pollingIntervalMs?: number;
|
|
28
|
+
}
|
|
23
29
|
/**
|
|
24
30
|
* Creates a viem client bound to a Polyester smart account.
|
|
25
31
|
*/
|
|
26
32
|
declare function createPolyesterSmartAccountClient(account: SafeSmartAccountInstance, params: {
|
|
27
33
|
environment: PolyesterEnvironment;
|
|
34
|
+
options?: PolyesterSmartAccountClientOptions;
|
|
28
35
|
}): import("permissionless").SmartAccountClient<import("viem").HttpTransport<undefined, false>, import("viem").Chain, (object & {
|
|
29
36
|
client: import("viem").Client<import("viem").Transport, import("viem").Chain | undefined, {
|
|
30
37
|
address: Address;
|
|
@@ -3087,7 +3094,20 @@ declare function createPolyesterSmartAccountClient(account: SafeSmartAccountInst
|
|
|
3087
3094
|
isDeployed: () => Promise<boolean>;
|
|
3088
3095
|
type: "smart";
|
|
3089
3096
|
}), undefined, undefined>;
|
|
3090
|
-
|
|
3097
|
+
/**
|
|
3098
|
+
* Warms the network path for an upcoming submission: primes the gas-price
|
|
3099
|
+
* cache and opens connections to the RPC endpoint. Never throws; the nonce is
|
|
3100
|
+
* intentionally not cached — fetching it here is connection warm-up only.
|
|
3101
|
+
*/
|
|
3102
|
+
declare function warmPolyesterSmartAccountClient(client: PolyesterSmartAccountClient): Promise<void>;
|
|
3103
|
+
interface SendPolyesterUserOperationOptions {
|
|
3104
|
+
/**
|
|
3105
|
+
* Fires once per submission, immediately before the wallet is asked to
|
|
3106
|
+
* sign the fully prepared operation — the prepare→sign boundary.
|
|
3107
|
+
*/
|
|
3108
|
+
onWalletSignatureRequested?: () => void;
|
|
3109
|
+
}
|
|
3110
|
+
declare function sendPolyesterUserOperation(client: PolyesterSmartAccountClient, parameters: Parameters<PolyesterSmartAccountClient["sendUserOperation"]>[0], options?: SendPolyesterUserOperationOptions): Promise<Awaited<ReturnType<PolyesterSmartAccountClient["sendUserOperation"]>>>;
|
|
3091
3111
|
//#endregion
|
|
3092
|
-
export { CreateSmartAccountParams, PolyesterSmartAccountClient, PredictPolyesterSmartAccountAddressParams, SafeSmartAccountInstance, createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation };
|
|
3112
|
+
export { CreateSmartAccountParams, PolyesterSmartAccountClient, PolyesterSmartAccountClientOptions, PredictPolyesterSmartAccountAddressParams, SafeSmartAccountInstance, SendPolyesterUserOperationOptions, createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation, warmPolyesterSmartAccountClient };
|
|
3093
3113
|
//# sourceMappingURL=smart-account.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-account.d.ts","names":[],"sources":["../../src/smart-account/smart-account.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"smart-account.d.ts","names":[],"sources":["../../src/smart-account/smart-account.ts"],"mappings":";;;;KAUY,2BAA2B,QAAQ,kBAAkB;KACrD,8BAA8B,kBAAkB;UAiB3C;EACb,aAAa;EACb,OAAO;EACP;EACA,eAAe;;UAGF;EACb,aAAa;EACb,cAAc;EACd;;iBAGY,sCACZ,aACA,cACA,aACD,4CAA4C;;;;iBAuBzB,8BAClB,aACA,OACA,WACA,gBACD,2BAA2B,QAAQ;UAuBrB;;EAEb;;EAEA;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6DwB,UAAC;IACZ,6BAAC;;EAO5B,aAAA;IAAgB;;EAUlB,mBAAA,4BAAC,qCAAA,uBAAA;;;;;;;;;;IAwCqC;;;IAGR,gBAAC,8BAAA,yBAAA,uBAAA,4BAAA;;;;;;;;;;;;;;;;;iBA6Bb,gCAClB,QAAQ,8BACT;UA2Cc;;;;;EAKb;;iBAGkB,2BAClB,QAAQ,6BACR,YAAY,WAAW,sDACvB,UAAS,oCACV,QAAQ,QAAQ,WAAW"}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { predictSafeAddress } from "../account-signer/predict-safe-address.js";
|
|
2
2
|
import { createPublicClient, http } from "viem";
|
|
3
|
+
import { estimateUserOperationGas, prepareUserOperation } from "viem/account-abstraction";
|
|
3
4
|
import { createSmartAccountClient } from "permissionless";
|
|
4
5
|
import { toSafeSmartAccount } from "permissionless/accounts";
|
|
5
6
|
import { createPimlicoClient } from "permissionless/clients/pimlico";
|
|
6
7
|
//#region src/smart-account/smart-account.ts
|
|
7
8
|
const smartAccountEnvironmentFingerprints = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
const smartAccountClientGasPricePrimers = /* @__PURE__ */ new WeakMap();
|
|
8
10
|
const USER_OPERATION_GAS_BUFFER_BPS = 2000n;
|
|
9
11
|
const USER_OPERATION_MIN_GAS_BUFFER = 50000n;
|
|
12
|
+
const USER_OPERATION_GAS_PRICE_TTL_MS = 1e4;
|
|
13
|
+
const USER_OPERATION_RECEIPT_POLLING_INTERVAL_MS = 1e3;
|
|
10
14
|
function predictPolyesterSmartAccountAddress({ environment, ownerAddress, saltNonce = 0n }) {
|
|
11
15
|
const { safeProxyFactoryAddress, safeSingletonAddress, safeModuleSetupAddress, safe4337ModuleAddress, multiSendAddress } = environment.accountAbstraction.safe;
|
|
12
16
|
return predictSafeAddress({
|
|
@@ -42,7 +46,8 @@ async function createPolyesterSmartAccount({ environment, owner, saltNonce, publ
|
|
|
42
46
|
* Creates a viem client bound to a Polyester smart account.
|
|
43
47
|
*/
|
|
44
48
|
function createPolyesterSmartAccountClient(account, params) {
|
|
45
|
-
const { environment } = params;
|
|
49
|
+
const { environment, options } = params;
|
|
50
|
+
const { gasPriceCacheTtlMs = USER_OPERATION_GAS_PRICE_TTL_MS, pollingIntervalMs = USER_OPERATION_RECEIPT_POLLING_INTERVAL_MS } = options ?? {};
|
|
46
51
|
const accountEnvironmentFingerprint = smartAccountEnvironmentFingerprints.get(account);
|
|
47
52
|
if (accountEnvironmentFingerprint && accountEnvironmentFingerprint !== environment.fingerprint) throw new Error("Smart account environment does not match client environment.");
|
|
48
53
|
const paymaster = createPimlicoClient({
|
|
@@ -50,13 +55,52 @@ function createPolyesterSmartAccountClient(account, params) {
|
|
|
50
55
|
transport: http(environment.accountAbstraction.paymasterUrl),
|
|
51
56
|
entryPoint: environment.accountAbstraction.entryPoint
|
|
52
57
|
});
|
|
53
|
-
|
|
58
|
+
let cachedGasPrice;
|
|
59
|
+
const getGasPrice = () => {
|
|
60
|
+
if (!cachedGasPrice || Date.now() - cachedGasPrice.fetchedAt >= gasPriceCacheTtlMs) {
|
|
61
|
+
const result = paymaster.getUserOperationGasPrice();
|
|
62
|
+
const entry = {
|
|
63
|
+
fetchedAt: Date.now(),
|
|
64
|
+
result
|
|
65
|
+
};
|
|
66
|
+
cachedGasPrice = entry;
|
|
67
|
+
result.catch(() => {
|
|
68
|
+
if (cachedGasPrice === entry) cachedGasPrice = void 0;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return cachedGasPrice.result;
|
|
72
|
+
};
|
|
73
|
+
const client = createSmartAccountClient({
|
|
54
74
|
account,
|
|
55
75
|
chain: environment.chain,
|
|
56
76
|
paymaster,
|
|
57
77
|
bundlerTransport: http(environment.accountAbstraction.bundlerUrl),
|
|
58
|
-
|
|
78
|
+
pollingInterval: pollingIntervalMs,
|
|
79
|
+
userOperation: {
|
|
80
|
+
estimateFeesPerGas: async () => (await getGasPrice()).fast,
|
|
81
|
+
prepareUserOperation: (prepareClient, prepareParameters) => {
|
|
82
|
+
const bufferingClient = {
|
|
83
|
+
...prepareClient,
|
|
84
|
+
estimateUserOperationGas: async (estimateParameters) => bufferPolyesterUserOperationGas(await estimateUserOperationGas(prepareClient, estimateParameters))
|
|
85
|
+
};
|
|
86
|
+
return prepareUserOperation(bufferingClient, prepareParameters);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
59
89
|
});
|
|
90
|
+
smartAccountClientGasPricePrimers.set(client, getGasPrice);
|
|
91
|
+
return client;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Warms the network path for an upcoming submission: primes the gas-price
|
|
95
|
+
* cache and opens connections to the RPC endpoint. Never throws; the nonce is
|
|
96
|
+
* intentionally not cached — fetching it here is connection warm-up only.
|
|
97
|
+
*/
|
|
98
|
+
async function warmPolyesterSmartAccountClient(client) {
|
|
99
|
+
await Promise.allSettled([
|
|
100
|
+
smartAccountClientGasPricePrimers.get(client)?.(),
|
|
101
|
+
client.account.getNonce(),
|
|
102
|
+
client.account.isDeployed()
|
|
103
|
+
]);
|
|
60
104
|
}
|
|
61
105
|
function addUserOperationGasBuffer(gas) {
|
|
62
106
|
const percentBuffer = gas * USER_OPERATION_GAS_BUFFER_BPS / 10000n;
|
|
@@ -72,23 +116,22 @@ function bufferPolyesterUserOperationGas(gas) {
|
|
|
72
116
|
...typeof gas.paymasterVerificationGasLimit === "bigint" ? { paymasterVerificationGasLimit: addUserOperationGasBuffer(gas.paymasterVerificationGasLimit) } : {}
|
|
73
117
|
};
|
|
74
118
|
}
|
|
75
|
-
async function sendPolyesterUserOperation(client, parameters) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
119
|
+
async function sendPolyesterUserOperation(client, parameters, options = {}) {
|
|
120
|
+
const { onWalletSignatureRequested } = options;
|
|
121
|
+
if (!onWalletSignatureRequested) return client.sendUserOperation(parameters);
|
|
122
|
+
const account = parameters.account ?? client.account;
|
|
123
|
+
return client.sendUserOperation({
|
|
124
|
+
...parameters,
|
|
125
|
+
account: {
|
|
126
|
+
...account,
|
|
127
|
+
signUserOperation: (userOperation) => {
|
|
128
|
+
onWalletSignatureRequested();
|
|
129
|
+
return account.signUserOperation(userOperation);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
90
133
|
}
|
|
91
134
|
//#endregion
|
|
92
|
-
export { createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation };
|
|
135
|
+
export { createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation, warmPolyesterSmartAccountClient };
|
|
93
136
|
|
|
94
137
|
//# sourceMappingURL=smart-account.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-account.js","names":[],"sources":["../../src/smart-account/smart-account.ts"],"sourcesContent":["import type { Address, LocalAccount, PublicClient } from \"viem\";\nimport { createPublicClient, http } from \"viem\";\nimport { createSmartAccountClient } from \"permissionless\";\nimport { toSafeSmartAccount } from \"permissionless/accounts\";\nimport { createPimlicoClient } from \"permissionless/clients/pimlico\";\nimport type { PolyesterEnvironment } from \"../environment.js\";\nimport { predictSafeAddress } from \"../account-signer/predict-safe-address.js\";\n\nexport type SafeSmartAccountInstance = Awaited<ReturnType<typeof toSafeSmartAccount>>;\nexport type PolyesterSmartAccountClient = ReturnType<typeof createPolyesterSmartAccountClient>;\n\nconst smartAccountEnvironmentFingerprints = new WeakMap<SafeSmartAccountInstance, string>();\nconst USER_OPERATION_GAS_BUFFER_BPS = 2_000n;\nconst USER_OPERATION_MIN_GAS_BUFFER = 50_000n;\n\ntype PolyesterUserOperationGas = {\n callGasLimit?: bigint;\n preVerificationGas?: bigint;\n verificationGasLimit?: bigint;\n paymasterPostOpGasLimit?: bigint;\n paymasterVerificationGasLimit?: bigint;\n};\n\nexport interface CreateSmartAccountParams {\n environment: PolyesterEnvironment;\n owner: LocalAccount;\n saltNonce?: bigint;\n publicClient?: PublicClient;\n}\n\nexport interface PredictPolyesterSmartAccountAddressParams {\n environment: PolyesterEnvironment;\n ownerAddress: Address;\n saltNonce?: bigint;\n}\n\nexport function predictPolyesterSmartAccountAddress({\n environment,\n ownerAddress,\n saltNonce = 0n,\n}: PredictPolyesterSmartAccountAddressParams): Address {\n const {\n safeProxyFactoryAddress,\n safeSingletonAddress,\n safeModuleSetupAddress,\n safe4337ModuleAddress,\n multiSendAddress,\n } = environment.accountAbstraction.safe;\n\n return predictSafeAddress({\n owners: [ownerAddress],\n saltNonce,\n safeProxyFactoryAddress,\n safeSingletonAddress,\n safeModuleSetupAddress,\n safe4337ModuleAddress,\n multiSendAddress,\n });\n}\n\n/**\n * Creates a Polyester smart account instance.\n */\nexport async function createPolyesterSmartAccount({\n environment,\n owner,\n saltNonce,\n publicClient,\n}: CreateSmartAccountParams): Promise<SafeSmartAccountInstance> {\n const client =\n publicClient ??\n createPublicClient({\n chain: environment.chain,\n transport: http(environment.rpcUrl),\n });\n\n if (client.chain?.id && client.chain.id !== environment.chain.id) {\n throw new Error(\"Smart account public client chain does not match environment.\");\n }\n\n const account = await toSafeSmartAccount({\n client,\n owners: [owner],\n saltNonce,\n entryPoint: environment.accountAbstraction.entryPoint,\n ...environment.accountAbstraction.safe,\n });\n smartAccountEnvironmentFingerprints.set(account, environment.fingerprint);\n return account;\n}\n\n/**\n * Creates a viem client bound to a Polyester smart account.\n */\nexport function createPolyesterSmartAccountClient(\n account: SafeSmartAccountInstance,\n params: { environment: PolyesterEnvironment },\n) {\n const { environment } = params;\n const accountEnvironmentFingerprint = smartAccountEnvironmentFingerprints.get(account);\n if (\n accountEnvironmentFingerprint &&\n accountEnvironmentFingerprint !== environment.fingerprint\n ) {\n throw new Error(\"Smart account environment does not match client environment.\");\n }\n\n const paymaster = createPimlicoClient({\n chain: environment.chain,\n transport: http(environment.accountAbstraction.paymasterUrl),\n entryPoint: environment.accountAbstraction.entryPoint,\n });\n\n return createSmartAccountClient({\n account,\n chain: environment.chain,\n paymaster,\n bundlerTransport: http(environment.accountAbstraction.bundlerUrl),\n userOperation: {\n estimateFeesPerGas: async () => (await paymaster.getUserOperationGasPrice()).fast,\n },\n });\n}\n\nfunction addUserOperationGasBuffer(gas: bigint): bigint {\n const percentBuffer = (gas * USER_OPERATION_GAS_BUFFER_BPS) / 10_000n;\n return (\n gas +\n (percentBuffer > USER_OPERATION_MIN_GAS_BUFFER\n ? percentBuffer\n : USER_OPERATION_MIN_GAS_BUFFER)\n );\n}\n\nfunction bufferPolyesterUserOperationGas<T extends PolyesterUserOperationGas>(gas: T): T {\n return {\n ...gas,\n ...(typeof gas.callGasLimit === \"bigint\"\n ? { callGasLimit: addUserOperationGasBuffer(gas.callGasLimit) }\n : {}),\n ...(typeof gas.preVerificationGas === \"bigint\"\n ? { preVerificationGas: addUserOperationGasBuffer(gas.preVerificationGas) }\n : {}),\n ...(typeof gas.verificationGasLimit === \"bigint\"\n ? { verificationGasLimit: addUserOperationGasBuffer(gas.verificationGasLimit) }\n : {}),\n ...(typeof gas.paymasterPostOpGasLimit === \"bigint\"\n ? { paymasterPostOpGasLimit: addUserOperationGasBuffer(gas.paymasterPostOpGasLimit) }\n : {}),\n ...(typeof gas.paymasterVerificationGasLimit === \"bigint\"\n ? {\n paymasterVerificationGasLimit: addUserOperationGasBuffer(\n gas.paymasterVerificationGasLimit,\n ),\n }\n : {}),\n };\n}\n\nexport async function sendPolyesterUserOperation(\n client: PolyesterSmartAccountClient,\n parameters: Parameters<PolyesterSmartAccountClient[\"sendUserOperation\"]>[0],\n): Promise<Awaited<ReturnType<PolyesterSmartAccountClient[\"sendUserOperation\"]>>> {\n try {\n const gas = await client.estimateUserOperationGas({\n callGasLimit: 0n,\n preVerificationGas: 0n,\n verificationGasLimit: 0n,\n ...parameters,\n } as Parameters<PolyesterSmartAccountClient[\"estimateUserOperationGas\"]>[0]);\n return client.sendUserOperation({\n ...parameters,\n ...bufferPolyesterUserOperationGas(gas),\n } as Parameters<PolyesterSmartAccountClient[\"sendUserOperation\"]>[0]);\n } catch {\n return client.sendUserOperation(parameters);\n }\n}\n"],"mappings":";;;;;;AAWA,MAAM,sDAAsC,IAAI,QAA0C;AAC1F,MAAM,gCAAgC;AACtC,MAAM,gCAAgC;AAuBtC,SAAgB,oCAAoC,EAChD,aACA,cACA,YAAY,MACuC;CACnD,MAAM,EACF,yBACA,sBACA,wBACA,uBACA,qBACA,YAAY,mBAAmB;CAEnC,OAAO,mBAAmB;EACtB,QAAQ,CAAC,YAAY;EACrB;EACA;EACA;EACA;EACA;EACA;CACJ,CAAC;AACL;;;;AAKA,eAAsB,4BAA4B,EAC9C,aACA,OACA,WACA,gBAC4D;CAC5D,MAAM,SACF,gBACA,mBAAmB;EACf,OAAO,YAAY;EACnB,WAAW,KAAK,YAAY,MAAM;CACtC,CAAC;CAEL,IAAI,OAAO,OAAO,MAAM,OAAO,MAAM,OAAO,YAAY,MAAM,IAC1D,MAAM,IAAI,MAAM,+DAA+D;CAGnF,MAAM,UAAU,MAAM,mBAAmB;EACrC;EACA,QAAQ,CAAC,KAAK;EACd;EACA,YAAY,YAAY,mBAAmB;EAC3C,GAAG,YAAY,mBAAmB;CACtC,CAAC;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C,cAAc;GACd,oBAAoB;GACpB,sBAAsB;GACtB,GAAG;EACP,CAA2E;EAC3E,OAAO,OAAO,kBAAkB;GAC5B,GAAG;GACH,GAAG,gCAAgC,GAAG;EAC1C,CAAoE;CACxE,QAAQ;EACJ,OAAO,OAAO,kBAAkB,UAAU;CAC9C;AACJ"}
|
|
1
|
+
{"version":3,"file":"smart-account.js","names":[],"sources":["../../src/smart-account/smart-account.ts"],"sourcesContent":["import type { Address, LocalAccount, PublicClient } from \"viem\";\nimport { createPublicClient, http } from \"viem\";\nimport type { EstimateUserOperationGasParameters } from \"viem/account-abstraction\";\nimport { estimateUserOperationGas, prepareUserOperation } from \"viem/account-abstraction\";\nimport { createSmartAccountClient } from \"permissionless\";\nimport { toSafeSmartAccount } from \"permissionless/accounts\";\nimport { createPimlicoClient } from \"permissionless/clients/pimlico\";\nimport type { PolyesterEnvironment } from \"../environment.js\";\nimport { predictSafeAddress } from \"../account-signer/predict-safe-address.js\";\n\nexport type SafeSmartAccountInstance = Awaited<ReturnType<typeof toSafeSmartAccount>>;\nexport type PolyesterSmartAccountClient = ReturnType<typeof createPolyesterSmartAccountClient>;\n\nconst smartAccountEnvironmentFingerprints = new WeakMap<SafeSmartAccountInstance, string>();\nconst smartAccountClientGasPricePrimers = new WeakMap<object, () => Promise<unknown>>();\nconst USER_OPERATION_GAS_BUFFER_BPS = 2_000n;\nconst USER_OPERATION_MIN_GAS_BUFFER = 50_000n;\nconst USER_OPERATION_GAS_PRICE_TTL_MS = 10_000;\nconst USER_OPERATION_RECEIPT_POLLING_INTERVAL_MS = 1_000;\n\ntype PolyesterUserOperationGas = {\n callGasLimit?: bigint;\n preVerificationGas?: bigint;\n verificationGasLimit?: bigint;\n paymasterPostOpGasLimit?: bigint;\n paymasterVerificationGasLimit?: bigint;\n};\n\nexport interface CreateSmartAccountParams {\n environment: PolyesterEnvironment;\n owner: LocalAccount;\n saltNonce?: bigint;\n publicClient?: PublicClient;\n}\n\nexport interface PredictPolyesterSmartAccountAddressParams {\n environment: PolyesterEnvironment;\n ownerAddress: Address;\n saltNonce?: bigint;\n}\n\nexport function predictPolyesterSmartAccountAddress({\n environment,\n ownerAddress,\n saltNonce = 0n,\n}: PredictPolyesterSmartAccountAddressParams): Address {\n const {\n safeProxyFactoryAddress,\n safeSingletonAddress,\n safeModuleSetupAddress,\n safe4337ModuleAddress,\n multiSendAddress,\n } = environment.accountAbstraction.safe;\n\n return predictSafeAddress({\n owners: [ownerAddress],\n saltNonce,\n safeProxyFactoryAddress,\n safeSingletonAddress,\n safeModuleSetupAddress,\n safe4337ModuleAddress,\n multiSendAddress,\n });\n}\n\n/**\n * Creates a Polyester smart account instance.\n */\nexport async function createPolyesterSmartAccount({\n environment,\n owner,\n saltNonce,\n publicClient,\n}: CreateSmartAccountParams): Promise<SafeSmartAccountInstance> {\n const client =\n publicClient ??\n createPublicClient({\n chain: environment.chain,\n transport: http(environment.rpcUrl),\n });\n\n if (client.chain?.id && client.chain.id !== environment.chain.id) {\n throw new Error(\"Smart account public client chain does not match environment.\");\n }\n\n const account = await toSafeSmartAccount({\n client,\n owners: [owner],\n saltNonce,\n entryPoint: environment.accountAbstraction.entryPoint,\n ...environment.accountAbstraction.safe,\n });\n smartAccountEnvironmentFingerprints.set(account, environment.fingerprint);\n return account;\n}\n\nexport interface PolyesterSmartAccountClientOptions {\n /** How long a fetched gas price is reused, in milliseconds. Defaults to 10s. */\n gasPriceCacheTtlMs?: number;\n /** How often to poll for UserOperation receipts, in milliseconds. Defaults to 1s. */\n pollingIntervalMs?: number;\n}\n\n/**\n * Creates a viem client bound to a Polyester smart account.\n */\nexport function createPolyesterSmartAccountClient(\n account: SafeSmartAccountInstance,\n params: {\n environment: PolyesterEnvironment;\n options?: PolyesterSmartAccountClientOptions;\n },\n) {\n const { environment, options } = params;\n const {\n gasPriceCacheTtlMs = USER_OPERATION_GAS_PRICE_TTL_MS,\n pollingIntervalMs = USER_OPERATION_RECEIPT_POLLING_INTERVAL_MS,\n } = options ?? {};\n const accountEnvironmentFingerprint = smartAccountEnvironmentFingerprints.get(account);\n if (\n accountEnvironmentFingerprint &&\n accountEnvironmentFingerprint !== environment.fingerprint\n ) {\n throw new Error(\"Smart account environment does not match client environment.\");\n }\n\n const paymaster = createPimlicoClient({\n chain: environment.chain,\n transport: http(environment.accountAbstraction.paymasterUrl),\n entryPoint: environment.accountAbstraction.entryPoint,\n });\n\n let cachedGasPrice:\n | { fetchedAt: number; result: ReturnType<typeof paymaster.getUserOperationGasPrice> }\n | undefined;\n const getGasPrice = () => {\n if (!cachedGasPrice || Date.now() - cachedGasPrice.fetchedAt >= gasPriceCacheTtlMs) {\n const result = paymaster.getUserOperationGasPrice();\n const entry = { fetchedAt: Date.now(), result };\n cachedGasPrice = entry;\n result.catch(() => {\n if (cachedGasPrice === entry) cachedGasPrice = undefined;\n });\n }\n return cachedGasPrice.result;\n };\n\n const client = createSmartAccountClient({\n account,\n chain: environment.chain,\n paymaster,\n bundlerTransport: http(environment.accountAbstraction.bundlerUrl),\n pollingInterval: pollingIntervalMs,\n userOperation: {\n estimateFeesPerGas: async () => (await getGasPrice()).fast,\n // Single prepare pass: viem resolves gas estimation via\n // `getAction(client, estimateUserOperationGas, ...)`, so handing\n // `prepareUserOperation` a client whose estimate action buffers the\n // result makes the buffered limits flow into `pm_getPaymasterData`\n // before signing — the sponsorship signature commits to them.\n prepareUserOperation: (prepareClient, prepareParameters) => {\n const bufferingClient = {\n ...prepareClient,\n estimateUserOperationGas: async (\n estimateParameters: EstimateUserOperationGasParameters,\n ) =>\n bufferPolyesterUserOperationGas(\n await estimateUserOperationGas(prepareClient, estimateParameters),\n ),\n };\n return prepareUserOperation(\n bufferingClient as typeof prepareClient,\n prepareParameters as Parameters<typeof prepareUserOperation>[1],\n );\n },\n },\n });\n smartAccountClientGasPricePrimers.set(client, getGasPrice);\n return client;\n}\n\n/**\n * Warms the network path for an upcoming submission: primes the gas-price\n * cache and opens connections to the RPC endpoint. Never throws; the nonce is\n * intentionally not cached — fetching it here is connection warm-up only.\n */\nexport async function warmPolyesterSmartAccountClient(\n client: PolyesterSmartAccountClient,\n): Promise<void> {\n await Promise.allSettled([\n smartAccountClientGasPricePrimers.get(client)?.(),\n client.account.getNonce(),\n client.account.isDeployed(),\n ]);\n}\n\nfunction addUserOperationGasBuffer(gas: bigint): bigint {\n const percentBuffer = (gas * USER_OPERATION_GAS_BUFFER_BPS) / 10_000n;\n return (\n gas +\n (percentBuffer > USER_OPERATION_MIN_GAS_BUFFER\n ? percentBuffer\n : USER_OPERATION_MIN_GAS_BUFFER)\n );\n}\n\nfunction bufferPolyesterUserOperationGas<T extends PolyesterUserOperationGas>(gas: T): T {\n return {\n ...gas,\n ...(typeof gas.callGasLimit === \"bigint\"\n ? { callGasLimit: addUserOperationGasBuffer(gas.callGasLimit) }\n : {}),\n ...(typeof gas.preVerificationGas === \"bigint\"\n ? { preVerificationGas: addUserOperationGasBuffer(gas.preVerificationGas) }\n : {}),\n ...(typeof gas.verificationGasLimit === \"bigint\"\n ? { verificationGasLimit: addUserOperationGasBuffer(gas.verificationGasLimit) }\n : {}),\n ...(typeof gas.paymasterPostOpGasLimit === \"bigint\"\n ? { paymasterPostOpGasLimit: addUserOperationGasBuffer(gas.paymasterPostOpGasLimit) }\n : {}),\n ...(typeof gas.paymasterVerificationGasLimit === \"bigint\"\n ? {\n paymasterVerificationGasLimit: addUserOperationGasBuffer(\n gas.paymasterVerificationGasLimit,\n ),\n }\n : {}),\n };\n}\n\nexport interface SendPolyesterUserOperationOptions {\n /**\n * Fires once per submission, immediately before the wallet is asked to\n * sign the fully prepared operation — the prepare→sign boundary.\n */\n onWalletSignatureRequested?: () => void;\n}\n\nexport async function sendPolyesterUserOperation(\n client: PolyesterSmartAccountClient,\n parameters: Parameters<PolyesterSmartAccountClient[\"sendUserOperation\"]>[0],\n options: SendPolyesterUserOperationOptions = {},\n): Promise<Awaited<ReturnType<PolyesterSmartAccountClient[\"sendUserOperation\"]>>> {\n const { onWalletSignatureRequested } = options;\n if (!onWalletSignatureRequested) return client.sendUserOperation(parameters);\n\n const account =\n (parameters as { account?: SafeSmartAccountInstance }).account ?? client.account;\n return client.sendUserOperation({\n ...parameters,\n account: {\n ...account,\n signUserOperation: (\n userOperation: Parameters<SafeSmartAccountInstance[\"signUserOperation\"]>[0],\n ) => {\n onWalletSignatureRequested();\n return account.signUserOperation(userOperation);\n },\n },\n } as Parameters<PolyesterSmartAccountClient[\"sendUserOperation\"]>[0]);\n}\n"],"mappings":";;;;;;;AAaA,MAAM,sDAAsC,IAAI,QAA0C;AAC1F,MAAM,oDAAoC,IAAI,QAAwC;AACtF,MAAM,gCAAgC;AACtC,MAAM,gCAAgC;AACtC,MAAM,kCAAkC;AACxC,MAAM,6CAA6C;AAuBnD,SAAgB,oCAAoC,EAChD,aACA,cACA,YAAY,MACuC;CACnD,MAAM,EACF,yBACA,sBACA,wBACA,uBACA,qBACA,YAAY,mBAAmB;CAEnC,OAAO,mBAAmB;EACtB,QAAQ,CAAC,YAAY;EACrB;EACA;EACA;EACA;EACA;EACA;CACJ,CAAC;AACL;;;;AAKA,eAAsB,4BAA4B,EAC9C,aACA,OACA,WACA,gBAC4D;CAC5D,MAAM,SACF,gBACA,mBAAmB;EACf,OAAO,YAAY;EACnB,WAAW,KAAK,YAAY,MAAM;CACtC,CAAC;CAEL,IAAI,OAAO,OAAO,MAAM,OAAO,MAAM,OAAO,YAAY,MAAM,IAC1D,MAAM,IAAI,MAAM,+DAA+D;CAGnF,MAAM,UAAU,MAAM,mBAAmB;EACrC;EACA,QAAQ,CAAC,KAAK;EACd;EACA,YAAY,YAAY,mBAAmB;EAC3C,GAAG,YAAY,mBAAmB;CACtC,CAAC;CACD,oCAAoC,IAAI,SAAS,YAAY,WAAW;CACxE,OAAO;AACX;;;;AAYA,SAAgB,kCACZ,SACA,QAIF;CACE,MAAM,EAAE,aAAa,YAAY;CACjC,MAAM,EACF,qBAAqB,iCACrB,oBAAoB,+CACpB,WAAW,CAAC;CAChB,MAAM,g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