@argent/x-shared 1.42.1 → 1.43.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +1 -1
  2. package/dist/.eslintrc.d.cts +2 -0
  3. package/dist/index.cjs +1 -1
  4. package/dist/index.js +297 -295
  5. package/dist/src/backend/index.d.ts +1 -1
  6. package/dist/src/bigdecimal/index.d.ts +1 -1
  7. package/dist/src/cache/index.d.ts +1 -1
  8. package/dist/src/chains/starknet/services/address/index.d.ts +1 -1
  9. package/dist/src/errors/account.d.ts +1 -1
  10. package/dist/src/errors/address.d.ts +1 -1
  11. package/dist/src/errors/call.d.ts +1 -1
  12. package/dist/src/errors/network.d.ts +1 -1
  13. package/dist/src/errors/review.d.ts +1 -1
  14. package/dist/src/errors/swap.d.ts +1 -1
  15. package/dist/src/features/simulation/activity/schema.cjs +1 -1
  16. package/dist/src/features/simulation/activity/schema.d.ts +346 -334
  17. package/dist/src/features/simulation/activity/schema.js +17 -26
  18. package/dist/src/features/simulation/activity/utils/createNativeActivity.cjs +1 -1
  19. package/dist/src/features/simulation/activity/utils/createNativeActivity.js +23 -23
  20. package/dist/src/features/simulation/transactionReview/getErrorMessageAndLabelFromSimulation.cjs +1 -1
  21. package/dist/src/features/simulation/transactionReview/getErrorMessageAndLabelFromSimulation.js +10 -9
  22. package/dist/src/features/simulation/transactionReview/schema.cjs +1 -1
  23. package/dist/src/features/simulation/transactionReview/schema.d.ts +12 -12
  24. package/dist/src/features/simulation/transactionReview/schema.js +2 -2
  25. package/dist/src/features/swap/services/index.d.ts +1 -1
  26. package/dist/src/http/index.d.ts +2 -2
  27. package/dist/src/knownDapps/index.d.ts +1 -1
  28. package/dist/src/nameResolution/index.d.ts +1 -1
  29. package/dist/src/nfts/index.d.ts +1 -1
  30. package/dist/src/onchainRecovery/index.d.ts +1 -1
  31. package/dist/src/staking/schema.cjs +1 -1
  32. package/dist/src/staking/schema.d.ts +88 -505
  33. package/dist/src/staking/schema.js +27 -19
  34. package/dist/src/tokens/index.d.ts +1 -1
  35. package/dist/src/tokens/service/implementation.d.ts +16 -10
  36. package/dist/src/tokens/service/index.d.ts +1 -1
  37. package/dist/src/tokens/service/tokenError.d.ts +1 -1
  38. package/dist/src/tokens/service/types/backend.model.cjs +1 -1
  39. package/dist/src/tokens/service/types/backend.model.d.ts +640 -400
  40. package/dist/src/tokens/service/types/backend.model.js +116 -114
  41. package/dist/src/transactions/estimate/error.d.ts +1 -1
  42. package/dist/src/transactions/estimate/utils.cjs +1 -1
  43. package/dist/src/transactions/estimate/utils.js +30 -27
  44. package/dist/src/transactions/index.d.ts +5 -5
  45. package/dist/src/transactions/service/implementation.cjs +1 -1
  46. package/dist/src/transactions/service/implementation.js +66 -65
  47. package/dist/src/transactions/service/index.d.ts +1 -1
  48. package/package.json +1 -1
@@ -2,11 +2,11 @@ import { TransactionType as u } from "starknet";
2
2
  import g from "url-join";
3
3
  import { ReviewError as d } from "../../errors/review.js";
4
4
  import { getTxVersionFromFeeToken as E } from "../getTransactionVersion.js";
