@argent/x-shared 1.59.0 → 1.60.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/dist/index.cjs +1 -1
- package/dist/index.js +224 -214
- package/dist/simulation.cjs +1 -1
- package/dist/simulation.js +68 -55
- package/dist/src/features/simulation/fees/schema.cjs +1 -1
- package/dist/src/features/simulation/fees/schema.d.ts +848 -0
- package/dist/src/features/simulation/fees/schema.js +36 -4
- package/dist/src/features/simulation/transactionReview/schema.cjs +1 -1
- package/dist/src/features/simulation/transactionReview/schema.d.ts +8264 -148
- package/dist/src/features/simulation/transactionReview/schema.js +105 -85
- package/dist/src/staking/schema.d.ts +24 -24
- package/dist/src/transactions/estimate/index.d.ts +1 -0
- package/dist/src/transactions/estimate/utilsV2.cjs +1 -0
- package/dist/src/transactions/estimate/utilsV2.d.ts +14 -0
- package/dist/src/transactions/estimate/utilsV2.js +96 -0
- package/dist/src/transactions/getTransactionVersion.cjs +1 -1
- package/dist/src/transactions/getTransactionVersion.d.ts +6 -0
- package/dist/src/transactions/getTransactionVersion.js +15 -12
- package/dist/src/transactions/txv3.cjs +1 -1
- package/dist/src/transactions/txv3.js +4 -4
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/type.utils.d.ts +215 -0
- package/package.json +3 -3
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import { constants as
|
|
2
|
-
import { feeTokenNeedsTxV3Support as
|
|
3
|
-
function S(
|
|
4
|
-
return
|
|
5
|
-
address:
|
|
6
|
-
}) ?
|
|
1
|
+
import { constants as r, isSierra as T } from "starknet";
|
|
2
|
+
import { feeTokenNeedsTxV3Support as t, classHashSupportsTxV3 as n } from "./txv3.js";
|
|
3
|
+
function S(e) {
|
|
4
|
+
return t({
|
|
5
|
+
address: e
|
|
6
|
+
}) ? r.TRANSACTION_VERSION.V3 : r.TRANSACTION_VERSION.V1;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
return
|
|
8
|
+
function A(e) {
|
|
9
|
+
return t({ address: e }) ? r.TRANSACTION_VERSION.F3 : r.TRANSACTION_VERSION.F1;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
return N
|
|
11
|
+
function I(e, N) {
|
|
12
|
+
return T(N.contract) ? t({ address: e }) ? r.TRANSACTION_VERSION.V3 : r.TRANSACTION_VERSION.V2 : r.TRANSACTION_VERSION.V1;
|
|
13
13
|
}
|
|
14
|
+
const O = ({ classHash: e }) => e && !n(e) ? r.TRANSACTION_VERSION.V1 : r.TRANSACTION_VERSION.V3, R = ({ classHash: e }, N) => T(N.contract) ? e && !n(e) ? r.TRANSACTION_VERSION.V2 : r.TRANSACTION_VERSION.V3 : r.TRANSACTION_VERSION.V1;
|
|
14
15
|
export {
|
|
15
|
-
|
|
16
|
+
O as getAccountTxVersion,
|
|
17
|
+
A as getSimulationTxVersionFromFeeToken,
|
|
18
|
+
R as getTxVersionForDeclareContract,
|
|
16
19
|
S as getTxVersionFromFeeToken,
|
|
17
|
-
|
|
20
|
+
I as getTxVersionFromFeeTokenForDeclareContract
|
|
18
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chains/starknet/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chains/starknet/services/deploymentData/getAccountClassHash.cjs"),o=require("../chains/starknet/constants.cjs"),t=require("../chains/starknet/address.cjs"),u=[o.STRK_TOKEN_ADDRESS];function n({address:e}){return u.some(s=>t.isEqualAddress(e,s))}function a(e){return e?r.getArgentAccountClassHashesWithTxV3Support().some(s=>t.isEqualAddress(s,e)):!1}exports.classHashSupportsTxV3=a;exports.feeTokenNeedsTxV3Support=n;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getArgentAccountClassHashesWithTxV3Support as t } from "../chains/starknet/services/deploymentData/getAccountClassHash.js";
|
|
2
|
+
import { STRK_TOKEN_ADDRESS as s } from "../chains/starknet/constants.js";
|
|
3
3
|
import { isEqualAddress as o } from "../chains/starknet/address.js";
|
|
4
|
-
const n = [
|
|
4
|
+
const n = [s];
|
|
5
5
|
function f({ address: r }) {
|
|
6
6
|
return n.some((e) => o(r, e));
|
|
7
7
|
}
|
|
8
8
|
function m(r) {
|
|
9
|
-
return r ?
|
|
9
|
+
return r ? t().some((e) => o(e, r)) : !1;
|
|
10
10
|
}
|
|
11
11
|
export {
|
|
12
12
|
m as classHashSupportsTxV3,
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
declare const symbol: unique symbol;
|
|
2
|
+
/**
|
|
3
|
+
* Creates a branded type of {@link T} with the brand {@link U}.
|
|
4
|
+
*
|
|
5
|
+
* @param T - Type to brand
|
|
6
|
+
* @param U - Label
|
|
7
|
+
* @returns Branded type
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* type Result = Branded<string, 'foo'>
|
|
11
|
+
* // ^? type Result = string & { [symbol]: 'foo' }
|
|
12
|
+
*/
|
|
13
|
+
export type Branded<T, U> = T & {
|
|
14
|
+
[symbol]: U;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* @description Combines members of an intersection into a readable type.
|
|
18
|
+
*
|
|
19
|
+
* @see {@link https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg}
|
|
20
|
+
* @example
|
|
21
|
+
* Prettify<{ a: string } & { b: string } & { c: number, d: bigint }>
|
|
22
|
+
* => { a: string, b: string, c: number, d: bigint }
|
|
23
|
+
*/
|
|
24
|
+
export type Prettify<T> = {
|
|
25
|
+
[K in keyof T]: T[K];
|
|
26
|
+
} & {};
|
|
27
|
+
/**
|
|
28
|
+
* Filters out all members of {@link T} that are not {@link P}
|
|
29
|
+
*
|
|
30
|
+
* @param T - Items to filter
|
|
31
|
+
* @param P - Type to filter out
|
|
32
|
+
* @returns Filtered items
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* type Result = Filter<['a', 'b', 'c'], 'b'>
|
|
36
|
+
* // ^? type Result = ['a', 'c']
|
|
37
|
+
*/
|
|
38
|
+
export type Filter<T extends readonly unknown[], P, Acc extends readonly unknown[] = []> = T extends readonly [infer F, ...infer Rest extends readonly unknown[]] ? [F] extends [P] ? Filter<Rest, P, [...Acc, F]> : Filter<Rest, P, Acc> : readonly [...Acc];
|
|
39
|
+
/**
|
|
40
|
+
* @description Checks if {@link T} can be narrowed further than {@link U}
|
|
41
|
+
* @param T - Type to check
|
|
42
|
+
* @param U - Type to against
|
|
43
|
+
* @example
|
|
44
|
+
* type Result = IsNarrowable<'foo', string>
|
|
45
|
+
* // ^? true
|
|
46
|
+
*/
|
|
47
|
+
export type IsNarrowable<T, U> = IsNever<(T extends U ? true : false) & (U extends T ? false : true)> extends true ? false : true;
|
|
48
|
+
/**
|
|
49
|
+
* @description Checks if {@link T} is `never`
|
|
50
|
+
* @param T - Type to check
|
|
51
|
+
* @example
|
|
52
|
+
* type Result = IsNever<never>
|
|
53
|
+
* // ^? type Result = true
|
|
54
|
+
*/
|
|
55
|
+
export type IsNever<T> = [T] extends [never] ? true : false;
|
|
56
|
+
/** Removes `readonly` from all properties of an object. */
|
|
57
|
+
export type Mutable<type extends object> = {
|
|
58
|
+
-readonly [key in keyof type]: type[key];
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* @description Evaluates boolean "or" condition for {@link T} properties.
|
|
62
|
+
* @param T - Type to check
|
|
63
|
+
*
|
|
64
|
+
* * @example
|
|
65
|
+
* type Result = Or<[false, true, false]>
|
|
66
|
+
* // ^? type Result = true
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* type Result = Or<[false, false, false]>
|
|
70
|
+
* // ^? type Result = false
|
|
71
|
+
*/
|
|
72
|
+
export type Or<T extends readonly unknown[]> = T extends readonly [
|
|
73
|
+
infer Head,
|
|
74
|
+
...infer Tail
|
|
75
|
+
] ? Head extends true ? true : Or<Tail> : false;
|
|
76
|
+
/**
|
|
77
|
+
* @description Checks if {@link T} is `undefined`
|
|
78
|
+
* @param T - Type to check
|
|
79
|
+
* @example
|
|
80
|
+
* type Result = IsUndefined<undefined>
|
|
81
|
+
* // ^? type Result = true
|
|
82
|
+
*/
|
|
83
|
+
export type IsUndefined<T> = [undefined] extends [T] ? true : false;
|
|
84
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
85
|
+
/**
|
|
86
|
+
* @description Makes attributes on the type T required if required is true.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* MaybeRequired<{ a: string, b?: number }, true>
|
|
90
|
+
* => { a: string, b: number }
|
|
91
|
+
*
|
|
92
|
+
* MaybeRequired<{ a: string, b?: number }, false>
|
|
93
|
+
* => { a: string, b?: number }
|
|
94
|
+
*/
|
|
95
|
+
export type MaybeRequired<T, required extends boolean> = required extends true ? ExactRequired<T> : T;
|
|
96
|
+
export type ExactRequired<type> = {
|
|
97
|
+
[P in keyof type]-?: Exclude<type[P], undefined>;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* @description Assigns the properties of U onto T.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* Assign<{ a: string, b: number }, { a: undefined, c: boolean }>
|
|
104
|
+
* => { a: undefined, b: number, c: boolean }
|
|
105
|
+
*/
|
|
106
|
+
export type Assign<T, U> = Assign_<T, U> & U;
|
|
107
|
+
type Assign_<T, U> = {
|
|
108
|
+
[K in keyof T as K extends keyof U ? U[K] extends void ? never : K : K]: K extends keyof U ? U[K] : T[K];
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* @description Constructs a type by excluding `undefined` from `T`.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* NoUndefined<string | undefined>
|
|
115
|
+
* => string
|
|
116
|
+
*
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
119
|
+
export type NoUndefined<T> = T extends undefined ? never : T;
|
|
120
|
+
/** Strict version of built-in Omit type */
|
|
121
|
+
export type StrictOmit<type, keys extends keyof type> = Pick<type, Exclude<keyof type, keys>>;
|
|
122
|
+
/**
|
|
123
|
+
* @description Creates a type that is a partial of T, but with the required keys K.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* PartialBy<{ a: string, b: number }, 'a'>
|
|
127
|
+
* => { a?: string, b: number }
|
|
128
|
+
*/
|
|
129
|
+
export type PartialBy<T, K extends keyof T> = Omit<T, K> & ExactPartial<Pick<T, K>>;
|
|
130
|
+
export type ExactPartial<type> = {
|
|
131
|
+
[key in keyof type]?: type[key] | undefined;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* @description Creates a type that is T with the required keys K.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* RequiredBy<{ a?: string, b: number }, 'a'>
|
|
138
|
+
* => { a: string, b: number }
|
|
139
|
+
*/
|
|
140
|
+
export type RequiredBy<T, K extends keyof T> = Omit<T, K> & ExactRequired<Pick<T, K>>;
|
|
141
|
+
/**
|
|
142
|
+
* @description Returns truthy if `array` contains `value`.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* Some<[1, 2, 3], 2>
|
|
146
|
+
* => true
|
|
147
|
+
*/
|
|
148
|
+
export type Some<array extends readonly unknown[], value> = array extends readonly [value, ...unknown[]] ? true : array extends readonly [unknown, ...infer rest] ? Some<rest, value> : false;
|
|
149
|
+
/**
|
|
150
|
+
* @description Creates a type that extracts the values of T.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ValueOf<{ a: string, b: number }>
|
|
154
|
+
* => string | number
|
|
155
|
+
*
|
|
156
|
+
* @internal
|
|
157
|
+
*/
|
|
158
|
+
export type ValueOf<T> = T[keyof T];
|
|
159
|
+
/**
|
|
160
|
+
* @description Converts a union to a tuple.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* UnionToTuple<string | number | boolean>
|
|
164
|
+
* => [string, number, boolean]
|
|
165
|
+
*
|
|
166
|
+
*/
|
|
167
|
+
export type UnionToTuple<union, last = LastInUnion<union>> = [union] extends [never] ? [] : [...UnionToTuple<Exclude<union, last>>, last];
|
|
168
|
+
type LastInUnion<U> = UnionToIntersection<U extends unknown ? (x: U) => 0 : never> extends (x: infer l) => 0 ? l : never;
|
|
169
|
+
type UnionToIntersection<union> = (union extends unknown ? (arg: union) => 0 : never) extends (arg: infer i) => 0 ? i : never;
|
|
170
|
+
export type IsUnion<union, union2 = union> = union extends union2 ? ([union2] extends [union] ? false : true) : never;
|
|
171
|
+
export type MaybePartial<type, enabled extends boolean | undefined> = enabled extends true ? Prettify<ExactPartial<type>> : type;
|
|
172
|
+
/**
|
|
173
|
+
* @description Creates a type that is a one of the keys of {@link union}.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* OneOf<{ a: string, b: number }, { a: string }>
|
|
177
|
+
* => { a: string, b?: number }
|
|
178
|
+
*/
|
|
179
|
+
export type OneOf<union extends object, fallback extends object | undefined = undefined, keys extends KeyofUnion<union> = KeyofUnion<union>> = union extends infer item ? Prettify<item & {
|
|
180
|
+
[key in Exclude<keys, keyof item>]?: fallback extends object ? key extends keyof fallback ? fallback[key] : undefined : undefined;
|
|
181
|
+
}> : never;
|
|
182
|
+
type KeyofUnion<type> = type extends type ? keyof type : never;
|
|
183
|
+
export type UnionEvaluate<type> = type extends object ? Prettify<type> : type;
|
|
184
|
+
export type UnionLooseOmit<type, keys extends string> = type extends any ? Omit<type, keys> : never;
|
|
185
|
+
/**
|
|
186
|
+
* @description Construct a type with the properties of union type T except for those in type K.
|
|
187
|
+
* @example
|
|
188
|
+
* type Result = UnionStrictOmit<{ a: string, b: number } | { a: string, b: undefined, c: number }, 'a'>
|
|
189
|
+
* => { b: number } | { b: undefined, c: number }
|
|
190
|
+
*/
|
|
191
|
+
export type UnionStrictOmit<type, keys extends keyof type> = type extends any ? StrictOmit<type, keys> : never;
|
|
192
|
+
/**
|
|
193
|
+
* @description Construct a type with the properties of union type T except for those in type K.
|
|
194
|
+
* @example
|
|
195
|
+
* type Result = UnionOmit<{ a: string, b: number } | { a: string, b: undefined, c: number }, 'a'>
|
|
196
|
+
* => { b: number } | { b: undefined, c: number }
|
|
197
|
+
*/
|
|
198
|
+
export type UnionPick<type, keys extends keyof type> = type extends any ? Pick<type, keys> : never;
|
|
199
|
+
/**
|
|
200
|
+
* @description Creates a type that is a partial of T, but with the required keys K.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* UnionPartialBy<{ a: string, b: number } | { a: string, b: undefined, c: number }, 'a'>
|
|
204
|
+
* => { a?: string, b: number } | { a?: string, b: undefined, c: number }
|
|
205
|
+
*/
|
|
206
|
+
export type UnionPartialBy<T, K extends keyof T> = T extends any ? PartialBy<T, K> : never;
|
|
207
|
+
/**
|
|
208
|
+
* @description Creates a type that is T with the required keys K.
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* UnionRequiredBy<{ a?: string, b: number } | { a?: string, c?: number }, 'a'>
|
|
212
|
+
* => { a: string, b: number } | { a: string, c?: number }
|
|
213
|
+
*/
|
|
214
|
+
export type UnionRequiredBy<T, K extends keyof T> = T extends any ? RequiredBy<T, K> : never;
|
|
215
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argent/x-shared",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.60.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/argentlabs/x-shared.git"
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@typescript-eslint/eslint-plugin": "8.18.0",
|
|
56
56
|
"@typescript-eslint/parser": "8.18.0",
|
|
57
57
|
"eslint": "8.57.1",
|
|
58
|
-
"eslint-config-prettier": "
|
|
58
|
+
"eslint-config-prettier": "10.0.1",
|
|
59
59
|
"eslint-plugin-import": "2.31.0",
|
|
60
60
|
"husky": "9.1.7",
|
|
61
61
|
"lint-staged": "15.2.11",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"typescript": "5.7.2",
|
|
67
67
|
"vite": "6.0.3",
|
|
68
68
|
"vite-plugin-dts": "4.3.0",
|
|
69
|
-
"vitest": "
|
|
69
|
+
"vitest": "3.0.5"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@argent/x-multicall": "^7.1.0",
|