@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.
- package/README.md +1 -1
- package/dist/.eslintrc.d.cts +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +297 -295
- package/dist/src/backend/index.d.ts +1 -1
- package/dist/src/bigdecimal/index.d.ts +1 -1
- package/dist/src/cache/index.d.ts +1 -1
- package/dist/src/chains/starknet/services/address/index.d.ts +1 -1
- package/dist/src/errors/account.d.ts +1 -1
- package/dist/src/errors/address.d.ts +1 -1
- package/dist/src/errors/call.d.ts +1 -1
- package/dist/src/errors/network.d.ts +1 -1
- package/dist/src/errors/review.d.ts +1 -1
- package/dist/src/errors/swap.d.ts +1 -1
- package/dist/src/features/simulation/activity/schema.cjs +1 -1
- package/dist/src/features/simulation/activity/schema.d.ts +346 -334
- package/dist/src/features/simulation/activity/schema.js +17 -26
- package/dist/src/features/simulation/activity/utils/createNativeActivity.cjs +1 -1
- package/dist/src/features/simulation/activity/utils/createNativeActivity.js +23 -23
- package/dist/src/features/simulation/transactionReview/getErrorMessageAndLabelFromSimulation.cjs +1 -1
- package/dist/src/features/simulation/transactionReview/getErrorMessageAndLabelFromSimulation.js +10 -9
- package/dist/src/features/simulation/transactionReview/schema.cjs +1 -1
- package/dist/src/features/simulation/transactionReview/schema.d.ts +12 -12
- package/dist/src/features/simulation/transactionReview/schema.js +2 -2
- package/dist/src/features/swap/services/index.d.ts +1 -1
- package/dist/src/http/index.d.ts +2 -2
- package/dist/src/knownDapps/index.d.ts +1 -1
- package/dist/src/nameResolution/index.d.ts +1 -1
- package/dist/src/nfts/index.d.ts +1 -1
- package/dist/src/onchainRecovery/index.d.ts +1 -1
- package/dist/src/staking/schema.cjs +1 -1
- package/dist/src/staking/schema.d.ts +88 -505
- package/dist/src/staking/schema.js +27 -19
- package/dist/src/tokens/index.d.ts +1 -1
- package/dist/src/tokens/service/implementation.d.ts +16 -10
- package/dist/src/tokens/service/index.d.ts +1 -1
- package/dist/src/tokens/service/tokenError.d.ts +1 -1
- package/dist/src/tokens/service/types/backend.model.cjs +1 -1
- package/dist/src/tokens/service/types/backend.model.d.ts +640 -400
- package/dist/src/tokens/service/types/backend.model.js +116 -114
- package/dist/src/transactions/estimate/error.d.ts +1 -1
- package/dist/src/transactions/estimate/utils.cjs +1 -1
- package/dist/src/transactions/estimate/utils.js +30 -27
- package/dist/src/transactions/index.d.ts +5 -5
- package/dist/src/transactions/service/implementation.cjs +1 -1
- package/dist/src/transactions/service/implementation.js +66 -65
- package/dist/src/transactions/service/index.d.ts +1 -1
- 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
|
|
6
|
-
import { urlWithQuery as
|
|
7
|
-
import { simulateAndReviewSchema as
|
|
8
|
-
import { ensureArray as
|
|
9
|
-
class
|
|
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,
|
|
30
|
-
|
|
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
|
|
35
|
+
const t = E(o), i = r ? "0x0" : await a.getNonce(), l = await a.getChainId(), w = {
|
|
35
36
|
transactions: e.map((h) => ({
|
|
36
|
-
...
|
|
37
|
+
...I({
|
|
37
38
|
transaction: h,
|
|
38
|
-
nonce:
|
|
39
|
-
version:
|
|
40
|
-
chainId:
|
|
39
|
+
nonce: i,
|
|
40
|
+
version: t,
|
|
41
|
+
chainId: l,
|
|
41
42
|
isDeploymentTransaction: r,
|
|
42
|
-
appDomain:
|
|
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"),
|
|
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(
|
|
54
|
-
},
|
|
55
|
-
if (p.transactions.some((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
|
|
58
|
+
const F = C(p, o);
|
|
58
59
|
return {
|
|
59
60
|
...p,
|
|
60
|
-
enrichedFeeEstimation:
|
|
61
|
+
enrichedFeeEstimation: F
|
|
61
62
|
};
|
|
62
|
-
} catch (
|
|
63
|
-
return console.error(
|
|
63
|
+
} catch (t) {
|
|
64
|
+
return console.error(t), this.fallbackToOnchainFeeEstimation({
|
|
64
65
|
transactions: e,
|
|
65
66
|
account: a,
|
|
66
67
|
isDeploymentTransaction: r,
|
|
67
|
-
feeTokenAddress:
|
|
68
|
-
accountDeployTransaction:
|
|
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 =
|
|
75
|
+
return a.calls && (e = v(a.calls)), e;
|
|
75
76
|
}
|
|
76
|
-
async fallbackToOnchainFeeEstimation({ transactions: a, account: e, isDeploymentTransaction:
|
|
77
|
+
async fallbackToOnchainFeeEstimation({ transactions: a, account: e, isDeploymentTransaction: o, feeTokenAddress: n, accountDeployTransaction: c }) {
|
|
77
78
|
try {
|
|
78
|
-
const
|
|
79
|
-
if (!
|
|
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:
|
|
86
|
-
isDeployed: !
|
|
87
|
-
feeTokenAddress:
|
|
88
|
-
accountDeployTransaction:
|
|
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 (
|
|
96
|
-
throw console.error(
|
|
97
|
-
message: `${
|
|
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:
|
|
103
|
+
async fetchFeesOnchain({ starknetAccount: a, calls: e, isDeployed: o, feeTokenAddress: n, accountDeployTransaction: c }) {
|
|
103
104
|
try {
|
|
104
|
-
const
|
|
105
|
+
const s = E(n), r = {
|
|
105
106
|
transactions: {
|
|
106
|
-
feeTokenAddress:
|
|
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 (!
|
|
114
|
+
if (!o && c) {
|
|
114
115
|
if ("estimateFeeBulk" in a) {
|
|
115
|
-
const
|
|
116
|
+
const m = [
|
|
116
117
|
{
|
|
117
118
|
type: u.DEPLOY_ACCOUNT,
|
|
118
119
|
payload: {
|
|
119
|
-
classHash:
|
|
120
|
-
addressSalt:
|
|
121
|
-
constructorCalldata:
|
|
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
|
-
], [
|
|
130
|
-
version:
|
|
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 (!
|
|
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:
|
|
141
|
-
amount:
|
|
142
|
-
pricePerUnit:
|
|
143
|
-
dataGasConsumed:
|
|
144
|
-
dataGasPrice:
|
|
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:
|
|
147
|
-
amount:
|
|
148
|
-
pricePerUnit:
|
|
149
|
-
dataGasConsumed:
|
|
150
|
-
dataGasPrice:
|
|
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:
|
|
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:
|
|
157
|
+
version: s
|
|
157
158
|
});
|
|
158
|
-
if (!
|
|
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:
|
|
165
|
-
amount:
|
|
166
|
-
pricePerUnit:
|
|
167
|
-
dataGasConsumed:
|
|
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 (
|
|
173
|
+
} catch (s) {
|
|
173
174
|
throw new d({
|
|
174
175
|
code: "ONCHAIN_FEE_ESTIMATION_FAILED",
|
|
175
|
-
message: `${
|
|
176
|
+
message: `${s}`
|
|
176
177
|
});
|
|
177
178
|
}
|
|
178
179
|
}
|
|
179
180
|
}
|
|
180
181
|
export {
|
|
181
|
-
|
|
182
|
+
x as TransactionReviewServiceWeb
|
|
182
183
|
};
|