starknet 6.7.0 → 6.9.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 +30 -0
- package/README.md +2 -0
- package/dist/index.d.ts +1064 -1420
- package/dist/index.global.js +1335 -964
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +529 -518
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +512 -489
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -4
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
2
5
|
var __export = (target, all) => {
|
|
3
6
|
for (var name in all)
|
|
4
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
8
|
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
6
18
|
|
|
7
19
|
// src/constants.ts
|
|
8
20
|
var constants_exports = {};
|
|
@@ -22,7 +34,7 @@ __export(constants_exports, {
|
|
|
22
34
|
RPC_NODES: () => RPC_NODES,
|
|
23
35
|
StarknetChainId: () => StarknetChainId,
|
|
24
36
|
TEXT_TO_FELT_MAX_LEN: () => TEXT_TO_FELT_MAX_LEN,
|
|
25
|
-
TRANSACTION_VERSION: () =>
|
|
37
|
+
TRANSACTION_VERSION: () => api_exports.ETransactionVersion,
|
|
26
38
|
TransactionHashPrefix: () => TransactionHashPrefix,
|
|
27
39
|
UDC: () => UDC,
|
|
28
40
|
ZERO: () => ZERO,
|
|
@@ -32,22 +44,9 @@ __export(constants_exports, {
|
|
|
32
44
|
// src/types/api/index.ts
|
|
33
45
|
var api_exports = {};
|
|
34
46
|
__export(api_exports, {
|
|
35
|
-
EBlockTag: () => EBlockTag2,
|
|
36
|
-
EDAMode: () => EDAMode2,
|
|
37
|
-
EDataAvailabilityMode: () => EDataAvailabilityMode2,
|
|
38
|
-
ESimulationFlag: () => ESimulationFlag2,
|
|
39
|
-
ETransactionExecutionStatus: () => ETransactionExecutionStatus2,
|
|
40
|
-
ETransactionFinalityStatus: () => ETransactionFinalityStatus2,
|
|
41
|
-
ETransactionStatus: () => ETransactionStatus2,
|
|
42
|
-
ETransactionType: () => ETransactionType2,
|
|
43
|
-
ETransactionVersion: () => ETransactionVersion4,
|
|
44
|
-
ETransactionVersion2: () => ETransactionVersion22,
|
|
45
|
-
ETransactionVersion3: () => ETransactionVersion32,
|
|
46
|
-
Errors: () => errors_exports2,
|
|
47
47
|
JRPC: () => jsonrpc_exports,
|
|
48
48
|
RPCSPEC06: () => rpcspec_0_6_exports,
|
|
49
|
-
RPCSPEC07: () =>
|
|
50
|
-
SPEC: () => components_exports2
|
|
49
|
+
RPCSPEC07: () => RPCSPEC07
|
|
51
50
|
});
|
|
52
51
|
|
|
53
52
|
// src/types/api/jsonrpc/index.ts
|
|
@@ -78,40 +77,40 @@ var errors_exports = {};
|
|
|
78
77
|
var components_exports = {};
|
|
79
78
|
|
|
80
79
|
// src/types/api/rpcspec_0_6/nonspec.ts
|
|
81
|
-
var ETransactionType = /* @__PURE__ */ ((
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return
|
|
80
|
+
var ETransactionType = /* @__PURE__ */ ((ETransactionType2) => {
|
|
81
|
+
ETransactionType2["DECLARE"] = "DECLARE";
|
|
82
|
+
ETransactionType2["DEPLOY"] = "DEPLOY";
|
|
83
|
+
ETransactionType2["DEPLOY_ACCOUNT"] = "DEPLOY_ACCOUNT";
|
|
84
|
+
ETransactionType2["INVOKE"] = "INVOKE";
|
|
85
|
+
ETransactionType2["L1_HANDLER"] = "L1_HANDLER";
|
|
86
|
+
return ETransactionType2;
|
|
88
87
|
})(ETransactionType || {});
|
|
89
|
-
var ESimulationFlag = /* @__PURE__ */ ((
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return
|
|
88
|
+
var ESimulationFlag = /* @__PURE__ */ ((ESimulationFlag2) => {
|
|
89
|
+
ESimulationFlag2["SKIP_VALIDATE"] = "SKIP_VALIDATE";
|
|
90
|
+
ESimulationFlag2["SKIP_FEE_CHARGE"] = "SKIP_FEE_CHARGE";
|
|
91
|
+
return ESimulationFlag2;
|
|
93
92
|
})(ESimulationFlag || {});
|
|
94
|
-
var ETransactionStatus = /* @__PURE__ */ ((
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return
|
|
93
|
+
var ETransactionStatus = /* @__PURE__ */ ((ETransactionStatus2) => {
|
|
94
|
+
ETransactionStatus2["RECEIVED"] = "RECEIVED";
|
|
95
|
+
ETransactionStatus2["REJECTED"] = "REJECTED";
|
|
96
|
+
ETransactionStatus2["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
97
|
+
ETransactionStatus2["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
98
|
+
return ETransactionStatus2;
|
|
100
99
|
})(ETransactionStatus || {});
|
|
101
|
-
var ETransactionFinalityStatus = /* @__PURE__ */ ((
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return
|
|
100
|
+
var ETransactionFinalityStatus = /* @__PURE__ */ ((ETransactionFinalityStatus2) => {
|
|
101
|
+
ETransactionFinalityStatus2["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
102
|
+
ETransactionFinalityStatus2["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
103
|
+
return ETransactionFinalityStatus2;
|
|
105
104
|
})(ETransactionFinalityStatus || {});
|
|
106
|
-
var ETransactionExecutionStatus = /* @__PURE__ */ ((
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return
|
|
105
|
+
var ETransactionExecutionStatus = /* @__PURE__ */ ((ETransactionExecutionStatus2) => {
|
|
106
|
+
ETransactionExecutionStatus2["SUCCEEDED"] = "SUCCEEDED";
|
|
107
|
+
ETransactionExecutionStatus2["REVERTED"] = "REVERTED";
|
|
108
|
+
return ETransactionExecutionStatus2;
|
|
110
109
|
})(ETransactionExecutionStatus || {});
|
|
111
|
-
var EBlockTag = /* @__PURE__ */ ((
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return
|
|
110
|
+
var EBlockTag = /* @__PURE__ */ ((EBlockTag2) => {
|
|
111
|
+
EBlockTag2["LATEST"] = "latest";
|
|
112
|
+
EBlockTag2["PENDING"] = "pending";
|
|
113
|
+
return EBlockTag2;
|
|
115
114
|
})(EBlockTag || {});
|
|
116
115
|
var EDataAvailabilityMode = /* @__PURE__ */ ((EDataAvailabilityMode3) => {
|
|
117
116
|
EDataAvailabilityMode3["L1"] = "L1";
|
|
@@ -123,127 +122,36 @@ var EDAMode = /* @__PURE__ */ ((EDAMode4) => {
|
|
|
123
122
|
EDAMode4[EDAMode4["L2"] = 1] = "L2";
|
|
124
123
|
return EDAMode4;
|
|
125
124
|
})(EDAMode || {});
|
|
126
|
-
var ETransactionVersion = /* @__PURE__ */ ((
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return
|
|
125
|
+
var ETransactionVersion = /* @__PURE__ */ ((ETransactionVersion10) => {
|
|
126
|
+
ETransactionVersion10["V0"] = "0x0";
|
|
127
|
+
ETransactionVersion10["V1"] = "0x1";
|
|
128
|
+
ETransactionVersion10["V2"] = "0x2";
|
|
129
|
+
ETransactionVersion10["V3"] = "0x3";
|
|
130
|
+
ETransactionVersion10["F0"] = "0x100000000000000000000000000000000";
|
|
131
|
+
ETransactionVersion10["F1"] = "0x100000000000000000000000000000001";
|
|
132
|
+
ETransactionVersion10["F2"] = "0x100000000000000000000000000000002";
|
|
133
|
+
ETransactionVersion10["F3"] = "0x100000000000000000000000000000003";
|
|
134
|
+
return ETransactionVersion10;
|
|
136
135
|
})(ETransactionVersion || {});
|
|
137
|
-
var ETransactionVersion2 = /* @__PURE__ */ ((
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return
|
|
136
|
+
var ETransactionVersion2 = /* @__PURE__ */ ((ETransactionVersion25) => {
|
|
137
|
+
ETransactionVersion25["V0"] = "0x0";
|
|
138
|
+
ETransactionVersion25["V1"] = "0x1";
|
|
139
|
+
ETransactionVersion25["V2"] = "0x2";
|
|
140
|
+
ETransactionVersion25["F0"] = "0x100000000000000000000000000000000";
|
|
141
|
+
ETransactionVersion25["F1"] = "0x100000000000000000000000000000001";
|
|
142
|
+
ETransactionVersion25["F2"] = "0x100000000000000000000000000000002";
|
|
143
|
+
return ETransactionVersion25;
|
|
145
144
|
})(ETransactionVersion2 || {});
|
|
146
|
-
var ETransactionVersion3 = /* @__PURE__ */ ((
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
return
|
|
145
|
+
var ETransactionVersion3 = /* @__PURE__ */ ((ETransactionVersion36) => {
|
|
146
|
+
ETransactionVersion36["V3"] = "0x3";
|
|
147
|
+
ETransactionVersion36["F3"] = "0x100000000000000000000000000000003";
|
|
148
|
+
return ETransactionVersion36;
|
|
150
149
|
})(ETransactionVersion3 || {});
|
|
151
150
|
|
|
152
|
-
// src/types/api/
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
EDAMode: () => EDAMode2,
|
|
157
|
-
EDataAvailabilityMode: () => EDataAvailabilityMode2,
|
|
158
|
-
ESimulationFlag: () => ESimulationFlag2,
|
|
159
|
-
ETransactionExecutionStatus: () => ETransactionExecutionStatus2,
|
|
160
|
-
ETransactionFinalityStatus: () => ETransactionFinalityStatus2,
|
|
161
|
-
ETransactionStatus: () => ETransactionStatus2,
|
|
162
|
-
ETransactionType: () => ETransactionType2,
|
|
163
|
-
ETransactionVersion: () => ETransactionVersion4,
|
|
164
|
-
ETransactionVersion2: () => ETransactionVersion22,
|
|
165
|
-
ETransactionVersion3: () => ETransactionVersion32,
|
|
166
|
-
Errors: () => errors_exports2,
|
|
167
|
-
SPEC: () => components_exports2
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
// src/types/api/rpcspec_0_7/errors.ts
|
|
171
|
-
var errors_exports2 = {};
|
|
172
|
-
|
|
173
|
-
// src/types/api/rpcspec_0_7/components.ts
|
|
174
|
-
var components_exports2 = {};
|
|
175
|
-
|
|
176
|
-
// src/types/api/rpcspec_0_7/nonspec.ts
|
|
177
|
-
var ETransactionType2 = /* @__PURE__ */ ((ETransactionType3) => {
|
|
178
|
-
ETransactionType3["DECLARE"] = "DECLARE";
|
|
179
|
-
ETransactionType3["DEPLOY"] = "DEPLOY";
|
|
180
|
-
ETransactionType3["DEPLOY_ACCOUNT"] = "DEPLOY_ACCOUNT";
|
|
181
|
-
ETransactionType3["INVOKE"] = "INVOKE";
|
|
182
|
-
ETransactionType3["L1_HANDLER"] = "L1_HANDLER";
|
|
183
|
-
return ETransactionType3;
|
|
184
|
-
})(ETransactionType2 || {});
|
|
185
|
-
var ESimulationFlag2 = /* @__PURE__ */ ((ESimulationFlag3) => {
|
|
186
|
-
ESimulationFlag3["SKIP_VALIDATE"] = "SKIP_VALIDATE";
|
|
187
|
-
ESimulationFlag3["SKIP_FEE_CHARGE"] = "SKIP_FEE_CHARGE";
|
|
188
|
-
return ESimulationFlag3;
|
|
189
|
-
})(ESimulationFlag2 || {});
|
|
190
|
-
var ETransactionStatus2 = /* @__PURE__ */ ((ETransactionStatus3) => {
|
|
191
|
-
ETransactionStatus3["RECEIVED"] = "RECEIVED";
|
|
192
|
-
ETransactionStatus3["REJECTED"] = "REJECTED";
|
|
193
|
-
ETransactionStatus3["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
194
|
-
ETransactionStatus3["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
195
|
-
return ETransactionStatus3;
|
|
196
|
-
})(ETransactionStatus2 || {});
|
|
197
|
-
var ETransactionFinalityStatus2 = /* @__PURE__ */ ((ETransactionFinalityStatus3) => {
|
|
198
|
-
ETransactionFinalityStatus3["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
199
|
-
ETransactionFinalityStatus3["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
200
|
-
return ETransactionFinalityStatus3;
|
|
201
|
-
})(ETransactionFinalityStatus2 || {});
|
|
202
|
-
var ETransactionExecutionStatus2 = /* @__PURE__ */ ((ETransactionExecutionStatus3) => {
|
|
203
|
-
ETransactionExecutionStatus3["SUCCEEDED"] = "SUCCEEDED";
|
|
204
|
-
ETransactionExecutionStatus3["REVERTED"] = "REVERTED";
|
|
205
|
-
return ETransactionExecutionStatus3;
|
|
206
|
-
})(ETransactionExecutionStatus2 || {});
|
|
207
|
-
var EBlockTag2 = /* @__PURE__ */ ((EBlockTag3) => {
|
|
208
|
-
EBlockTag3["LATEST"] = "latest";
|
|
209
|
-
EBlockTag3["PENDING"] = "pending";
|
|
210
|
-
return EBlockTag3;
|
|
211
|
-
})(EBlockTag2 || {});
|
|
212
|
-
var EDataAvailabilityMode2 = /* @__PURE__ */ ((EDataAvailabilityMode3) => {
|
|
213
|
-
EDataAvailabilityMode3["L1"] = "L1";
|
|
214
|
-
EDataAvailabilityMode3["L2"] = "L2";
|
|
215
|
-
return EDataAvailabilityMode3;
|
|
216
|
-
})(EDataAvailabilityMode2 || {});
|
|
217
|
-
var EDAMode2 = /* @__PURE__ */ ((EDAMode4) => {
|
|
218
|
-
EDAMode4[EDAMode4["L1"] = 0] = "L1";
|
|
219
|
-
EDAMode4[EDAMode4["L2"] = 1] = "L2";
|
|
220
|
-
return EDAMode4;
|
|
221
|
-
})(EDAMode2 || {});
|
|
222
|
-
var ETransactionVersion4 = /* @__PURE__ */ ((ETransactionVersion5) => {
|
|
223
|
-
ETransactionVersion5["V0"] = "0x0";
|
|
224
|
-
ETransactionVersion5["V1"] = "0x1";
|
|
225
|
-
ETransactionVersion5["V2"] = "0x2";
|
|
226
|
-
ETransactionVersion5["V3"] = "0x3";
|
|
227
|
-
ETransactionVersion5["F0"] = "0x100000000000000000000000000000000";
|
|
228
|
-
ETransactionVersion5["F1"] = "0x100000000000000000000000000000001";
|
|
229
|
-
ETransactionVersion5["F2"] = "0x100000000000000000000000000000002";
|
|
230
|
-
ETransactionVersion5["F3"] = "0x100000000000000000000000000000003";
|
|
231
|
-
return ETransactionVersion5;
|
|
232
|
-
})(ETransactionVersion4 || {});
|
|
233
|
-
var ETransactionVersion22 = /* @__PURE__ */ ((ETransactionVersion24) => {
|
|
234
|
-
ETransactionVersion24["V0"] = "0x0";
|
|
235
|
-
ETransactionVersion24["V1"] = "0x1";
|
|
236
|
-
ETransactionVersion24["V2"] = "0x2";
|
|
237
|
-
ETransactionVersion24["F0"] = "0x100000000000000000000000000000000";
|
|
238
|
-
ETransactionVersion24["F1"] = "0x100000000000000000000000000000001";
|
|
239
|
-
ETransactionVersion24["F2"] = "0x100000000000000000000000000000002";
|
|
240
|
-
return ETransactionVersion24;
|
|
241
|
-
})(ETransactionVersion22 || {});
|
|
242
|
-
var ETransactionVersion32 = /* @__PURE__ */ ((ETransactionVersion34) => {
|
|
243
|
-
ETransactionVersion34["V3"] = "0x3";
|
|
244
|
-
ETransactionVersion34["F3"] = "0x100000000000000000000000000000003";
|
|
245
|
-
return ETransactionVersion34;
|
|
246
|
-
})(ETransactionVersion32 || {});
|
|
151
|
+
// src/types/api/index.ts
|
|
152
|
+
__reExport(api_exports, starknet_types_07_star);
|
|
153
|
+
import * as RPCSPEC07 from "starknet-types-07";
|
|
154
|
+
import * as starknet_types_07_star from "starknet-types-07";
|
|
247
155
|
|
|
248
156
|
// src/utils/encode.ts
|
|
249
157
|
var encode_exports = {};
|
|
@@ -334,19 +242,16 @@ var RANGE_I128 = range(-(2n ** 127n), 2n ** 127n - 1n);
|
|
|
334
242
|
var RANGE_U128 = range(ZERO, 2n ** 128n - 1n);
|
|
335
243
|
var BaseUrl = /* @__PURE__ */ ((BaseUrl2) => {
|
|
336
244
|
BaseUrl2["SN_MAIN"] = "https://alpha-mainnet.starknet.io";
|
|
337
|
-
BaseUrl2["SN_GOERLI"] = "https://alpha4.starknet.io";
|
|
338
245
|
BaseUrl2["SN_SEPOLIA"] = "https://alpha-sepolia.starknet.io";
|
|
339
246
|
return BaseUrl2;
|
|
340
247
|
})(BaseUrl || {});
|
|
341
248
|
var NetworkName = /* @__PURE__ */ ((NetworkName2) => {
|
|
342
249
|
NetworkName2["SN_MAIN"] = "SN_MAIN";
|
|
343
|
-
NetworkName2["SN_GOERLI"] = "SN_GOERLI";
|
|
344
250
|
NetworkName2["SN_SEPOLIA"] = "SN_SEPOLIA";
|
|
345
251
|
return NetworkName2;
|
|
346
252
|
})(NetworkName || {});
|
|
347
253
|
var StarknetChainId = /* @__PURE__ */ ((StarknetChainId6) => {
|
|
348
254
|
StarknetChainId6["SN_MAIN"] = "0x534e5f4d41494e";
|
|
349
|
-
StarknetChainId6["SN_GOERLI"] = "0x534e5f474f45524c49";
|
|
350
255
|
StarknetChainId6["SN_SEPOLIA"] = "0x534e5f5345504f4c4941";
|
|
351
256
|
return StarknetChainId6;
|
|
352
257
|
})(StarknetChainId || {});
|
|
@@ -370,10 +275,6 @@ var UDC = {
|
|
|
370
275
|
};
|
|
371
276
|
var RPC_DEFAULT_VERSION = "v0_7";
|
|
372
277
|
var RPC_NODES = {
|
|
373
|
-
SN_GOERLI: [
|
|
374
|
-
`https://starknet-testnet.public.blastapi.io/rpc/${RPC_DEFAULT_VERSION}`,
|
|
375
|
-
`https://free-rpc.nethermind.io/goerli-juno/${RPC_DEFAULT_VERSION}`
|
|
376
|
-
],
|
|
377
278
|
SN_MAIN: [
|
|
378
279
|
`https://starknet-mainnet.public.blastapi.io/rpc/${RPC_DEFAULT_VERSION}`,
|
|
379
280
|
`https://free-rpc.nethermind.io/mainnet-juno/${RPC_DEFAULT_VERSION}`
|
|
@@ -384,6 +285,16 @@ var RPC_NODES = {
|
|
|
384
285
|
]
|
|
385
286
|
};
|
|
386
287
|
|
|
288
|
+
// src/provider/rpc.ts
|
|
289
|
+
import { bytesToHex } from "@noble/curves/abstract/utils";
|
|
290
|
+
import { keccak_256 } from "@noble/hashes/sha3";
|
|
291
|
+
|
|
292
|
+
// src/channel/rpc_0_6.ts
|
|
293
|
+
var rpc_0_6_exports = {};
|
|
294
|
+
__export(rpc_0_6_exports, {
|
|
295
|
+
RpcChannel: () => RpcChannel
|
|
296
|
+
});
|
|
297
|
+
|
|
387
298
|
// src/provider/errors.ts
|
|
388
299
|
function fixStack(target, fn = target.constructor) {
|
|
389
300
|
const { captureStackTrace } = Error;
|
|
@@ -421,12 +332,6 @@ var HttpError = class extends LibraryError {
|
|
|
421
332
|
}
|
|
422
333
|
};
|
|
423
334
|
|
|
424
|
-
// src/channel/rpc_0_6.ts
|
|
425
|
-
var rpc_0_6_exports = {};
|
|
426
|
-
__export(rpc_0_6_exports, {
|
|
427
|
-
RpcChannel: () => RpcChannel
|
|
428
|
-
});
|
|
429
|
-
|
|
430
335
|
// src/types/index.ts
|
|
431
336
|
var types_exports = {};
|
|
432
337
|
__export(types_exports, {
|
|
@@ -435,7 +340,6 @@ __export(types_exports, {
|
|
|
435
340
|
EntryPointType: () => EntryPointType,
|
|
436
341
|
Literal: () => Literal,
|
|
437
342
|
RPC: () => api_exports,
|
|
438
|
-
SIMULATION_FLAG: () => SIMULATION_FLAG,
|
|
439
343
|
TransactionExecutionStatus: () => TransactionExecutionStatus,
|
|
440
344
|
TransactionFinalityStatus: () => TransactionFinalityStatus,
|
|
441
345
|
TransactionStatus: () => TransactionStatus,
|
|
@@ -445,13 +349,6 @@ __export(types_exports, {
|
|
|
445
349
|
ValidateType: () => ValidateType
|
|
446
350
|
});
|
|
447
351
|
|
|
448
|
-
// src/types/account.ts
|
|
449
|
-
var SIMULATION_FLAG = /* @__PURE__ */ ((SIMULATION_FLAG2) => {
|
|
450
|
-
SIMULATION_FLAG2["SKIP_VALIDATE"] = "SKIP_VALIDATE";
|
|
451
|
-
SIMULATION_FLAG2["SKIP_EXECUTE"] = "SKIP_EXECUTE";
|
|
452
|
-
return SIMULATION_FLAG2;
|
|
453
|
-
})(SIMULATION_FLAG || {});
|
|
454
|
-
|
|
455
352
|
// src/types/calldata.ts
|
|
456
353
|
var ValidateType = /* @__PURE__ */ ((ValidateType2) => {
|
|
457
354
|
ValidateType2["DEPLOY"] = "DEPLOY";
|
|
@@ -530,7 +427,7 @@ var BlockTag = /* @__PURE__ */ ((BlockTag2) => {
|
|
|
530
427
|
// src/types/typedData.ts
|
|
531
428
|
import {
|
|
532
429
|
TypedDataRevision
|
|
533
|
-
} from "starknet-types";
|
|
430
|
+
} from "starknet-types-07";
|
|
534
431
|
|
|
535
432
|
// src/utils/assert.ts
|
|
536
433
|
function assert(condition, message) {
|
|
@@ -1272,46 +1169,49 @@ var guard = {
|
|
|
1272
1169
|
}
|
|
1273
1170
|
};
|
|
1274
1171
|
function formatter(data, type, sameType) {
|
|
1275
|
-
return Object.entries(data).reduce(
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
}
|
|
1281
|
-
if (elType === "string") {
|
|
1282
|
-
if (Array.isArray(data[key])) {
|
|
1283
|
-
const arrayStr = formatter(
|
|
1284
|
-
data[key],
|
|
1285
|
-
data[key].map((_) => elType)
|
|
1286
|
-
);
|
|
1287
|
-
acc[key] = Object.values(arrayStr).join("");
|
|
1172
|
+
return Object.entries(data).reduce(
|
|
1173
|
+
(acc, [key, value]) => {
|
|
1174
|
+
const elType = sameType ?? type[key];
|
|
1175
|
+
if (!(key in type) && !sameType) {
|
|
1176
|
+
acc[key] = value;
|
|
1288
1177
|
return acc;
|
|
1289
1178
|
}
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1179
|
+
if (elType === "string") {
|
|
1180
|
+
if (Array.isArray(data[key])) {
|
|
1181
|
+
const arrayStr = formatter(
|
|
1182
|
+
data[key],
|
|
1183
|
+
data[key].map((_) => elType)
|
|
1184
|
+
);
|
|
1185
|
+
acc[key] = Object.values(arrayStr).join("");
|
|
1186
|
+
return acc;
|
|
1187
|
+
}
|
|
1188
|
+
guard.isBN(data, type, key);
|
|
1189
|
+
acc[key] = decodeShortString(value);
|
|
1190
|
+
return acc;
|
|
1191
|
+
}
|
|
1192
|
+
if (elType === "number") {
|
|
1193
|
+
guard.isBN(data, type, key);
|
|
1194
|
+
acc[key] = Number(value);
|
|
1195
|
+
return acc;
|
|
1196
|
+
}
|
|
1197
|
+
if (typeof elType === "function") {
|
|
1198
|
+
acc[key] = elType(value);
|
|
1199
|
+
return acc;
|
|
1200
|
+
}
|
|
1201
|
+
if (Array.isArray(elType)) {
|
|
1202
|
+
const arrayObj = formatter(data[key], elType, elType[0]);
|
|
1203
|
+
acc[key] = Object.values(arrayObj);
|
|
1204
|
+
return acc;
|
|
1205
|
+
}
|
|
1206
|
+
if (typeof elType === "object") {
|
|
1207
|
+
acc[key] = formatter(data[key], elType);
|
|
1208
|
+
return acc;
|
|
1209
|
+
}
|
|
1210
|
+
guard.unknown(data, type, key);
|
|
1310
1211
|
return acc;
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
}, {});
|
|
1212
|
+
},
|
|
1213
|
+
{}
|
|
1214
|
+
);
|
|
1315
1215
|
}
|
|
1316
1216
|
|
|
1317
1217
|
// src/utils/calldata/parser/parser-0-1.1.0.ts
|
|
@@ -1366,7 +1266,9 @@ var AbiParser2 = class {
|
|
|
1366
1266
|
* @returns FunctionAbi | undefined
|
|
1367
1267
|
*/
|
|
1368
1268
|
getMethod(name) {
|
|
1369
|
-
const intf = this.abi.find(
|
|
1269
|
+
const intf = this.abi.find(
|
|
1270
|
+
(it) => it.type === "interface"
|
|
1271
|
+
);
|
|
1370
1272
|
return intf.items.find((it) => it.name === name);
|
|
1371
1273
|
}
|
|
1372
1274
|
/**
|
|
@@ -2336,7 +2238,7 @@ var CallData = class _CallData {
|
|
|
2336
2238
|
* Compile contract callData with abi
|
|
2337
2239
|
* Parse the calldata by using input fields from the abi for that method
|
|
2338
2240
|
* @param method string - method name
|
|
2339
|
-
* @param
|
|
2241
|
+
* @param argsCalldata RawArgs - arguments passed to the method. Can be an array of arguments (in the order of abi definition), or an object constructed in conformity with abi (in this case, the parameter can be in a wrong order).
|
|
2340
2242
|
* @return Calldata - parsed arguments in format that contract is expecting
|
|
2341
2243
|
* @example
|
|
2342
2244
|
* ```typescript
|
|
@@ -2738,7 +2640,7 @@ function calculateInvokeTransactionHash(senderAddress, version, compiledCalldata
|
|
|
2738
2640
|
|
|
2739
2641
|
// src/utils/hash/transactionHash/index.ts
|
|
2740
2642
|
function isV3InvokeTx(args) {
|
|
2741
|
-
return [
|
|
2643
|
+
return [api_exports.ETransactionVersion.V3, api_exports.ETransactionVersion.F3].includes(
|
|
2742
2644
|
args.version
|
|
2743
2645
|
);
|
|
2744
2646
|
}
|
|
@@ -2768,7 +2670,7 @@ function calculateInvokeTransactionHash2(args) {
|
|
|
2768
2670
|
);
|
|
2769
2671
|
}
|
|
2770
2672
|
function isV3DeclareTx(args) {
|
|
2771
|
-
return [
|
|
2673
|
+
return [api_exports.ETransactionVersion.V3, api_exports.ETransactionVersion.F3].includes(
|
|
2772
2674
|
args.version
|
|
2773
2675
|
);
|
|
2774
2676
|
}
|
|
@@ -2800,7 +2702,7 @@ function calculateDeclareTransactionHash3(args) {
|
|
|
2800
2702
|
);
|
|
2801
2703
|
}
|
|
2802
2704
|
function isV3DeployAccountTx(args) {
|
|
2803
|
-
return [
|
|
2705
|
+
return [api_exports.ETransactionVersion.V3, api_exports.ETransactionVersion.F3].includes(
|
|
2804
2706
|
args.version
|
|
2805
2707
|
);
|
|
2806
2708
|
}
|
|
@@ -3095,19 +2997,19 @@ function estimateFeeToBounds(estimate, amountOverhead = 50 /* L1_BOUND_MAX_AMOUN
|
|
|
3095
2997
|
};
|
|
3096
2998
|
}
|
|
3097
2999
|
function intDAM(dam) {
|
|
3098
|
-
if (dam ===
|
|
3099
|
-
return
|
|
3100
|
-
if (dam ===
|
|
3101
|
-
return
|
|
3000
|
+
if (dam === api_exports.EDataAvailabilityMode.L1)
|
|
3001
|
+
return api_exports.EDAMode.L1;
|
|
3002
|
+
if (dam === api_exports.EDataAvailabilityMode.L2)
|
|
3003
|
+
return api_exports.EDAMode.L2;
|
|
3102
3004
|
throw Error("EDAM conversion");
|
|
3103
3005
|
}
|
|
3104
3006
|
function toTransactionVersion(defaultVersion, providedVersion) {
|
|
3105
3007
|
const providedVersion0xs = providedVersion ? toHex(providedVersion) : void 0;
|
|
3106
3008
|
const defaultVersion0xs = toHex(defaultVersion);
|
|
3107
|
-
if (providedVersion && !Object.values(
|
|
3009
|
+
if (providedVersion && !Object.values(api_exports.ETransactionVersion).includes(providedVersion0xs)) {
|
|
3108
3010
|
throw Error(`providedVersion ${providedVersion} is not ETransactionVersion`);
|
|
3109
3011
|
}
|
|
3110
|
-
if (!Object.values(
|
|
3012
|
+
if (!Object.values(api_exports.ETransactionVersion).includes(defaultVersion0xs)) {
|
|
3111
3013
|
throw Error(`defaultVersion ${defaultVersion} is not ETransactionVersion`);
|
|
3112
3014
|
}
|
|
3113
3015
|
return providedVersion ? providedVersion0xs : defaultVersion0xs;
|
|
@@ -3116,14 +3018,14 @@ function toFeeVersion(providedVersion) {
|
|
|
3116
3018
|
if (!providedVersion)
|
|
3117
3019
|
return void 0;
|
|
3118
3020
|
const version = toHex(providedVersion);
|
|
3119
|
-
if (version ===
|
|
3120
|
-
return
|
|
3121
|
-
if (version ===
|
|
3122
|
-
return
|
|
3123
|
-
if (version ===
|
|
3124
|
-
return
|
|
3125
|
-
if (version ===
|
|
3126
|
-
return
|
|
3021
|
+
if (version === api_exports.ETransactionVersion.V0)
|
|
3022
|
+
return api_exports.ETransactionVersion.F0;
|
|
3023
|
+
if (version === api_exports.ETransactionVersion.V1)
|
|
3024
|
+
return api_exports.ETransactionVersion.F1;
|
|
3025
|
+
if (version === api_exports.ETransactionVersion.V2)
|
|
3026
|
+
return api_exports.ETransactionVersion.F2;
|
|
3027
|
+
if (version === api_exports.ETransactionVersion.V3)
|
|
3028
|
+
return api_exports.ETransactionVersion.F3;
|
|
3127
3029
|
throw Error(`toFeeVersion: ${version} is not supported`);
|
|
3128
3030
|
}
|
|
3129
3031
|
function v3Details(details) {
|
|
@@ -3131,16 +3033,16 @@ function v3Details(details) {
|
|
|
3131
3033
|
tip: details.tip || 0,
|
|
3132
3034
|
paymasterData: details.paymasterData || [],
|
|
3133
3035
|
accountDeploymentData: details.accountDeploymentData || [],
|
|
3134
|
-
nonceDataAvailabilityMode: details.nonceDataAvailabilityMode ||
|
|
3135
|
-
feeDataAvailabilityMode: details.feeDataAvailabilityMode ||
|
|
3036
|
+
nonceDataAvailabilityMode: details.nonceDataAvailabilityMode || api_exports.EDataAvailabilityMode.L1,
|
|
3037
|
+
feeDataAvailabilityMode: details.feeDataAvailabilityMode || api_exports.EDataAvailabilityMode.L1,
|
|
3136
3038
|
resourceBounds: details.resourceBounds ?? estimateFeeToBounds(ZERO)
|
|
3137
3039
|
};
|
|
3138
3040
|
}
|
|
3139
3041
|
function reduceV2(providedVersion) {
|
|
3140
|
-
if (providedVersion ===
|
|
3141
|
-
return
|
|
3142
|
-
if (providedVersion ===
|
|
3143
|
-
return
|
|
3042
|
+
if (providedVersion === api_exports.ETransactionVersion.F2)
|
|
3043
|
+
return api_exports.ETransactionVersion.F1;
|
|
3044
|
+
if (providedVersion === api_exports.ETransactionVersion.V2)
|
|
3045
|
+
return api_exports.ETransactionVersion.V1;
|
|
3144
3046
|
return providedVersion;
|
|
3145
3047
|
}
|
|
3146
3048
|
|
|
@@ -3186,7 +3088,7 @@ function ethRandomPrivateKey() {
|
|
|
3186
3088
|
function validateAndParseEthAddress(address) {
|
|
3187
3089
|
assertInRange(address, ZERO, 2n ** 160n - 1n, "Ethereum Address ");
|
|
3188
3090
|
const result = addHexPrefix(removeHexPrefix(toHex(address)).padStart(40, "0"));
|
|
3189
|
-
assert(result.match(/^(0x)?[0-9a-f]{40}$/), "Invalid Ethereum Address Format");
|
|
3091
|
+
assert(Boolean(result.match(/^(0x)?[0-9a-f]{40}$/)), "Invalid Ethereum Address Format");
|
|
3190
3092
|
return result;
|
|
3191
3093
|
}
|
|
3192
3094
|
|
|
@@ -3238,9 +3140,10 @@ function parseContract(contract) {
|
|
|
3238
3140
|
return createSierraContractClass(parsedContract);
|
|
3239
3141
|
}
|
|
3240
3142
|
var getDefaultNodeUrl = (networkName, mute = false) => {
|
|
3241
|
-
if (!mute)
|
|
3143
|
+
if (!mute) {
|
|
3242
3144
|
console.warn("Using default public node url, please provide nodeUrl in provider options!");
|
|
3243
|
-
|
|
3145
|
+
}
|
|
3146
|
+
const nodes = RPC_NODES[networkName ?? "SN_SEPOLIA" /* SN_SEPOLIA */];
|
|
3244
3147
|
const randIdx = Math.floor(Math.random() * nodes.length);
|
|
3245
3148
|
return nodes[randIdx];
|
|
3246
3149
|
};
|
|
@@ -3263,10 +3166,14 @@ var Block = class {
|
|
|
3263
3166
|
tag = null;
|
|
3264
3167
|
setIdentifier(__identifier) {
|
|
3265
3168
|
if (isString(__identifier)) {
|
|
3266
|
-
if (
|
|
3169
|
+
if (isDecimalString(__identifier)) {
|
|
3170
|
+
this.number = parseInt(__identifier, 10);
|
|
3171
|
+
} else if (isHex(__identifier)) {
|
|
3267
3172
|
this.hash = __identifier;
|
|
3268
3173
|
} else if (validBlockTags.includes(__identifier)) {
|
|
3269
3174
|
this.tag = __identifier;
|
|
3175
|
+
} else {
|
|
3176
|
+
throw TypeError(`Block identifier unmanaged: ${__identifier}`);
|
|
3270
3177
|
}
|
|
3271
3178
|
} else if (isBigInt(__identifier)) {
|
|
3272
3179
|
this.hash = toHex(__identifier);
|
|
@@ -3275,6 +3182,9 @@ var Block = class {
|
|
|
3275
3182
|
} else {
|
|
3276
3183
|
this.tag = "pending" /* pending */;
|
|
3277
3184
|
}
|
|
3185
|
+
if (isNumber(this.number) && this.number < 0) {
|
|
3186
|
+
throw TypeError(`Block number (${this.number}) can't be negative`);
|
|
3187
|
+
}
|
|
3278
3188
|
}
|
|
3279
3189
|
constructor(_identifier) {
|
|
3280
3190
|
this.setIdentifier(_identifier);
|
|
@@ -3304,15 +3214,10 @@ var Block = class {
|
|
|
3304
3214
|
}
|
|
3305
3215
|
valueOf = () => this.number;
|
|
3306
3216
|
toString = () => this.hash;
|
|
3307
|
-
/* get sequencerIdentifier(): SequencerIdentifier {
|
|
3308
|
-
return this.hash !== null
|
|
3309
|
-
? { blockHash: this.hash as string }
|
|
3310
|
-
: { blockNumber: (this.number ?? this.tag) as BlockNumber };
|
|
3311
|
-
} */
|
|
3312
3217
|
};
|
|
3313
3218
|
function isV3Tx(details) {
|
|
3314
|
-
const version = details.version ? toHex(details.version) :
|
|
3315
|
-
return version ===
|
|
3219
|
+
const version = details.version ? toHex(details.version) : api_exports.ETransactionVersion.V3;
|
|
3220
|
+
return version === api_exports.ETransactionVersion.V3 || version === api_exports.ETransactionVersion.F3;
|
|
3316
3221
|
}
|
|
3317
3222
|
function isVersion(version, response) {
|
|
3318
3223
|
const [majorS, minorS] = version.split(".");
|
|
@@ -3427,10 +3332,10 @@ function buildUDCCall(payload, address) {
|
|
|
3427
3332
|
}
|
|
3428
3333
|
function getVersionsByType(versionType) {
|
|
3429
3334
|
return versionType === "fee" ? {
|
|
3430
|
-
v1:
|
|
3431
|
-
v2:
|
|
3432
|
-
v3:
|
|
3433
|
-
} : { v1:
|
|
3335
|
+
v1: api_exports.ETransactionVersion.F1,
|
|
3336
|
+
v2: api_exports.ETransactionVersion.F2,
|
|
3337
|
+
v3: api_exports.ETransactionVersion.F3
|
|
3338
|
+
} : { v1: api_exports.ETransactionVersion.V1, v2: api_exports.ETransactionVersion.V2, v3: api_exports.ETransactionVersion.V3 };
|
|
3434
3339
|
}
|
|
3435
3340
|
|
|
3436
3341
|
// src/channel/rpc_0_6.ts
|
|
@@ -3591,11 +3496,12 @@ var RpcChannel = class {
|
|
|
3591
3496
|
* - skipValidate (default false)<br/>
|
|
3592
3497
|
* - skipFeeCharge (default true)<br/>
|
|
3593
3498
|
*/
|
|
3594
|
-
simulateTransaction(invocations, {
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3499
|
+
simulateTransaction(invocations, simulateTransactionOptions = {}) {
|
|
3500
|
+
const {
|
|
3501
|
+
blockIdentifier = this.blockIdentifier,
|
|
3502
|
+
skipValidate = true,
|
|
3503
|
+
skipFeeCharge = true
|
|
3504
|
+
} = simulateTransactionOptions;
|
|
3599
3505
|
const block_id = new Block(blockIdentifier).identifier;
|
|
3600
3506
|
const simulationFlags = [];
|
|
3601
3507
|
if (skipValidate)
|
|
@@ -3918,7 +3824,6 @@ var RpcChannel = class {
|
|
|
3918
3824
|
return {
|
|
3919
3825
|
// v0 v1 v3
|
|
3920
3826
|
type: rpcspec_0_6_exports.ETransactionType.INVOKE,
|
|
3921
|
-
// TODO: Diff between sequencer and rpc invoke type
|
|
3922
3827
|
sender_address: invocation.contractAddress,
|
|
3923
3828
|
calldata: CallData.toHex(invocation.calldata),
|
|
3924
3829
|
version: toHex(invocation.version || defaultVersions.v3),
|
|
@@ -3981,10 +3886,20 @@ var RpcChannel2 = class {
|
|
|
3981
3886
|
blockIdentifier;
|
|
3982
3887
|
chainId;
|
|
3983
3888
|
specVersion;
|
|
3889
|
+
transactionRetryIntervalFallback;
|
|
3984
3890
|
waitMode;
|
|
3985
3891
|
// behave like web2 rpc and return when tx is processed
|
|
3986
3892
|
constructor(optionsOrProvider) {
|
|
3987
|
-
const {
|
|
3893
|
+
const {
|
|
3894
|
+
nodeUrl,
|
|
3895
|
+
retries,
|
|
3896
|
+
headers,
|
|
3897
|
+
blockIdentifier,
|
|
3898
|
+
chainId,
|
|
3899
|
+
specVersion,
|
|
3900
|
+
waitMode,
|
|
3901
|
+
transactionRetryIntervalFallback
|
|
3902
|
+
} = optionsOrProvider || {};
|
|
3988
3903
|
if (Object.values(NetworkName).includes(nodeUrl)) {
|
|
3989
3904
|
this.nodeUrl = getDefaultNodeUrl(nodeUrl, optionsOrProvider?.default);
|
|
3990
3905
|
} else if (nodeUrl) {
|
|
@@ -3999,6 +3914,10 @@ var RpcChannel2 = class {
|
|
|
3999
3914
|
this.specVersion = specVersion;
|
|
4000
3915
|
this.waitMode = waitMode || false;
|
|
4001
3916
|
this.requestId = 0;
|
|
3917
|
+
this.transactionRetryIntervalFallback = transactionRetryIntervalFallback;
|
|
3918
|
+
}
|
|
3919
|
+
get transactionRetryIntervalDefault() {
|
|
3920
|
+
return this.transactionRetryIntervalFallback ?? 5e3;
|
|
4002
3921
|
}
|
|
4003
3922
|
setChainId(chainId) {
|
|
4004
3923
|
this.chainId = chainId;
|
|
@@ -4129,17 +4048,18 @@ var RpcChannel2 = class {
|
|
|
4129
4048
|
* - skipValidate (default false)<br/>
|
|
4130
4049
|
* - skipFeeCharge (default true)<br/>
|
|
4131
4050
|
*/
|
|
4132
|
-
simulateTransaction(invocations, {
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4051
|
+
simulateTransaction(invocations, simulateTransactionOptions = {}) {
|
|
4052
|
+
const {
|
|
4053
|
+
blockIdentifier = this.blockIdentifier,
|
|
4054
|
+
skipValidate = true,
|
|
4055
|
+
skipFeeCharge = true
|
|
4056
|
+
} = simulateTransactionOptions;
|
|
4137
4057
|
const block_id = new Block(blockIdentifier).identifier;
|
|
4138
4058
|
const simulationFlags = [];
|
|
4139
4059
|
if (skipValidate)
|
|
4140
|
-
simulationFlags.push(
|
|
4060
|
+
simulationFlags.push(RPCSPEC07.ESimulationFlag.SKIP_VALIDATE);
|
|
4141
4061
|
if (skipFeeCharge)
|
|
4142
|
-
simulationFlags.push(
|
|
4062
|
+
simulationFlags.push(RPCSPEC07.ESimulationFlag.SKIP_FEE_CHARGE);
|
|
4143
4063
|
return this.fetchEndpoint("starknet_simulateTransactions", {
|
|
4144
4064
|
block_id,
|
|
4145
4065
|
transactions: invocations.map((it) => this.buildTransaction(it)),
|
|
@@ -4151,17 +4071,17 @@ var RpcChannel2 = class {
|
|
|
4151
4071
|
let { retries } = this;
|
|
4152
4072
|
let onchain = false;
|
|
4153
4073
|
let isErrorState = false;
|
|
4154
|
-
const retryInterval = options?.retryInterval ??
|
|
4074
|
+
const retryInterval = options?.retryInterval ?? this.transactionRetryIntervalDefault;
|
|
4155
4075
|
const errorStates = options?.errorStates ?? [
|
|
4156
|
-
|
|
4076
|
+
RPCSPEC07.ETransactionStatus.REJECTED
|
|
4157
4077
|
// TODO: commented out to preserve the long-standing behavior of "reverted" not being treated as an error by default
|
|
4158
4078
|
// should decide which behavior to keep in the future
|
|
4159
4079
|
// RPC.ETransactionExecutionStatus.REVERTED,
|
|
4160
4080
|
];
|
|
4161
4081
|
const successStates = options?.successStates ?? [
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4082
|
+
RPCSPEC07.ETransactionExecutionStatus.SUCCEEDED,
|
|
4083
|
+
RPCSPEC07.ETransactionStatus.ACCEPTED_ON_L2,
|
|
4084
|
+
RPCSPEC07.ETransactionStatus.ACCEPTED_ON_L1
|
|
4165
4085
|
];
|
|
4166
4086
|
let txStatus;
|
|
4167
4087
|
while (!onchain) {
|
|
@@ -4246,7 +4166,7 @@ var RpcChannel2 = class {
|
|
|
4246
4166
|
let flags = {};
|
|
4247
4167
|
if (!isVersion("0.5", await this.getSpecVersion())) {
|
|
4248
4168
|
flags = {
|
|
4249
|
-
simulation_flags: skipValidate ? [
|
|
4169
|
+
simulation_flags: skipValidate ? [RPCSPEC07.ESimulationFlag.SKIP_VALIDATE] : []
|
|
4250
4170
|
};
|
|
4251
4171
|
}
|
|
4252
4172
|
return this.fetchEndpoint("starknet_estimateFee", {
|
|
@@ -4262,9 +4182,9 @@ var RpcChannel2 = class {
|
|
|
4262
4182
|
invoke_transaction: {
|
|
4263
4183
|
sender_address: functionInvocation.contractAddress,
|
|
4264
4184
|
calldata: CallData.toHex(functionInvocation.calldata),
|
|
4265
|
-
type:
|
|
4185
|
+
type: RPCSPEC07.ETransactionType.INVOKE,
|
|
4266
4186
|
max_fee: toHex(details.maxFee || 0),
|
|
4267
|
-
version:
|
|
4187
|
+
version: RPCSPEC07.ETransactionVersion.V1,
|
|
4268
4188
|
signature: signatureToHexArray(functionInvocation.signature),
|
|
4269
4189
|
nonce: toHex(details.nonce)
|
|
4270
4190
|
}
|
|
@@ -4272,10 +4192,10 @@ var RpcChannel2 = class {
|
|
|
4272
4192
|
} else {
|
|
4273
4193
|
promise = this.fetchEndpoint("starknet_addInvokeTransaction", {
|
|
4274
4194
|
invoke_transaction: {
|
|
4275
|
-
type:
|
|
4195
|
+
type: RPCSPEC07.ETransactionType.INVOKE,
|
|
4276
4196
|
sender_address: functionInvocation.contractAddress,
|
|
4277
4197
|
calldata: CallData.toHex(functionInvocation.calldata),
|
|
4278
|
-
version:
|
|
4198
|
+
version: RPCSPEC07.ETransactionVersion.V3,
|
|
4279
4199
|
signature: signatureToHexArray(functionInvocation.signature),
|
|
4280
4200
|
nonce: toHex(details.nonce),
|
|
4281
4201
|
resource_bounds: details.resourceBounds,
|
|
@@ -4294,13 +4214,13 @@ var RpcChannel2 = class {
|
|
|
4294
4214
|
if (!isSierra(contract) && !isV3Tx(details)) {
|
|
4295
4215
|
promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
|
|
4296
4216
|
declare_transaction: {
|
|
4297
|
-
type:
|
|
4217
|
+
type: RPCSPEC07.ETransactionType.DECLARE,
|
|
4298
4218
|
contract_class: {
|
|
4299
4219
|
program: contract.program,
|
|
4300
4220
|
entry_points_by_type: contract.entry_points_by_type,
|
|
4301
4221
|
abi: contract.abi
|
|
4302
4222
|
},
|
|
4303
|
-
version:
|
|
4223
|
+
version: RPCSPEC07.ETransactionVersion.V1,
|
|
4304
4224
|
max_fee: toHex(details.maxFee || 0),
|
|
4305
4225
|
signature: signatureToHexArray(signature),
|
|
4306
4226
|
sender_address: senderAddress,
|
|
@@ -4310,7 +4230,7 @@ var RpcChannel2 = class {
|
|
|
4310
4230
|
} else if (isSierra(contract) && !isV3Tx(details)) {
|
|
4311
4231
|
promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
|
|
4312
4232
|
declare_transaction: {
|
|
4313
|
-
type:
|
|
4233
|
+
type: RPCSPEC07.ETransactionType.DECLARE,
|
|
4314
4234
|
contract_class: {
|
|
4315
4235
|
sierra_program: decompressProgram(contract.sierra_program),
|
|
4316
4236
|
contract_class_version: contract.contract_class_version,
|
|
@@ -4318,7 +4238,7 @@ var RpcChannel2 = class {
|
|
|
4318
4238
|
abi: contract.abi
|
|
4319
4239
|
},
|
|
4320
4240
|
compiled_class_hash: compiledClassHash || "",
|
|
4321
|
-
version:
|
|
4241
|
+
version: RPCSPEC07.ETransactionVersion.V2,
|
|
4322
4242
|
max_fee: toHex(details.maxFee || 0),
|
|
4323
4243
|
signature: signatureToHexArray(signature),
|
|
4324
4244
|
sender_address: senderAddress,
|
|
@@ -4328,10 +4248,10 @@ var RpcChannel2 = class {
|
|
|
4328
4248
|
} else if (isSierra(contract) && isV3Tx(details)) {
|
|
4329
4249
|
promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
|
|
4330
4250
|
declare_transaction: {
|
|
4331
|
-
type:
|
|
4251
|
+
type: RPCSPEC07.ETransactionType.DECLARE,
|
|
4332
4252
|
sender_address: senderAddress,
|
|
4333
4253
|
compiled_class_hash: compiledClassHash || "",
|
|
4334
|
-
version:
|
|
4254
|
+
version: RPCSPEC07.ETransactionVersion.V3,
|
|
4335
4255
|
signature: signatureToHexArray(signature),
|
|
4336
4256
|
nonce: toHex(details.nonce),
|
|
4337
4257
|
contract_class: {
|
|
@@ -4361,9 +4281,9 @@ var RpcChannel2 = class {
|
|
|
4361
4281
|
constructor_calldata: CallData.toHex(constructorCalldata || []),
|
|
4362
4282
|
class_hash: toHex(classHash),
|
|
4363
4283
|
contract_address_salt: toHex(addressSalt || 0),
|
|
4364
|
-
type:
|
|
4284
|
+
type: RPCSPEC07.ETransactionType.DEPLOY_ACCOUNT,
|
|
4365
4285
|
max_fee: toHex(details.maxFee || 0),
|
|
4366
|
-
version:
|
|
4286
|
+
version: RPCSPEC07.ETransactionVersion.V1,
|
|
4367
4287
|
signature: signatureToHexArray(signature),
|
|
4368
4288
|
nonce: toHex(details.nonce)
|
|
4369
4289
|
}
|
|
@@ -4371,8 +4291,8 @@ var RpcChannel2 = class {
|
|
|
4371
4291
|
} else {
|
|
4372
4292
|
promise = this.fetchEndpoint("starknet_addDeployAccountTransaction", {
|
|
4373
4293
|
deploy_account_transaction: {
|
|
4374
|
-
type:
|
|
4375
|
-
version:
|
|
4294
|
+
type: RPCSPEC07.ETransactionType.DEPLOY_ACCOUNT,
|
|
4295
|
+
version: RPCSPEC07.ETransactionVersion.V3,
|
|
4376
4296
|
signature: signatureToHexArray(signature),
|
|
4377
4297
|
nonce: toHex(details.nonce),
|
|
4378
4298
|
contract_address_salt: toHex(addressSalt || 0),
|
|
@@ -4455,8 +4375,7 @@ var RpcChannel2 = class {
|
|
|
4455
4375
|
if (invocation.type === "INVOKE_FUNCTION" /* INVOKE */) {
|
|
4456
4376
|
return {
|
|
4457
4377
|
// v0 v1 v3
|
|
4458
|
-
type:
|
|
4459
|
-
// TODO: Diff between sequencer and rpc invoke type
|
|
4378
|
+
type: RPCSPEC07.ETransactionType.INVOKE,
|
|
4460
4379
|
sender_address: invocation.contractAddress,
|
|
4461
4380
|
calldata: CallData.toHex(invocation.calldata),
|
|
4462
4381
|
version: toHex(invocation.version || defaultVersions.v3),
|
|
@@ -4572,6 +4491,9 @@ var RPCResponseParser = class {
|
|
|
4572
4491
|
abi: isString(res.abi) ? JSON.parse(res.abi) : res.abi
|
|
4573
4492
|
};
|
|
4574
4493
|
}
|
|
4494
|
+
parseL1GasPriceResponse(res) {
|
|
4495
|
+
return res.l1_gas_price.price_in_wei;
|
|
4496
|
+
}
|
|
4575
4497
|
};
|
|
4576
4498
|
|
|
4577
4499
|
// src/utils/transactionReceipt.ts
|
|
@@ -4670,6 +4592,63 @@ var RpcProvider = class {
|
|
|
4670
4592
|
async getBlockWithTxs(blockIdentifier) {
|
|
4671
4593
|
return this.channel.getBlockWithTxs(blockIdentifier);
|
|
4672
4594
|
}
|
|
4595
|
+
/**
|
|
4596
|
+
* Pause the execution of the script until a specified block is created.
|
|
4597
|
+
* @param {BlockIdentifier} blockIdentifier bloc number (BigNumberisk) or 'pending' or 'latest'.
|
|
4598
|
+
* Use of 'latest" or of a block already created will generate no pause.
|
|
4599
|
+
* @param {number} [retryInterval] number of milliseconds between 2 requests to the node
|
|
4600
|
+
* @example
|
|
4601
|
+
* ```typescript
|
|
4602
|
+
* await myProvider.waitForBlock();
|
|
4603
|
+
* // wait the creation of the pending block
|
|
4604
|
+
* ```
|
|
4605
|
+
*/
|
|
4606
|
+
async waitForBlock(blockIdentifier = "pending", retryInterval = 5e3) {
|
|
4607
|
+
if (blockIdentifier === "latest" /* latest */)
|
|
4608
|
+
return;
|
|
4609
|
+
const currentBlock = await this.getBlockNumber();
|
|
4610
|
+
const targetBlock = blockIdentifier === "pending" /* pending */ ? currentBlock + 1 : Number(toHex(blockIdentifier));
|
|
4611
|
+
if (targetBlock <= currentBlock)
|
|
4612
|
+
return;
|
|
4613
|
+
const { retries } = this.channel;
|
|
4614
|
+
let retriesCount = retries;
|
|
4615
|
+
let isTargetBlock = false;
|
|
4616
|
+
while (!isTargetBlock) {
|
|
4617
|
+
const currBlock = await this.getBlockNumber();
|
|
4618
|
+
if (currBlock === targetBlock) {
|
|
4619
|
+
isTargetBlock = true;
|
|
4620
|
+
} else {
|
|
4621
|
+
await wait(retryInterval);
|
|
4622
|
+
}
|
|
4623
|
+
retriesCount -= 1;
|
|
4624
|
+
if (retriesCount <= 0) {
|
|
4625
|
+
throw new Error(`waitForBlock() timed-out after ${retries} tries.`);
|
|
4626
|
+
}
|
|
4627
|
+
}
|
|
4628
|
+
}
|
|
4629
|
+
async getL1GasPrice(blockIdentifier) {
|
|
4630
|
+
return this.channel.getBlockWithTxHashes(blockIdentifier).then(this.responseParser.parseL1GasPriceResponse);
|
|
4631
|
+
}
|
|
4632
|
+
async getL1MessageHash(l2TxHash) {
|
|
4633
|
+
const transaction = await this.channel.getTransactionByHash(l2TxHash);
|
|
4634
|
+
assert(transaction.type === "L1_HANDLER", "This L2 transaction is not a L1 message.");
|
|
4635
|
+
const { calldata, contract_address, entry_point_selector, nonce } = transaction;
|
|
4636
|
+
const params = [
|
|
4637
|
+
calldata[0],
|
|
4638
|
+
contract_address,
|
|
4639
|
+
nonce,
|
|
4640
|
+
entry_point_selector,
|
|
4641
|
+
calldata.length - 1,
|
|
4642
|
+
...calldata.slice(1)
|
|
4643
|
+
];
|
|
4644
|
+
const myEncode = addHexPrefix(
|
|
4645
|
+
params.reduce(
|
|
4646
|
+
(res, par) => res + removeHexPrefix(toHex(par)).padStart(64, "0"),
|
|
4647
|
+
""
|
|
4648
|
+
)
|
|
4649
|
+
);
|
|
4650
|
+
return addHexPrefix(bytesToHex(keccak_256(hexToBytes(myEncode))));
|
|
4651
|
+
}
|
|
4673
4652
|
async getBlockWithReceipts(blockIdentifier) {
|
|
4674
4653
|
if (this.channel instanceof rpc_0_6_exports.RpcChannel)
|
|
4675
4654
|
throw new LibraryError("Unsupported method for RPC version");
|
|
@@ -4721,7 +4700,7 @@ var RpcProvider = class {
|
|
|
4721
4700
|
}
|
|
4722
4701
|
/**
|
|
4723
4702
|
* @param invocations AccountInvocations
|
|
4724
|
-
* @param
|
|
4703
|
+
* @param options blockIdentifier and flags to skip validation and fee charge<br/>
|
|
4725
4704
|
* - blockIdentifier<br/>
|
|
4726
4705
|
* - skipValidate (default false)<br/>
|
|
4727
4706
|
* - skipFeeCharge (default true)<br/>
|
|
@@ -4962,7 +4941,6 @@ function useEncoded(decoded) {
|
|
|
4962
4941
|
}
|
|
4963
4942
|
var StarknetIdContract = /* @__PURE__ */ ((StarknetIdContract2) => {
|
|
4964
4943
|
StarknetIdContract2["MAINNET"] = "0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678";
|
|
4965
|
-
StarknetIdContract2["TESTNET"] = "0x3bab268e932d2cecd1946f100ae67ce3dff9fd234119ea2f6da57d16d29fce";
|
|
4966
4944
|
StarknetIdContract2["TESTNET_SEPOLIA"] = "0x0707f09bc576bd7cfee59694846291047e965f4184fe13dac62c56759b3b6fa7";
|
|
4967
4945
|
return StarknetIdContract2;
|
|
4968
4946
|
})(StarknetIdContract || {});
|
|
@@ -4970,8 +4948,6 @@ function getStarknetIdContract(chainId) {
|
|
|
4970
4948
|
switch (chainId) {
|
|
4971
4949
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
4972
4950
|
return "0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678" /* MAINNET */;
|
|
4973
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
4974
|
-
return "0x3bab268e932d2cecd1946f100ae67ce3dff9fd234119ea2f6da57d16d29fce" /* TESTNET */;
|
|
4975
4951
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
4976
4952
|
return "0x0707f09bc576bd7cfee59694846291047e965f4184fe13dac62c56759b3b6fa7" /* TESTNET_SEPOLIA */;
|
|
4977
4953
|
default:
|
|
@@ -4980,7 +4956,6 @@ function getStarknetIdContract(chainId) {
|
|
|
4980
4956
|
}
|
|
4981
4957
|
var StarknetIdIdentityContract = /* @__PURE__ */ ((StarknetIdIdentityContract2) => {
|
|
4982
4958
|
StarknetIdIdentityContract2["MAINNET"] = "0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af";
|
|
4983
|
-
StarknetIdIdentityContract2["TESTNET"] = "0x783a9097b26eae0586373b2ce0ed3529ddc44069d1e0fbc4f66d42b69d6850d";
|
|
4984
4959
|
StarknetIdIdentityContract2["TESTNET_SEPOLIA"] = "0x070DF8B4F5cb2879f8592849fA8f3134da39d25326B8558cc9C8FE8D47EA3A90";
|
|
4985
4960
|
return StarknetIdIdentityContract2;
|
|
4986
4961
|
})(StarknetIdIdentityContract || {});
|
|
@@ -4988,8 +4963,6 @@ function getStarknetIdIdentityContract(chainId) {
|
|
|
4988
4963
|
switch (chainId) {
|
|
4989
4964
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
4990
4965
|
return "0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af" /* MAINNET */;
|
|
4991
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
4992
|
-
return "0x783a9097b26eae0586373b2ce0ed3529ddc44069d1e0fbc4f66d42b69d6850d" /* TESTNET */;
|
|
4993
4966
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
4994
4967
|
return "0x070DF8B4F5cb2879f8592849fA8f3134da39d25326B8558cc9C8FE8D47EA3A90" /* TESTNET_SEPOLIA */;
|
|
4995
4968
|
default:
|
|
@@ -5001,8 +4974,6 @@ function getStarknetIdMulticallContract(chainId) {
|
|
|
5001
4974
|
switch (chainId) {
|
|
5002
4975
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
5003
4976
|
return StarknetIdMulticallContract;
|
|
5004
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
5005
|
-
return StarknetIdMulticallContract;
|
|
5006
4977
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
5007
4978
|
return StarknetIdMulticallContract;
|
|
5008
4979
|
default:
|
|
@@ -5011,7 +4982,6 @@ function getStarknetIdMulticallContract(chainId) {
|
|
|
5011
4982
|
}
|
|
5012
4983
|
var StarknetIdVerifierContract = /* @__PURE__ */ ((StarknetIdVerifierContract2) => {
|
|
5013
4984
|
StarknetIdVerifierContract2["MAINNET"] = "0x07d14dfd8ee95b41fce179170d88ba1f0d5a512e13aeb232f19cfeec0a88f8bf";
|
|
5014
|
-
StarknetIdVerifierContract2["TESTNET"] = "0x057c942544063c3aea6ea6c37009cc9d1beacd750cb6801549a129c7265f0f11";
|
|
5015
4985
|
StarknetIdVerifierContract2["TESTNET_SEPOLIA"] = "0x0182EcE8173C216A395f4828e1523541b7e3600bf190CB252E1a1A0cE219d184";
|
|
5016
4986
|
return StarknetIdVerifierContract2;
|
|
5017
4987
|
})(StarknetIdVerifierContract || {});
|
|
@@ -5019,8 +4989,6 @@ function getStarknetIdVerifierContract(chainId) {
|
|
|
5019
4989
|
switch (chainId) {
|
|
5020
4990
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
5021
4991
|
return "0x07d14dfd8ee95b41fce179170d88ba1f0d5a512e13aeb232f19cfeec0a88f8bf" /* MAINNET */;
|
|
5022
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
5023
|
-
return "0x057c942544063c3aea6ea6c37009cc9d1beacd750cb6801549a129c7265f0f11" /* TESTNET */;
|
|
5024
4992
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
5025
4993
|
return "0x0182EcE8173C216A395f4828e1523541b7e3600bf190CB252E1a1A0cE219d184" /* TESTNET_SEPOLIA */;
|
|
5026
4994
|
default:
|
|
@@ -5029,7 +4997,6 @@ function getStarknetIdVerifierContract(chainId) {
|
|
|
5029
4997
|
}
|
|
5030
4998
|
var StarknetIdPfpContract = /* @__PURE__ */ ((StarknetIdPfpContract2) => {
|
|
5031
4999
|
StarknetIdPfpContract2["MAINNET"] = "0x070aaa20ec4a46da57c932d9fd89ca5e6bb9ca3188d3df361a32306aff7d59c7";
|
|
5032
|
-
StarknetIdPfpContract2["TESTNET"] = "0x03cac3228b434259734ee0e4ff445f642206ea11adace7e4f45edd2596748698";
|
|
5033
5000
|
StarknetIdPfpContract2["TESTNET_SEPOLIA"] = "0x058061bb6bdc501eE215172c9f87d557C1E0f466dC498cA81b18f998Bf1362b2";
|
|
5034
5001
|
return StarknetIdPfpContract2;
|
|
5035
5002
|
})(StarknetIdPfpContract || {});
|
|
@@ -5037,8 +5004,6 @@ function getStarknetIdPfpContract(chainId) {
|
|
|
5037
5004
|
switch (chainId) {
|
|
5038
5005
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
5039
5006
|
return "0x070aaa20ec4a46da57c932d9fd89ca5e6bb9ca3188d3df361a32306aff7d59c7" /* MAINNET */;
|
|
5040
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
5041
|
-
return "0x03cac3228b434259734ee0e4ff445f642206ea11adace7e4f45edd2596748698" /* TESTNET */;
|
|
5042
5007
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
5043
5008
|
return "0x058061bb6bdc501eE215172c9f87d557C1E0f466dC498cA81b18f998Bf1362b2" /* TESTNET_SEPOLIA */;
|
|
5044
5009
|
default:
|
|
@@ -5049,7 +5014,6 @@ function getStarknetIdPfpContract(chainId) {
|
|
|
5049
5014
|
}
|
|
5050
5015
|
var StarknetIdPopContract = /* @__PURE__ */ ((StarknetIdPopContract2) => {
|
|
5051
5016
|
StarknetIdPopContract2["MAINNET"] = "0x0293eb2ba9862f762bd3036586d5755a782bd22e6f5028320f1d0405fd47bff4";
|
|
5052
|
-
StarknetIdPopContract2["TESTNET"] = "0x03528caf090179e337931ee669a5b0214041e1bae30d460ff07d2cea2c7a9106";
|
|
5053
5017
|
StarknetIdPopContract2["TESTNET_SEPOLIA"] = "0x0023FE3b845ed5665a9eb3792bbB17347B490EE4090f855C1298d03BB5F49B49";
|
|
5054
5018
|
return StarknetIdPopContract2;
|
|
5055
5019
|
})(StarknetIdPopContract || {});
|
|
@@ -5057,8 +5021,6 @@ function getStarknetIdPopContract(chainId) {
|
|
|
5057
5021
|
switch (chainId) {
|
|
5058
5022
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
5059
5023
|
return "0x0293eb2ba9862f762bd3036586d5755a782bd22e6f5028320f1d0405fd47bff4" /* MAINNET */;
|
|
5060
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
5061
|
-
return "0x03528caf090179e337931ee669a5b0214041e1bae30d460ff07d2cea2c7a9106" /* TESTNET */;
|
|
5062
5024
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
5063
5025
|
return "0x0023FE3b845ed5665a9eb3792bbB17347B490EE4090f855C1298d03BB5F49B49" /* TESTNET_SEPOLIA */;
|
|
5064
5026
|
default:
|
|
@@ -5123,13 +5085,7 @@ var StarknetId = class _StarknetId {
|
|
|
5123
5085
|
const chainId = await provider.getChainId();
|
|
5124
5086
|
const contract = StarknetIdContract2 ?? getStarknetIdContract(chainId);
|
|
5125
5087
|
try {
|
|
5126
|
-
const hexDomain = await
|
|
5127
|
-
contractAddress: contract,
|
|
5128
|
-
entrypoint: "address_to_domain",
|
|
5129
|
-
calldata: CallData.compile({
|
|
5130
|
-
address
|
|
5131
|
-
})
|
|
5132
|
-
});
|
|
5088
|
+
const hexDomain = await this.executeStarkName(provider, address, contract);
|
|
5133
5089
|
const decimalDomain = hexDomain.map((element) => BigInt(element)).slice(1);
|
|
5134
5090
|
const stringDomain = useDecoded(decimalDomain);
|
|
5135
5091
|
if (!stringDomain) {
|
|
@@ -5143,6 +5099,26 @@ var StarknetId = class _StarknetId {
|
|
|
5143
5099
|
throw Error("Could not get stark name");
|
|
5144
5100
|
}
|
|
5145
5101
|
}
|
|
5102
|
+
static async executeStarkName(provider, address, contract) {
|
|
5103
|
+
try {
|
|
5104
|
+
return await provider.callContract({
|
|
5105
|
+
contractAddress: contract,
|
|
5106
|
+
entrypoint: "address_to_domain",
|
|
5107
|
+
calldata: CallData.compile({
|
|
5108
|
+
address,
|
|
5109
|
+
hint: []
|
|
5110
|
+
})
|
|
5111
|
+
});
|
|
5112
|
+
} catch (initialError) {
|
|
5113
|
+
return await provider.callContract({
|
|
5114
|
+
contractAddress: contract,
|
|
5115
|
+
entrypoint: "address_to_domain",
|
|
5116
|
+
calldata: CallData.compile({
|
|
5117
|
+
address
|
|
5118
|
+
})
|
|
5119
|
+
});
|
|
5120
|
+
}
|
|
5121
|
+
}
|
|
5146
5122
|
static async getAddressFromStarkName(provider, name, StarknetIdContract2) {
|
|
5147
5123
|
const chainId = await provider.getChainId();
|
|
5148
5124
|
const contract = StarknetIdContract2 ?? getStarknetIdContract(chainId);
|
|
@@ -5167,100 +5143,111 @@ var StarknetId = class _StarknetId {
|
|
|
5167
5143
|
const popContract = StarknetIdPopContract2 ?? getStarknetIdPopContract(chainId);
|
|
5168
5144
|
const multicallAddress = StarknetIdMulticallContract2 ?? getStarknetIdMulticallContract(chainId);
|
|
5169
5145
|
try {
|
|
5170
|
-
const
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
to: dynamicFelt(contract),
|
|
5184
|
-
selector: dynamicFelt(getSelectorFromName("domain_to_id")),
|
|
5185
|
-
calldata: [dynamicCallData(void 0, void 0, [0, 0])]
|
|
5186
|
-
},
|
|
5187
|
-
{
|
|
5188
|
-
execution: execution({}),
|
|
5189
|
-
to: dynamicFelt(identityContract),
|
|
5190
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5191
|
-
calldata: [
|
|
5192
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5193
|
-
dynamicCallData(encodeShortString("twitter")),
|
|
5194
|
-
dynamicCallData(verifierContract),
|
|
5195
|
-
dynamicCallData("0")
|
|
5196
|
-
]
|
|
5197
|
-
},
|
|
5198
|
-
{
|
|
5199
|
-
execution: execution({}),
|
|
5200
|
-
to: dynamicFelt(identityContract),
|
|
5201
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5202
|
-
calldata: [
|
|
5203
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5204
|
-
dynamicCallData(encodeShortString("github")),
|
|
5205
|
-
dynamicCallData(verifierContract),
|
|
5206
|
-
dynamicCallData("0")
|
|
5207
|
-
]
|
|
5208
|
-
},
|
|
5209
|
-
{
|
|
5210
|
-
execution: execution({}),
|
|
5211
|
-
to: dynamicFelt(identityContract),
|
|
5212
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5213
|
-
calldata: [
|
|
5214
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5215
|
-
dynamicCallData(encodeShortString("discord")),
|
|
5216
|
-
dynamicCallData(verifierContract),
|
|
5217
|
-
dynamicCallData("0")
|
|
5218
|
-
]
|
|
5219
|
-
},
|
|
5220
|
-
{
|
|
5221
|
-
execution: execution({}),
|
|
5222
|
-
to: dynamicFelt(identityContract),
|
|
5223
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5224
|
-
calldata: [
|
|
5225
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5226
|
-
dynamicCallData(encodeShortString("proof_of_personhood")),
|
|
5227
|
-
dynamicCallData(popContract),
|
|
5228
|
-
dynamicCallData("0")
|
|
5229
|
-
]
|
|
5230
|
-
},
|
|
5231
|
-
// PFP
|
|
5232
|
-
{
|
|
5233
|
-
execution: execution({}),
|
|
5234
|
-
to: dynamicFelt(identityContract),
|
|
5235
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5236
|
-
calldata: [
|
|
5237
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5238
|
-
dynamicCallData(encodeShortString("nft_pp_contract")),
|
|
5239
|
-
dynamicCallData(pfpContract),
|
|
5240
|
-
dynamicCallData("0")
|
|
5241
|
-
]
|
|
5242
|
-
},
|
|
5243
|
-
{
|
|
5244
|
-
execution: execution({}),
|
|
5245
|
-
to: dynamicFelt(identityContract),
|
|
5246
|
-
selector: dynamicFelt(getSelectorFromName("get_extended_verifier_data")),
|
|
5247
|
-
calldata: [
|
|
5248
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5249
|
-
dynamicCallData(encodeShortString("nft_pp_id")),
|
|
5250
|
-
dynamicCallData("2"),
|
|
5251
|
-
dynamicCallData(pfpContract),
|
|
5252
|
-
dynamicCallData("0")
|
|
5253
|
-
]
|
|
5254
|
-
},
|
|
5255
|
-
{
|
|
5256
|
-
execution: execution(void 0, void 0, [6, 0, 0]),
|
|
5257
|
-
to: dynamicFelt(void 0, [6, 0]),
|
|
5258
|
-
selector: dynamicFelt(getSelectorFromName("tokenURI")),
|
|
5259
|
-
calldata: [dynamicCallData(void 0, [7, 1]), dynamicCallData(void 0, [7, 2])]
|
|
5260
|
-
}
|
|
5261
|
-
]
|
|
5262
|
-
})
|
|
5146
|
+
const initialCalldata = [];
|
|
5147
|
+
const fallbackCalldata = [];
|
|
5148
|
+
initialCalldata.push({
|
|
5149
|
+
execution: execution({}),
|
|
5150
|
+
to: dynamicCallData(contract),
|
|
5151
|
+
selector: dynamicCallData(getSelectorFromName("address_to_domain")),
|
|
5152
|
+
calldata: [dynamicCallData(address), dynamicCallData("0")]
|
|
5153
|
+
});
|
|
5154
|
+
fallbackCalldata.push({
|
|
5155
|
+
execution: execution({}),
|
|
5156
|
+
to: dynamicCallData(contract),
|
|
5157
|
+
selector: dynamicFelt(getSelectorFromName("address_to_domain")),
|
|
5158
|
+
calldata: [dynamicCallData(address)]
|
|
5263
5159
|
});
|
|
5160
|
+
const calls = [
|
|
5161
|
+
{
|
|
5162
|
+
execution: execution({}),
|
|
5163
|
+
to: dynamicFelt(contract),
|
|
5164
|
+
selector: dynamicFelt(getSelectorFromName("domain_to_id")),
|
|
5165
|
+
calldata: [dynamicCallData(void 0, void 0, [0, 0])]
|
|
5166
|
+
},
|
|
5167
|
+
{
|
|
5168
|
+
execution: execution({}),
|
|
5169
|
+
to: dynamicFelt(identityContract),
|
|
5170
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5171
|
+
calldata: [
|
|
5172
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5173
|
+
dynamicCallData(encodeShortString("twitter")),
|
|
5174
|
+
dynamicCallData(verifierContract),
|
|
5175
|
+
dynamicCallData("0")
|
|
5176
|
+
]
|
|
5177
|
+
},
|
|
5178
|
+
{
|
|
5179
|
+
execution: execution({}),
|
|
5180
|
+
to: dynamicFelt(identityContract),
|
|
5181
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5182
|
+
calldata: [
|
|
5183
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5184
|
+
dynamicCallData(encodeShortString("github")),
|
|
5185
|
+
dynamicCallData(verifierContract),
|
|
5186
|
+
dynamicCallData("0")
|
|
5187
|
+
]
|
|
5188
|
+
},
|
|
5189
|
+
{
|
|
5190
|
+
execution: execution({}),
|
|
5191
|
+
to: dynamicFelt(identityContract),
|
|
5192
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5193
|
+
calldata: [
|
|
5194
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5195
|
+
dynamicCallData(encodeShortString("discord")),
|
|
5196
|
+
dynamicCallData(verifierContract),
|
|
5197
|
+
dynamicCallData("0")
|
|
5198
|
+
]
|
|
5199
|
+
},
|
|
5200
|
+
{
|
|
5201
|
+
execution: execution({}),
|
|
5202
|
+
to: dynamicFelt(identityContract),
|
|
5203
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5204
|
+
calldata: [
|
|
5205
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5206
|
+
dynamicCallData(encodeShortString("proof_of_personhood")),
|
|
5207
|
+
dynamicCallData(popContract),
|
|
5208
|
+
dynamicCallData("0")
|
|
5209
|
+
]
|
|
5210
|
+
},
|
|
5211
|
+
// PFP
|
|
5212
|
+
{
|
|
5213
|
+
execution: execution({}),
|
|
5214
|
+
to: dynamicFelt(identityContract),
|
|
5215
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5216
|
+
calldata: [
|
|
5217
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5218
|
+
dynamicCallData(encodeShortString("nft_pp_contract")),
|
|
5219
|
+
dynamicCallData(pfpContract),
|
|
5220
|
+
dynamicCallData("0")
|
|
5221
|
+
]
|
|
5222
|
+
},
|
|
5223
|
+
{
|
|
5224
|
+
execution: execution({}),
|
|
5225
|
+
to: dynamicFelt(identityContract),
|
|
5226
|
+
selector: dynamicFelt(getSelectorFromName("get_extended_verifier_data")),
|
|
5227
|
+
calldata: [
|
|
5228
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5229
|
+
dynamicCallData(encodeShortString("nft_pp_id")),
|
|
5230
|
+
dynamicCallData("2"),
|
|
5231
|
+
dynamicCallData(pfpContract),
|
|
5232
|
+
dynamicCallData("0")
|
|
5233
|
+
]
|
|
5234
|
+
},
|
|
5235
|
+
{
|
|
5236
|
+
execution: execution(void 0, void 0, [6, 0, 0]),
|
|
5237
|
+
to: dynamicFelt(void 0, [6, 0]),
|
|
5238
|
+
selector: dynamicFelt(getSelectorFromName("tokenURI")),
|
|
5239
|
+
calldata: [dynamicCallData(void 0, [7, 1]), dynamicCallData(void 0, [7, 2])]
|
|
5240
|
+
}
|
|
5241
|
+
];
|
|
5242
|
+
initialCalldata.push(...calls);
|
|
5243
|
+
fallbackCalldata.push(...calls);
|
|
5244
|
+
const data = await this.executeStarkProfile(
|
|
5245
|
+
provider,
|
|
5246
|
+
multicallAddress,
|
|
5247
|
+
"aggregate",
|
|
5248
|
+
initialCalldata,
|
|
5249
|
+
fallbackCalldata
|
|
5250
|
+
);
|
|
5264
5251
|
if (Array.isArray(data)) {
|
|
5265
5252
|
const size = parseInt(data[0], 16);
|
|
5266
5253
|
const finalArray = [];
|
|
@@ -5300,6 +5287,25 @@ var StarknetId = class _StarknetId {
|
|
|
5300
5287
|
throw Error("Could not get user stark profile data from address");
|
|
5301
5288
|
}
|
|
5302
5289
|
}
|
|
5290
|
+
static async executeStarkProfile(provider, contract, functionName, initialCalldata, fallbackCalldata) {
|
|
5291
|
+
try {
|
|
5292
|
+
return await provider.callContract({
|
|
5293
|
+
contractAddress: contract,
|
|
5294
|
+
entrypoint: functionName,
|
|
5295
|
+
calldata: CallData.compile({
|
|
5296
|
+
calls: initialCalldata
|
|
5297
|
+
})
|
|
5298
|
+
});
|
|
5299
|
+
} catch (initialError) {
|
|
5300
|
+
return await provider.callContract({
|
|
5301
|
+
contractAddress: contract,
|
|
5302
|
+
entrypoint: functionName,
|
|
5303
|
+
calldata: CallData.compile({
|
|
5304
|
+
calls: fallbackCalldata
|
|
5305
|
+
})
|
|
5306
|
+
});
|
|
5307
|
+
}
|
|
5308
|
+
}
|
|
5303
5309
|
};
|
|
5304
5310
|
|
|
5305
5311
|
// src/provider/extensions/default.ts
|
|
@@ -5701,7 +5707,7 @@ var Signer = class {
|
|
|
5701
5707
|
async signTransaction(transactions, details) {
|
|
5702
5708
|
const compiledCalldata = getExecuteCalldata(transactions, details.cairoVersion);
|
|
5703
5709
|
let msgHash;
|
|
5704
|
-
if (Object.values(
|
|
5710
|
+
if (Object.values(api_exports.ETransactionVersion2).includes(details.version)) {
|
|
5705
5711
|
const det = details;
|
|
5706
5712
|
msgHash = calculateInvokeTransactionHash2({
|
|
5707
5713
|
...det,
|
|
@@ -5709,7 +5715,7 @@ var Signer = class {
|
|
|
5709
5715
|
compiledCalldata,
|
|
5710
5716
|
version: det.version
|
|
5711
5717
|
});
|
|
5712
|
-
} else if (Object.values(
|
|
5718
|
+
} else if (Object.values(api_exports.ETransactionVersion3).includes(details.version)) {
|
|
5713
5719
|
const det = details;
|
|
5714
5720
|
msgHash = calculateInvokeTransactionHash2({
|
|
5715
5721
|
...det,
|
|
@@ -5727,7 +5733,7 @@ var Signer = class {
|
|
|
5727
5733
|
async signDeployAccountTransaction(details) {
|
|
5728
5734
|
const compiledConstructorCalldata = CallData.compile(details.constructorCalldata);
|
|
5729
5735
|
let msgHash;
|
|
5730
|
-
if (Object.values(
|
|
5736
|
+
if (Object.values(api_exports.ETransactionVersion2).includes(details.version)) {
|
|
5731
5737
|
const det = details;
|
|
5732
5738
|
msgHash = calculateDeployAccountTransactionHash3({
|
|
5733
5739
|
...det,
|
|
@@ -5735,7 +5741,7 @@ var Signer = class {
|
|
|
5735
5741
|
constructorCalldata: compiledConstructorCalldata,
|
|
5736
5742
|
version: det.version
|
|
5737
5743
|
});
|
|
5738
|
-
} else if (Object.values(
|
|
5744
|
+
} else if (Object.values(api_exports.ETransactionVersion3).includes(details.version)) {
|
|
5739
5745
|
const det = details;
|
|
5740
5746
|
msgHash = calculateDeployAccountTransactionHash3({
|
|
5741
5747
|
...det,
|
|
@@ -5752,13 +5758,13 @@ var Signer = class {
|
|
|
5752
5758
|
}
|
|
5753
5759
|
async signDeclareTransaction(details) {
|
|
5754
5760
|
let msgHash;
|
|
5755
|
-
if (Object.values(
|
|
5761
|
+
if (Object.values(api_exports.ETransactionVersion2).includes(details.version)) {
|
|
5756
5762
|
const det = details;
|
|
5757
5763
|
msgHash = calculateDeclareTransactionHash3({
|
|
5758
5764
|
...det,
|
|
5759
5765
|
version: det.version
|
|
5760
5766
|
});
|
|
5761
|
-
} else if (Object.values(
|
|
5767
|
+
} else if (Object.values(api_exports.ETransactionVersion3).includes(details.version)) {
|
|
5762
5768
|
const det = details;
|
|
5763
5769
|
msgHash = calculateDeclareTransactionHash3({
|
|
5764
5770
|
...det,
|
|
@@ -5825,7 +5831,7 @@ var EthSigner = class {
|
|
|
5825
5831
|
async signTransaction(transactions, details) {
|
|
5826
5832
|
const compiledCalldata = getExecuteCalldata(transactions, details.cairoVersion);
|
|
5827
5833
|
let msgHash;
|
|
5828
|
-
if (Object.values(
|
|
5834
|
+
if (Object.values(api_exports.ETransactionVersion2).includes(details.version)) {
|
|
5829
5835
|
const det = details;
|
|
5830
5836
|
msgHash = calculateInvokeTransactionHash2({
|
|
5831
5837
|
...det,
|
|
@@ -5833,7 +5839,7 @@ var EthSigner = class {
|
|
|
5833
5839
|
compiledCalldata,
|
|
5834
5840
|
version: det.version
|
|
5835
5841
|
});
|
|
5836
|
-
} else if (Object.values(
|
|
5842
|
+
} else if (Object.values(api_exports.ETransactionVersion3).includes(details.version)) {
|
|
5837
5843
|
const det = details;
|
|
5838
5844
|
msgHash = calculateInvokeTransactionHash2({
|
|
5839
5845
|
...det,
|
|
@@ -5855,7 +5861,7 @@ var EthSigner = class {
|
|
|
5855
5861
|
async signDeployAccountTransaction(details) {
|
|
5856
5862
|
const compiledConstructorCalldata = CallData.compile(details.constructorCalldata);
|
|
5857
5863
|
let msgHash;
|
|
5858
|
-
if (Object.values(
|
|
5864
|
+
if (Object.values(api_exports.ETransactionVersion2).includes(details.version)) {
|
|
5859
5865
|
const det = details;
|
|
5860
5866
|
msgHash = calculateDeployAccountTransactionHash3({
|
|
5861
5867
|
...det,
|
|
@@ -5863,7 +5869,7 @@ var EthSigner = class {
|
|
|
5863
5869
|
constructorCalldata: compiledConstructorCalldata,
|
|
5864
5870
|
version: det.version
|
|
5865
5871
|
});
|
|
5866
|
-
} else if (Object.values(
|
|
5872
|
+
} else if (Object.values(api_exports.ETransactionVersion3).includes(details.version)) {
|
|
5867
5873
|
const det = details;
|
|
5868
5874
|
msgHash = calculateDeployAccountTransactionHash3({
|
|
5869
5875
|
...det,
|
|
@@ -5884,13 +5890,13 @@ var EthSigner = class {
|
|
|
5884
5890
|
}
|
|
5885
5891
|
async signDeclareTransaction(details) {
|
|
5886
5892
|
let msgHash;
|
|
5887
|
-
if (Object.values(
|
|
5893
|
+
if (Object.values(api_exports.ETransactionVersion2).includes(details.version)) {
|
|
5888
5894
|
const det = details;
|
|
5889
5895
|
msgHash = calculateDeclareTransactionHash3({
|
|
5890
5896
|
...det,
|
|
5891
5897
|
version: det.version
|
|
5892
5898
|
});
|
|
5893
|
-
} else if (Object.values(
|
|
5899
|
+
} else if (Object.values(api_exports.ETransactionVersion3).includes(details.version)) {
|
|
5894
5900
|
const det = details;
|
|
5895
5901
|
msgHash = calculateDeclareTransactionHash3({
|
|
5896
5902
|
...det,
|
|
@@ -5954,7 +5960,7 @@ var Account = class extends RpcProvider2 {
|
|
|
5954
5960
|
address;
|
|
5955
5961
|
cairoVersion;
|
|
5956
5962
|
transactionVersion;
|
|
5957
|
-
constructor(providerOrOptions, address, pkOrSigner, cairoVersion, transactionVersion =
|
|
5963
|
+
constructor(providerOrOptions, address, pkOrSigner, cairoVersion, transactionVersion = api_exports.ETransactionVersion.V2) {
|
|
5958
5964
|
super(providerOrOptions);
|
|
5959
5965
|
this.address = address.toLowerCase();
|
|
5960
5966
|
this.signer = isString(pkOrSigner) || pkOrSigner instanceof Uint8Array ? new Signer(pkOrSigner) : pkOrSigner;
|
|
@@ -5965,11 +5971,11 @@ var Account = class extends RpcProvider2 {
|
|
|
5965
5971
|
}
|
|
5966
5972
|
// provided version or contract based preferred transactionVersion
|
|
5967
5973
|
getPreferredVersion(type12, type3) {
|
|
5968
|
-
if (this.transactionVersion ===
|
|
5974
|
+
if (this.transactionVersion === api_exports.ETransactionVersion.V3)
|
|
5969
5975
|
return type3;
|
|
5970
|
-
if (this.transactionVersion ===
|
|
5976
|
+
if (this.transactionVersion === api_exports.ETransactionVersion.V2)
|
|
5971
5977
|
return type12;
|
|
5972
|
-
return
|
|
5978
|
+
return api_exports.ETransactionVersion.V3;
|
|
5973
5979
|
}
|
|
5974
5980
|
async getNonce(blockIdentifier) {
|
|
5975
5981
|
return super.getNonceForAddress(this.address, blockIdentifier);
|
|
@@ -5982,7 +5988,7 @@ var Account = class extends RpcProvider2 {
|
|
|
5982
5988
|
}
|
|
5983
5989
|
}
|
|
5984
5990
|
/**
|
|
5985
|
-
* Retrieves the Cairo version from the network and sets `cairoVersion` if not already set in the constructor
|
|
5991
|
+
* Retrieves the Cairo version from the network and sets `cairoVersion` if not already set in the constructor.
|
|
5986
5992
|
* @param classHash if provided detects Cairo version from classHash, otherwise from the account address
|
|
5987
5993
|
*/
|
|
5988
5994
|
async getCairoVersion(classHash) {
|
|
@@ -6005,7 +6011,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6005
6011
|
const transactions = Array.isArray(calls) ? calls : [calls];
|
|
6006
6012
|
const nonce = toBigInt(providedNonce ?? await this.getNonce());
|
|
6007
6013
|
const version = toTransactionVersion(
|
|
6008
|
-
this.getPreferredVersion(
|
|
6014
|
+
this.getPreferredVersion(api_exports.ETransactionVersion.F1, api_exports.ETransactionVersion.F3),
|
|
6009
6015
|
toFeeVersion(providedVersion)
|
|
6010
6016
|
);
|
|
6011
6017
|
const chainId = await this.getChainId();
|
|
@@ -6036,7 +6042,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6036
6042
|
} = details;
|
|
6037
6043
|
const nonce = toBigInt(providedNonce ?? await this.getNonce());
|
|
6038
6044
|
const version = toTransactionVersion(
|
|
6039
|
-
!isSierra(payload.contract) ?
|
|
6045
|
+
!isSierra(payload.contract) ? api_exports.ETransactionVersion.F1 : this.getPreferredVersion(api_exports.ETransactionVersion.F2, api_exports.ETransactionVersion.F3),
|
|
6040
6046
|
toFeeVersion(providedVersion)
|
|
6041
6047
|
);
|
|
6042
6048
|
const chainId = await this.getChainId();
|
|
@@ -6066,7 +6072,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6066
6072
|
}, details = {}) {
|
|
6067
6073
|
const { blockIdentifier, version: providedVersion, skipValidate = true } = details;
|
|
6068
6074
|
const version = toTransactionVersion(
|
|
6069
|
-
this.getPreferredVersion(
|
|
6075
|
+
this.getPreferredVersion(api_exports.ETransactionVersion.F1, api_exports.ETransactionVersion.F3),
|
|
6070
6076
|
toFeeVersion(providedVersion)
|
|
6071
6077
|
);
|
|
6072
6078
|
const nonce = ZERO;
|
|
@@ -6102,10 +6108,10 @@ var Account = class extends RpcProvider2 {
|
|
|
6102
6108
|
const accountInvocations = await this.accountInvocationsFactory(invocations, {
|
|
6103
6109
|
...v3Details(details),
|
|
6104
6110
|
versions: [
|
|
6105
|
-
|
|
6111
|
+
api_exports.ETransactionVersion.F1,
|
|
6106
6112
|
// non-sierra
|
|
6107
6113
|
toTransactionVersion(
|
|
6108
|
-
this.getPreferredVersion(
|
|
6114
|
+
this.getPreferredVersion(api_exports.ETransactionVersion.F2, api_exports.ETransactionVersion.F3),
|
|
6109
6115
|
version
|
|
6110
6116
|
)
|
|
6111
6117
|
// sierra
|
|
@@ -6124,10 +6130,10 @@ var Account = class extends RpcProvider2 {
|
|
|
6124
6130
|
const accountInvocations = await this.accountInvocationsFactory(invocations, {
|
|
6125
6131
|
...v3Details(details),
|
|
6126
6132
|
versions: [
|
|
6127
|
-
|
|
6133
|
+
api_exports.ETransactionVersion.V1,
|
|
6128
6134
|
// non-sierra
|
|
6129
6135
|
toTransactionVersion(
|
|
6130
|
-
this.getPreferredVersion(
|
|
6136
|
+
this.getPreferredVersion(api_exports.ETransactionVersion.V2, api_exports.ETransactionVersion.V3),
|
|
6131
6137
|
version
|
|
6132
6138
|
)
|
|
6133
6139
|
],
|
|
@@ -6146,7 +6152,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6146
6152
|
const calls = Array.isArray(transactions) ? transactions : [transactions];
|
|
6147
6153
|
const nonce = toBigInt(details.nonce ?? await this.getNonce());
|
|
6148
6154
|
const version = toTransactionVersion(
|
|
6149
|
-
this.getPreferredVersion(
|
|
6155
|
+
this.getPreferredVersion(api_exports.ETransactionVersion.V1, api_exports.ETransactionVersion.V3),
|
|
6150
6156
|
// TODO: does this depend on cairo version ?
|
|
6151
6157
|
details.version
|
|
6152
6158
|
);
|
|
@@ -6204,7 +6210,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6204
6210
|
const declareContractPayload = extractContractHashes(payload);
|
|
6205
6211
|
const { nonce, version: providedVersion } = details;
|
|
6206
6212
|
const version = toTransactionVersion(
|
|
6207
|
-
!isSierra(payload.contract) ?
|
|
6213
|
+
!isSierra(payload.contract) ? api_exports.ETransactionVersion.V1 : this.getPreferredVersion(api_exports.ETransactionVersion.V2, api_exports.ETransactionVersion.V3),
|
|
6208
6214
|
providedVersion
|
|
6209
6215
|
);
|
|
6210
6216
|
const estimate = await this.getUniversalSuggestedFee(
|
|
@@ -6268,7 +6274,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6268
6274
|
contractAddress: providedContractAddress
|
|
6269
6275
|
}, details = {}) {
|
|
6270
6276
|
const version = toTransactionVersion(
|
|
6271
|
-
this.getPreferredVersion(
|
|
6277
|
+
this.getPreferredVersion(api_exports.ETransactionVersion.V1, api_exports.ETransactionVersion.V3),
|
|
6272
6278
|
details.version
|
|
6273
6279
|
);
|
|
6274
6280
|
const nonce = ZERO;
|
|
@@ -6317,32 +6323,64 @@ var Account = class extends RpcProvider2 {
|
|
|
6317
6323
|
async hashMessage(typedData) {
|
|
6318
6324
|
return getMessageHash(typedData, this.address);
|
|
6319
6325
|
}
|
|
6320
|
-
async verifyMessageHash(hash, signature) {
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6326
|
+
async verifyMessageHash(hash, signature, signatureVerificationFunctionName, signatureVerificationResponse) {
|
|
6327
|
+
const knownSigVerificationFName = signatureVerificationFunctionName ? [signatureVerificationFunctionName] : ["isValidSignature", "is_valid_signature"];
|
|
6328
|
+
const knownSignatureResponse = signatureVerificationResponse || {
|
|
6329
|
+
okResponse: [
|
|
6330
|
+
// any non-nok response is true
|
|
6331
|
+
],
|
|
6332
|
+
nokResponse: [
|
|
6333
|
+
"0x0",
|
|
6334
|
+
// Devnet
|
|
6335
|
+
"0x00"
|
|
6336
|
+
// OpenZeppelin 0.7.0 to 0.9.0 invalid signature
|
|
6337
|
+
],
|
|
6338
|
+
error: [
|
|
6339
|
+
"argent/invalid-signature",
|
|
6340
|
+
// ArgentX 0.3.0 to 0.3.1
|
|
6341
|
+
"is invalid, with respect to the public key",
|
|
6342
|
+
// OpenZeppelin until 0.6.1, Braavos 0.0.11
|
|
6343
|
+
"INVALID_SIG"
|
|
6344
|
+
// Braavos 1.0.0
|
|
6345
|
+
]
|
|
6346
|
+
};
|
|
6347
|
+
let error;
|
|
6348
|
+
for (const SigVerificationFName of knownSigVerificationFName) {
|
|
6349
|
+
try {
|
|
6350
|
+
const resp = await this.callContract({
|
|
6351
|
+
contractAddress: this.address,
|
|
6352
|
+
entrypoint: SigVerificationFName,
|
|
6353
|
+
calldata: CallData.compile({
|
|
6354
|
+
hash: toBigInt(hash).toString(),
|
|
6355
|
+
signature: formatSignature(signature)
|
|
6356
|
+
})
|
|
6357
|
+
});
|
|
6358
|
+
if (knownSignatureResponse.nokResponse.includes(resp[0].toString())) {
|
|
6359
|
+
return false;
|
|
6360
|
+
}
|
|
6361
|
+
if (knownSignatureResponse.okResponse.length === 0 || knownSignatureResponse.okResponse.includes(resp[0].toString())) {
|
|
6362
|
+
return true;
|
|
6363
|
+
}
|
|
6364
|
+
throw Error("signatureVerificationResponse Error: response is not part of known responses");
|
|
6365
|
+
} catch (err) {
|
|
6366
|
+
if (knownSignatureResponse.error.some(
|
|
6367
|
+
(errMessage) => err.message.includes(errMessage)
|
|
6368
|
+
)) {
|
|
6369
|
+
return false;
|
|
6370
|
+
}
|
|
6371
|
+
error = err;
|
|
6339
6372
|
}
|
|
6340
|
-
throw Error(`Signature verification request is rejected by the network: ${err}`);
|
|
6341
6373
|
}
|
|
6374
|
+
throw Error(`Signature verification Error: ${error}`);
|
|
6342
6375
|
}
|
|
6343
|
-
async verifyMessage(typedData, signature) {
|
|
6376
|
+
async verifyMessage(typedData, signature, signatureVerificationFunctionName, signatureVerificationResponse) {
|
|
6344
6377
|
const hash = await this.hashMessage(typedData);
|
|
6345
|
-
return this.verifyMessageHash(
|
|
6378
|
+
return this.verifyMessageHash(
|
|
6379
|
+
hash,
|
|
6380
|
+
signature,
|
|
6381
|
+
signatureVerificationFunctionName,
|
|
6382
|
+
signatureVerificationResponse
|
|
6383
|
+
);
|
|
6346
6384
|
}
|
|
6347
6385
|
/*
|
|
6348
6386
|
* Support methods
|
|
@@ -6350,7 +6388,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6350
6388
|
async getUniversalSuggestedFee(version, { type, payload }, details) {
|
|
6351
6389
|
let maxFee = 0;
|
|
6352
6390
|
let resourceBounds = estimateFeeToBounds(ZERO);
|
|
6353
|
-
if (version ===
|
|
6391
|
+
if (version === api_exports.ETransactionVersion.V3) {
|
|
6354
6392
|
resourceBounds = details.resourceBounds ?? (await this.getSuggestedFee({ type, payload }, details)).resourceBounds;
|
|
6355
6393
|
} else {
|
|
6356
6394
|
maxFee = details.maxFee ?? (await this.getSuggestedFee({ type, payload }, details)).suggestedMaxFee;
|
|
@@ -6403,7 +6441,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6403
6441
|
async buildDeclarePayload(payload, details) {
|
|
6404
6442
|
const { classHash, contract, compiledClassHash } = extractContractHashes(payload);
|
|
6405
6443
|
const compressedCompiledContract = parseContract(contract);
|
|
6406
|
-
if (typeof compiledClassHash === "undefined" && (details.version ===
|
|
6444
|
+
if (typeof compiledClassHash === "undefined" && (details.version === api_exports.ETransactionVersion3.F3 || details.version === api_exports.ETransactionVersion3.V3)) {
|
|
6407
6445
|
throw Error("V3 Transaction work with Cairo1 Contracts and require compiledClassHash");
|
|
6408
6446
|
}
|
|
6409
6447
|
const signature = !details.skipValidate ? await this.signer.signDeclareTransaction({
|
|
@@ -6556,7 +6594,6 @@ var AccountInterface = class extends ProviderInterface {
|
|
|
6556
6594
|
var connect_exports = {};
|
|
6557
6595
|
__export(connect_exports, {
|
|
6558
6596
|
addDeclareTransaction: () => addDeclareTransaction,
|
|
6559
|
-
addDeployAccountTransaction: () => addDeployAccountTransaction,
|
|
6560
6597
|
addInvokeTransaction: () => addInvokeTransaction,
|
|
6561
6598
|
addStarknetChain: () => addStarknetChain,
|
|
6562
6599
|
deploymentData: () => deploymentData,
|
|
@@ -6570,11 +6607,11 @@ __export(connect_exports, {
|
|
|
6570
6607
|
switchStarknetChain: () => switchStarknetChain,
|
|
6571
6608
|
watchAsset: () => watchAsset
|
|
6572
6609
|
});
|
|
6573
|
-
function requestAccounts(swo,
|
|
6610
|
+
function requestAccounts(swo, silent_mode = false) {
|
|
6574
6611
|
return swo.request({
|
|
6575
6612
|
type: "wallet_requestAccounts",
|
|
6576
6613
|
params: {
|
|
6577
|
-
|
|
6614
|
+
silent_mode
|
|
6578
6615
|
}
|
|
6579
6616
|
});
|
|
6580
6617
|
}
|
|
@@ -6609,30 +6646,24 @@ function deploymentData(swo) {
|
|
|
6609
6646
|
}
|
|
6610
6647
|
function addInvokeTransaction(swo, params) {
|
|
6611
6648
|
return swo.request({
|
|
6612
|
-
type: "
|
|
6649
|
+
type: "wallet_addInvokeTransaction",
|
|
6613
6650
|
params
|
|
6614
6651
|
});
|
|
6615
6652
|
}
|
|
6616
6653
|
function addDeclareTransaction(swo, params) {
|
|
6617
6654
|
return swo.request({
|
|
6618
|
-
type: "
|
|
6619
|
-
params
|
|
6620
|
-
});
|
|
6621
|
-
}
|
|
6622
|
-
function addDeployAccountTransaction(swo, params) {
|
|
6623
|
-
return swo.request({
|
|
6624
|
-
type: "starknet_addDeployAccountTransaction",
|
|
6655
|
+
type: "wallet_addDeclareTransaction",
|
|
6625
6656
|
params
|
|
6626
6657
|
});
|
|
6627
6658
|
}
|
|
6628
6659
|
function signMessage(swo, typedData) {
|
|
6629
6660
|
return swo.request({
|
|
6630
|
-
type: "
|
|
6661
|
+
type: "wallet_signTypedData",
|
|
6631
6662
|
params: typedData
|
|
6632
6663
|
});
|
|
6633
6664
|
}
|
|
6634
6665
|
function supportedSpecs(swo) {
|
|
6635
|
-
return swo.request({ type: "
|
|
6666
|
+
return swo.request({ type: "wallet_supportedSpecs" });
|
|
6636
6667
|
}
|
|
6637
6668
|
function onAccountChange(swo, callback) {
|
|
6638
6669
|
swo.on("accountsChanged", callback);
|
|
@@ -6661,7 +6692,7 @@ var WalletAccount = class extends Account {
|
|
|
6661
6692
|
walletProvider.request({
|
|
6662
6693
|
type: "wallet_requestAccounts",
|
|
6663
6694
|
params: {
|
|
6664
|
-
|
|
6695
|
+
silent_mode: false
|
|
6665
6696
|
}
|
|
6666
6697
|
}).then((res) => {
|
|
6667
6698
|
this.address = res[0].toLowerCase();
|
|
@@ -6702,7 +6733,7 @@ var WalletAccount = class extends Account {
|
|
|
6702
6733
|
const { contractAddress, entrypoint, calldata } = it;
|
|
6703
6734
|
return {
|
|
6704
6735
|
contract_address: contractAddress,
|
|
6705
|
-
entrypoint,
|
|
6736
|
+
entry_point: entrypoint,
|
|
6706
6737
|
calldata
|
|
6707
6738
|
};
|
|
6708
6739
|
});
|
|
@@ -6735,14 +6766,6 @@ var WalletAccount = class extends Account {
|
|
|
6735
6766
|
contract_address: addresses
|
|
6736
6767
|
};
|
|
6737
6768
|
}
|
|
6738
|
-
deployAccount(payload) {
|
|
6739
|
-
const params = {
|
|
6740
|
-
contract_address_salt: payload.addressSalt?.toString() || "0",
|
|
6741
|
-
constructor_calldata: payload.constructorCalldata ? CallData.compile(payload.constructorCalldata) : [],
|
|
6742
|
-
class_hash: payload.classHash
|
|
6743
|
-
};
|
|
6744
|
-
return addDeployAccountTransaction(this.walletProvider, params);
|
|
6745
|
-
}
|
|
6746
6769
|
signMessage(typedData) {
|
|
6747
6770
|
return signMessage(this.walletProvider, typedData);
|
|
6748
6771
|
}
|
|
@@ -7233,7 +7256,6 @@ export {
|
|
|
7233
7256
|
ReceiptTx,
|
|
7234
7257
|
RpcChannel2 as RpcChannel,
|
|
7235
7258
|
RpcProvider2 as RpcProvider,
|
|
7236
|
-
SIMULATION_FLAG,
|
|
7237
7259
|
Signer,
|
|
7238
7260
|
SignerInterface,
|
|
7239
7261
|
TransactionExecutionStatus,
|
|
@@ -7277,6 +7299,7 @@ export {
|
|
|
7277
7299
|
merkle_exports as merkle,
|
|
7278
7300
|
num_exports as num,
|
|
7279
7301
|
number,
|
|
7302
|
+
parseCalldataField,
|
|
7280
7303
|
parseUDCEvent,
|
|
7281
7304
|
provider_exports as provider,
|
|
7282
7305
|
selector_exports as selector,
|