5
- import { getPayloadFromTransaction as F, getEstimatedFeeFromSimulationAndRespectWatermarkFee as I } from "../estimate/utils.js";
6
- import { urlWithQuery as C } from "../../utils/url/urlWithQuery.js";
7
- import { simulateAndReviewSchema as O, isTransactionSimulationError as S } from "../../features/simulation/transactionReview/schema.js";
8
- import { ensureArray as N } from "../../utils/arrays.js";
9
- class B {
5
+ import { getPayloadFromTransaction as I, getEstimatedFeeFromSimulationAndRespectWatermarkFee as C } from "../estimate/utils.js";
6
+ import { urlWithQuery as O } from "../../utils/url/urlWithQuery.js";
7
+ import { simulateAndReviewSchema as S, isTransactionSimulationError as N } from "../../features/simulation/transactionReview/schema.js";
8
+ import { ensureArray as v } from "../../utils/arrays.js";
9
+ class x {
10
10
  constructor(a, e) {
11
11
  this.apiBase = a, this.httpService = e;
12
12
  }
@@ -26,99 +26,100 @@ class B {
26
26
  const a = g(this.apiBase, "reviewer", "warnings/reasons");
27
27
  return await this.httpService.get(a);
28
28
  }
29
- async simulateAndReview(a, e, c, o, m, t) {
30
- const r = e.some((i) => i.type === "DEPLOY_ACCOUNT");
29
+ async simulateAndReview(a, e, o, n, c, s) {
30
+ var m;
31
+ const r = e.some((t) => t.type === "DEPLOY_ACCOUNT");
31
32
  try {
32
33
  if (!("getChainId" in a))
33
34
  throw new Error("MISSING_METHOD");
34
- const i = E(c), s = r ? "0x0" : await a.getNonce(), n = await a.getChainId(), l = {
35
+ const t = E(o), i = r ? "0x0" : await a.getNonce(), l = await a.getChainId(), w = {
35
36
  transactions: e.map((h) => ({
36
- ...F({
37
+ ...I({
37
38
  transaction: h,
38
- nonce: s,
39
- version: i,
40
- chainId: n,
39
+ nonce: i,
40
+ version: t,
41
+ chainId: l,
41
42
  isDeploymentTransaction: r,
42
- appDomain: o,
43
+ appDomain: n,
43
44
  cairoVersion: a.cairoVersion,
44
45
  address: a.address
45
46
  }),
46
47
  type: h.type
47
48
  }))
48
- }, _ = g(this.apiBase, "reviewer", "transactions", "v2", "review", "starknet"), w = t ? C(_, { delayedTransactions: "true" }) : _, p = await this.httpService.post(w, {
49
+ }, _ = g(this.apiBase, "reviewer", "transactions", "v2", "review", "starknet"), y = s ? O(_, { delayedTransactions: "true" }) : _, p = await this.httpService.post(y, {
49
50
  headers: {
50
51
  Accept: "application/json",
51
52
  "Content-Type": "application/json"
52
53
  },
53
- body: JSON.stringify(l)
54
- }, O);
55
- if (p.transactions.some((h) => S(h)))
54
+ body: JSON.stringify(w)
55
+ }, S);
56
+ if ((m = p.transactions) == null ? void 0 : m.some((h) => N(h)))
56
57
  return p;
57
- const y = I(p, c);
58
+ const F = C(p, o);
58
59
  return {
59
60
  ...p,
60
- enrichedFeeEstimation: y
61
+ enrichedFeeEstimation: F
61
62
  };
62
- } catch (i) {
63
- return console.error(i), this.fallbackToOnchainFeeEstimation({
63
+ } catch (t) {
64
+ return console.error(t), this.fallbackToOnchainFeeEstimation({
64
65
  transactions: e,
65
66
  account: a,
66
67
  isDeploymentTransaction: r,
67
- feeTokenAddress: c,
68
- accountDeployTransaction: m
68
+ feeTokenAddress: o,
69
+ accountDeployTransaction: c
69
70
  });
70
71
  }
71
72
  }
72
73
  getCallsFromTx(a) {
73
74
  let e;
74
- return a.calls && (e = N(a.calls)), e;
75
+ return a.calls && (e = v(a.calls)), e;
75
76
  }
76
- async fallbackToOnchainFeeEstimation({ transactions: a, account: e, isDeploymentTransaction: c, feeTokenAddress: o, accountDeployTransaction: m }) {
77
+ async fallbackToOnchainFeeEstimation({ transactions: a, account: e, isDeploymentTransaction: o, feeTokenAddress: n, accountDeployTransaction: c }) {
77
78
  try {
78
- const t = c ? this.getCallsFromTx(a[1]) : this.getCallsFromTx(a[0]);
79
- if (!t)
79
+ const s = o ? this.getCallsFromTx(a[1]) : this.getCallsFromTx(a[0]);
80
+ if (!s)
80
81
  throw new d({
81
82
  code: "NO_CALLS_FOUND"
82
83
  });
83
84
  const r = await this.fetchFeesOnchain({
84
85
  starknetAccount: e,
85
- calls: t,
86
- isDeployed: !c,
87
- feeTokenAddress: o,
88
- accountDeployTransaction: m
86
+ calls: s,
87
+ isDeployed: !o,
88
+ feeTokenAddress: n,
89
+ accountDeployTransaction: c
89
90
  });
90
91
  return {
91
92
  transactions: [],
92
93
  enrichedFeeEstimation: r,
93
94
  isBackendDown: !0
94
95
  };
95
- } catch (t) {
96
- throw console.error(t), new d({
97
- message: `${t}`,
96
+ } catch (s) {
97
+ throw console.error(s), new d({
98
+ message: `${s}`,
98
99
  code: "SIMULATE_AND_REVIEW_FAILED"
99
100
  });
100
101
  }
101
102
  }
102
- async fetchFeesOnchain({ starknetAccount: a, calls: e, isDeployed: c, feeTokenAddress: o, accountDeployTransaction: m }) {
103
+ async fetchFeesOnchain({ starknetAccount: a, calls: e, isDeployed: o, feeTokenAddress: n, accountDeployTransaction: c }) {
103
104
  try {
104
- const t = E(o), r = {
105
+ const s = E(n), r = {
105
106
  transactions: {
106
- feeTokenAddress: o,
107
+ feeTokenAddress: n,
107
108
  amount: 0n,
108
109
  pricePerUnit: 0n,
109
110
  dataGasConsumed: 0n,
110
111
  dataGasPrice: 0n
111
112
  }
112
113
  };
113
- if (!c && m) {
114
+ if (!o && c) {
114
115
  if ("estimateFeeBulk" in a) {
115
- const i = [
116
+ const m = [
116
117
  {
117
118
  type: u.DEPLOY_ACCOUNT,
118
119
  payload: {
119
- classHash: m.classHash,
120
- addressSalt: m.salt,
121
- constructorCalldata: m.calldata,
120
+ classHash: c.classHash,
121
+ addressSalt: c.salt,
122
+ constructorCalldata: c.calldata,
122
123
  contractAddress: a.address
123
124
  }
124
125
  },
@@ -126,57 +127,57 @@ class B {
126
127
  type: u.INVOKE,
127
128
  payload: e
128
129
  }
129
- ], [s, n] = await a.estimateFeeBulk(i, {
130
- version: t
130
+ ], [t, i] = await a.estimateFeeBulk(m, {
131
+ version: s
131
132
  }).catch((l) => {
132
133
  throw console.error(l), l;
133
134
  });
134
- if (!s.gas_consumed || !s.gas_price || !n.gas_consumed || !n.gas_price)
135
+ if (!t.gas_consumed || !t.gas_price || !i.gas_consumed || !i.gas_price)
135
136
  throw new d({
136
137
  code: "ONCHAIN_FEE_ESTIMATION_FAILED",
137
138
  message: "Missing gas_consumed or gas_price"
138
139
  });
139
140
  r.deployment = {
140
- feeTokenAddress: o,
141
- amount: s.gas_consumed,
142
- pricePerUnit: s.gas_price,
143
- dataGasConsumed: s.data_gas_consumed,
144
- dataGasPrice: s.data_gas_price
141
+ feeTokenAddress: n,
142
+ amount: t.gas_consumed,
143
+ pricePerUnit: t.gas_price,
144
+ dataGasConsumed: t.data_gas_consumed,
145
+ dataGasPrice: t.data_gas_price
145
146
  }, r.transactions = {
146
- feeTokenAddress: o,
147
- amount: n.gas_consumed,
148
- pricePerUnit: n.gas_price,
149
- dataGasConsumed: n.data_gas_consumed,
150
- dataGasPrice: n.data_gas_price
147
+ feeTokenAddress: n,
148
+ amount: i.gas_consumed,
149
+ pricePerUnit: i.gas_price,
150
+ dataGasConsumed: i.data_gas_consumed,
151
+ dataGasPrice: i.data_gas_price
151
152
  };
152
153
  }
153
154
  } else {
154
- const { gas_consumed: i, gas_price: s, data_gas_consumed: n, data_gas_price: l } = await a.estimateFee(e, {
155
+ const { gas_consumed: m, gas_price: t, data_gas_consumed: i, data_gas_price: l } = await a.estimateFee(e, {
155
156
  skipValidate: !0,
156
- version: t
157
+ version: s
157
158
  });
158
- if (!i || !s)
159
+ if (!m || !t)
159
160
  throw new d({
160
161
  code: "ONCHAIN_FEE_ESTIMATION_FAILED",
161
162
  message: "Missing gas_consumed or gas_price"
162
163
  });
163
164
  r.transactions = {
164
- feeTokenAddress: o,
165
- amount: i,
166
- pricePerUnit: s,
167
- dataGasConsumed: n,
165
+ feeTokenAddress: n,
166
+ amount: m,
167
+ pricePerUnit: t,
168
+ dataGasConsumed: i,
168
169
  dataGasPrice: l
169
170
  };
170
171
  }
171
172
  return r;
172
- } catch (t) {
173
+ } catch (s) {
173
174
  throw new d({
174
175
  code: "ONCHAIN_FEE_ESTIMATION_FAILED",
175
- message: `${t}`
176
+ message: `${s}`
176
177
  });
177
178
  }
178
179
  }
179
180
  }
180
181
  export {
181
- B as TransactionReviewServiceWeb
182
+ x as TransactionReviewServiceWeb
182
183
  };
@@ -1,3 +1,3 @@
1
1
  export * from './implementation';
2
- export * from './interface';
2
+ export type * from './interface';
3
3
  export * from './types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@argent/x-shared",
3
- "version": "1.42.1",
3
+ "version": "1.43.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/argentlabs/x-shared.git"