starknet 10.0.3 → 10.1.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 +12 -0
- package/dist/index.d.ts +229 -215
- package/dist/index.global.js +168 -56
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +84 -60
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +82 -59
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -99,12 +99,13 @@ __export(index_exports, {
|
|
|
99
99
|
Provider: () => RpcProvider,
|
|
100
100
|
ProviderInterface: () => ProviderInterface,
|
|
101
101
|
RPC: () => api_exports,
|
|
102
|
-
|
|
102
|
+
RPC0102: () => rpc_0_10_2_exports,
|
|
103
|
+
RPC0103: () => rpc_0_10_3_exports,
|
|
103
104
|
RPC09: () => rpc_0_9_0_exports,
|
|
104
105
|
RPCResponseParser: () => RPCResponseParser,
|
|
105
106
|
ReceiptTx: () => ReceiptTx,
|
|
106
107
|
ResponseParser: () => ResponseParser,
|
|
107
|
-
RpcChannel: () =>
|
|
108
|
+
RpcChannel: () => RpcChannel3,
|
|
108
109
|
RpcError: () => RpcError,
|
|
109
110
|
RpcProvider: () => RpcProvider,
|
|
110
111
|
Signer: () => Signer,
|
|
@@ -250,8 +251,8 @@ __export(constants_exports, {
|
|
|
250
251
|
var api_exports = {};
|
|
251
252
|
__export(api_exports, {
|
|
252
253
|
JRPC: () => jsonrpc_exports,
|
|
253
|
-
PAYMASTER_API: () =>
|
|
254
|
-
|
|
254
|
+
PAYMASTER_API: () => import_starknet_types_0103.PAYMASTER_API,
|
|
255
|
+
RPCSPEC0103: () => RPCSPEC0103,
|
|
255
256
|
RPCSPEC09: () => RPCSPEC09
|
|
256
257
|
});
|
|
257
258
|
|
|
@@ -260,12 +261,12 @@ var jsonrpc_exports = {};
|
|
|
260
261
|
|
|
261
262
|
// src/types/api/index.ts
|
|
262
263
|
var RPCSPEC09 = __toESM(require("@starknet-io/starknet-types-09"));
|
|
263
|
-
var
|
|
264
|
-
var
|
|
264
|
+
var RPCSPEC0103 = __toESM(require("@starknet-io/starknet-types-0103"));
|
|
265
|
+
var import_starknet_types_0103 = require("@starknet-io/starknet-types-0103");
|
|
265
266
|
|
|
266
267
|
// src/types/api/rpc.ts
|
|
267
268
|
var rpc_exports = {};
|
|
268
|
-
__reExport(rpc_exports, require("@starknet-io/starknet-types-
|
|
269
|
+
__reExport(rpc_exports, require("@starknet-io/starknet-types-0103"));
|
|
269
270
|
|
|
270
271
|
// src/types/api/index.ts
|
|
271
272
|
__reExport(api_exports, rpc_exports);
|
|
@@ -274,19 +275,19 @@ __reExport(api_exports, rpc_exports);
|
|
|
274
275
|
var { ETransactionVersion } = RPCSPEC09;
|
|
275
276
|
var { ETransactionVersion2 } = RPCSPEC09;
|
|
276
277
|
var { ETransactionVersion3 } = RPCSPEC09;
|
|
277
|
-
var { EDataAvailabilityMode } =
|
|
278
|
-
var { EDAMode } =
|
|
278
|
+
var { EDataAvailabilityMode } = RPCSPEC0103;
|
|
279
|
+
var { EDAMode } = RPCSPEC0103;
|
|
279
280
|
function isRPC08Plus_ResourceBounds(entry) {
|
|
280
281
|
return "l1_data_gas" in entry;
|
|
281
282
|
}
|
|
282
283
|
function isRPC08Plus_ResourceBoundsBN(entry) {
|
|
283
284
|
return "l1_data_gas" in entry;
|
|
284
285
|
}
|
|
285
|
-
var { ETxnResponseFlag } =
|
|
286
|
-
var { ETraceFlag } =
|
|
287
|
-
var { ESubscriptionTag } =
|
|
288
|
-
var { ETransactionStatus } =
|
|
289
|
-
var { ETransactionExecutionStatus } =
|
|
286
|
+
var { ETxnResponseFlag } = RPCSPEC0103;
|
|
287
|
+
var { ETraceFlag } = RPCSPEC0103;
|
|
288
|
+
var { ESubscriptionTag } = RPCSPEC0103;
|
|
289
|
+
var { ETransactionStatus } = RPCSPEC0103;
|
|
290
|
+
var { ETransactionExecutionStatus } = RPCSPEC0103;
|
|
290
291
|
var { ETransactionType: TransactionType } = RPCSPEC09;
|
|
291
292
|
var { EBlockStatus: BlockStatus } = RPCSPEC09;
|
|
292
293
|
var { ETransactionFinalityStatus: TransactionFinalityStatus } = RPCSPEC09;
|
|
@@ -501,9 +502,11 @@ var _SupportedRpcVersion = {
|
|
|
501
502
|
"0.9.0": "0.9.0",
|
|
502
503
|
"0.10.0": "0.10.0",
|
|
503
504
|
"0.10.2": "0.10.2",
|
|
505
|
+
"0.10.3": "0.10.3",
|
|
504
506
|
v0_9_0: "0.9.0",
|
|
505
507
|
v0_10_0: "0.10.0",
|
|
506
|
-
v0_10_2: "0.10.2"
|
|
508
|
+
v0_10_2: "0.10.2",
|
|
509
|
+
v0_10_3: "0.10.3"
|
|
507
510
|
};
|
|
508
511
|
var DEFAULT_GLOBAL_CONFIG = {
|
|
509
512
|
rpcVersion: "0.10.0",
|
|
@@ -1323,31 +1326,6 @@ function addCompiledFlag(compiled) {
|
|
|
1323
1326
|
}
|
|
1324
1327
|
|
|
1325
1328
|
// src/utils/cairoDataTypes/felt.ts
|
|
1326
|
-
function CairoFelt(it) {
|
|
1327
|
-
if (isBigInt(it) || Number.isInteger(it)) {
|
|
1328
|
-
return it.toString();
|
|
1329
|
-
}
|
|
1330
|
-
if (isString(it)) {
|
|
1331
|
-
if (isHex(it)) {
|
|
1332
|
-
return BigInt(it).toString();
|
|
1333
|
-
}
|
|
1334
|
-
if (isText(it)) {
|
|
1335
|
-
if (!isShortString(it)) {
|
|
1336
|
-
throw new Error(
|
|
1337
|
-
`${it} is a long string > 31 chars. Please split it into an array of short strings.`
|
|
1338
|
-
);
|
|
1339
|
-
}
|
|
1340
|
-
return BigInt(encodeShortString(it)).toString();
|
|
1341
|
-
}
|
|
1342
|
-
if (isStringWholeNumber(it)) {
|
|
1343
|
-
return it;
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
if (isBoolean(it)) {
|
|
1347
|
-
return `${+it}`;
|
|
1348
|
-
}
|
|
1349
|
-
throw new Error(`${it} can't be computed by felt()`);
|
|
1350
|
-
}
|
|
1351
1329
|
var CairoFelt252 = class _CairoFelt252 {
|
|
1352
1330
|
/**
|
|
1353
1331
|
* byte representation of the felt252
|
|
@@ -1386,6 +1364,9 @@ var CairoFelt252 = class _CairoFelt252 {
|
|
|
1386
1364
|
toApiRequest() {
|
|
1387
1365
|
return addCompiledFlag([this.toHexString()]);
|
|
1388
1366
|
}
|
|
1367
|
+
static assertRange(val) {
|
|
1368
|
+
assert(val >= 0n && val < PRIME, `Value ${val} is out of felt252 range [0, ${PRIME})`);
|
|
1369
|
+
}
|
|
1389
1370
|
static validate(data) {
|
|
1390
1371
|
assert(data !== null, "null value is not allowed for felt252");
|
|
1391
1372
|
assert(data !== void 0, "undefined value is not allowed for felt252");
|
|
@@ -1395,7 +1376,7 @@ var CairoFelt252 = class _CairoFelt252 {
|
|
|
1395
1376
|
);
|
|
1396
1377
|
const value = _CairoFelt252.__processData(data);
|
|
1397
1378
|
const bn = uint8ArrayToBigInt(value);
|
|
1398
|
-
|
|
1379
|
+
_CairoFelt252.assertRange(bn);
|
|
1399
1380
|
}
|
|
1400
1381
|
static is(data) {
|
|
1401
1382
|
try {
|
|
@@ -1412,6 +1393,37 @@ var CairoFelt252 = class _CairoFelt252 {
|
|
|
1412
1393
|
return new _CairoFelt252(getNext(responseIterator));
|
|
1413
1394
|
}
|
|
1414
1395
|
};
|
|
1396
|
+
function CairoFelt(it) {
|
|
1397
|
+
if (isBigInt(it) || Number.isInteger(it)) {
|
|
1398
|
+
const val = BigInt(it);
|
|
1399
|
+
CairoFelt252.assertRange(val);
|
|
1400
|
+
return val.toString();
|
|
1401
|
+
}
|
|
1402
|
+
if (isString(it)) {
|
|
1403
|
+
if (isHex(it)) {
|
|
1404
|
+
const val = BigInt(it);
|
|
1405
|
+
CairoFelt252.assertRange(val);
|
|
1406
|
+
return val.toString();
|
|
1407
|
+
}
|
|
1408
|
+
if (isText(it)) {
|
|
1409
|
+
if (!isShortString(it)) {
|
|
1410
|
+
throw new Error(
|
|
1411
|
+
`${it} is a long string > 31 chars. Please split it into an array of short strings.`
|
|
1412
|
+
);
|
|
1413
|
+
}
|
|
1414
|
+
return BigInt(encodeShortString(it)).toString();
|
|
1415
|
+
}
|
|
1416
|
+
if (isStringWholeNumber(it)) {
|
|
1417
|
+
const val = BigInt(it);
|
|
1418
|
+
CairoFelt252.assertRange(val);
|
|
1419
|
+
return val.toString();
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
if (isBoolean(it)) {
|
|
1423
|
+
return `${+it}`;
|
|
1424
|
+
}
|
|
1425
|
+
throw new Error(`${it} can't be computed by felt()`);
|
|
1426
|
+
}
|
|
1415
1427
|
|
|
1416
1428
|
// src/utils/cairoDataTypes/uint256.ts
|
|
1417
1429
|
var UINT_128_MAX = (1n << 128n) - 1n;
|
|
@@ -6720,6 +6732,7 @@ var rpc_0_10_2_exports = {};
|
|
|
6720
6732
|
__export(rpc_0_10_2_exports, {
|
|
6721
6733
|
RpcChannel: () => RpcChannel2
|
|
6722
6734
|
});
|
|
6735
|
+
var RPC = __toESM(require("@starknet-io/starknet-types-0101"));
|
|
6723
6736
|
var RpcChannel2 = class {
|
|
6724
6737
|
id = "RPC0.10.2";
|
|
6725
6738
|
/**
|
|
@@ -6939,7 +6952,7 @@ var RpcChannel2 = class {
|
|
|
6939
6952
|
*/
|
|
6940
6953
|
getBlockWithTxs(blockIdentifier = this.blockIdentifier, options) {
|
|
6941
6954
|
const block_id = new Block(blockIdentifier).identifier;
|
|
6942
|
-
const response_flags = options?.includeProofFacts ? [
|
|
6955
|
+
const response_flags = options?.includeProofFacts ? [RPC.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
|
|
6943
6956
|
return this.fetchEndpoint("starknet_getBlockWithTxs", {
|
|
6944
6957
|
block_id,
|
|
6945
6958
|
...response_flags && { response_flags }
|
|
@@ -6953,7 +6966,7 @@ var RpcChannel2 = class {
|
|
|
6953
6966
|
*/
|
|
6954
6967
|
getBlockWithReceipts(blockIdentifier = this.blockIdentifier, options) {
|
|
6955
6968
|
const block_id = new Block(blockIdentifier).identifier;
|
|
6956
|
-
const response_flags = options?.includeProofFacts ? [
|
|
6969
|
+
const response_flags = options?.includeProofFacts ? [RPC.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
|
|
6957
6970
|
return this.fetchEndpoint("starknet_getBlockWithReceipts", {
|
|
6958
6971
|
block_id,
|
|
6959
6972
|
...response_flags && { response_flags }
|
|
@@ -6976,7 +6989,7 @@ var RpcChannel2 = class {
|
|
|
6976
6989
|
*/
|
|
6977
6990
|
getBlockTransactionsTraces(blockIdentifier = this.blockIdentifier, options) {
|
|
6978
6991
|
const block_id = new Block(blockIdentifier).identifier;
|
|
6979
|
-
const trace_flags = options?.returnInitialReads ? [
|
|
6992
|
+
const trace_flags = options?.returnInitialReads ? [RPC.ETraceFlag.RETURN_INITIAL_READS] : void 0;
|
|
6980
6993
|
return this.fetchEndpoint("starknet_traceBlockTransactions", {
|
|
6981
6994
|
block_id,
|
|
6982
6995
|
...trace_flags && { trace_flags }
|
|
@@ -6994,7 +7007,7 @@ var RpcChannel2 = class {
|
|
|
6994
7007
|
*/
|
|
6995
7008
|
getTransactionByHash(txHash, options) {
|
|
6996
7009
|
const transaction_hash = toHex(txHash);
|
|
6997
|
-
const response_flags = options?.includeProofFacts ? [
|
|
7010
|
+
const response_flags = options?.includeProofFacts ? [RPC.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
|
|
6998
7011
|
return this.fetchEndpoint("starknet_getTransactionByHash", {
|
|
6999
7012
|
transaction_hash,
|
|
7000
7013
|
...response_flags && { response_flags }
|
|
@@ -7009,7 +7022,7 @@ var RpcChannel2 = class {
|
|
|
7009
7022
|
*/
|
|
7010
7023
|
getTransactionByBlockIdAndIndex(blockIdentifier, index, options) {
|
|
7011
7024
|
const block_id = new Block(blockIdentifier).identifier;
|
|
7012
|
-
const response_flags = options?.includeProofFacts ? [
|
|
7025
|
+
const response_flags = options?.includeProofFacts ? [RPC.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
|
|
7013
7026
|
return this.fetchEndpoint("starknet_getTransactionByBlockIdAndIndex", {
|
|
7014
7027
|
block_id,
|
|
7015
7028
|
index,
|
|
@@ -7050,9 +7063,9 @@ var RpcChannel2 = class {
|
|
|
7050
7063
|
} = simulateTransactionOptions;
|
|
7051
7064
|
const block_id = new Block(blockIdentifier).identifier;
|
|
7052
7065
|
const simulationFlags = [];
|
|
7053
|
-
if (skipValidate) simulationFlags.push(
|
|
7054
|
-
if (skipFeeCharge) simulationFlags.push(
|
|
7055
|
-
const trace_flags = returnInitialReads ? [
|
|
7066
|
+
if (skipValidate) simulationFlags.push(RPC.ESimulationFlag.SKIP_VALIDATE);
|
|
7067
|
+
if (skipFeeCharge) simulationFlags.push(RPC.ESimulationFlag.SKIP_FEE_CHARGE);
|
|
7068
|
+
const trace_flags = returnInitialReads ? [RPC.ETraceFlag.RETURN_INITIAL_READS] : void 0;
|
|
7056
7069
|
return this.fetchEndpoint("starknet_simulateTransactions", {
|
|
7057
7070
|
block_id,
|
|
7058
7071
|
transactions: await Promise.all(invocations.map((it) => this.buildTransaction(it))),
|
|
@@ -7070,13 +7083,13 @@ var RpcChannel2 = class {
|
|
|
7070
7083
|
const errorStates = options?.errorStates ?? [];
|
|
7071
7084
|
const successStates = options?.successStates ?? [
|
|
7072
7085
|
// RPC.ETransactionExecutionStatus.SUCCEEDED, // UDC on SUCCEEDED + pre_confirmed had no proper events to parse UDC
|
|
7073
|
-
|
|
7074
|
-
|
|
7086
|
+
RPC.ETransactionFinalityStatus.ACCEPTED_ON_L2,
|
|
7087
|
+
RPC.ETransactionFinalityStatus.ACCEPTED_ON_L1
|
|
7075
7088
|
];
|
|
7076
7089
|
const errorMessages = {
|
|
7077
|
-
[
|
|
7078
|
-
[
|
|
7079
|
-
[
|
|
7090
|
+
[RPC.ETransactionStatus.RECEIVED]: SYSTEM_MESSAGES.txEvictedFromMempool,
|
|
7091
|
+
[RPC.ETransactionStatus.PRE_CONFIRMED]: SYSTEM_MESSAGES.consensusFailed,
|
|
7092
|
+
[RPC.ETransactionStatus.CANDIDATE]: SYSTEM_MESSAGES.txFailsBlockBuildingValidation
|
|
7080
7093
|
};
|
|
7081
7094
|
const txLife = [];
|
|
7082
7095
|
let txStatus;
|
|
@@ -7173,7 +7186,7 @@ var RpcChannel2 = class {
|
|
|
7173
7186
|
const { blockIdentifier = this.blockIdentifier, skipValidate = methodDefaults.skipValidate } = options;
|
|
7174
7187
|
const block_id = new Block(blockIdentifier).identifier;
|
|
7175
7188
|
const flags = {
|
|
7176
|
-
simulation_flags: skipValidate ? [
|
|
7189
|
+
simulation_flags: skipValidate ? [RPC.ESimulationFlag.SKIP_VALIDATE] : []
|
|
7177
7190
|
};
|
|
7178
7191
|
return this.fetchEndpoint("starknet_estimateFee", {
|
|
7179
7192
|
request: await Promise.all(invocations.map((it) => this.buildTransaction(it, "fee"))),
|
|
@@ -7287,7 +7300,7 @@ var RpcChannel2 = class {
|
|
|
7287
7300
|
};
|
|
7288
7301
|
if (invocation.type === api_exports.ETransactionType.INVOKE) {
|
|
7289
7302
|
const btx = {
|
|
7290
|
-
type:
|
|
7303
|
+
type: RPC.ETransactionType.INVOKE,
|
|
7291
7304
|
sender_address: invocation.contractAddress,
|
|
7292
7305
|
calldata: CallData.toHex(invocation.calldata),
|
|
7293
7306
|
...details,
|
|
@@ -7329,6 +7342,16 @@ var RpcChannel2 = class {
|
|
|
7329
7342
|
}
|
|
7330
7343
|
};
|
|
7331
7344
|
|
|
7345
|
+
// src/channel/rpc_0_10_3.ts
|
|
7346
|
+
var rpc_0_10_3_exports = {};
|
|
7347
|
+
__export(rpc_0_10_3_exports, {
|
|
7348
|
+
RpcChannel: () => RpcChannel3
|
|
7349
|
+
});
|
|
7350
|
+
var RpcChannel3 = class extends RpcChannel2 {
|
|
7351
|
+
id = "RPC0.10.3";
|
|
7352
|
+
channelSpecVersion = _SupportedRpcVersion.v0_10_3;
|
|
7353
|
+
};
|
|
7354
|
+
|
|
7332
7355
|
// src/utils/eventEmitter.ts
|
|
7333
7356
|
var EventEmitter = class {
|
|
7334
7357
|
listeners = {};
|
|
@@ -9600,12 +9623,12 @@ var RpcProvider = class {
|
|
|
9600
9623
|
if (isVersion("0.9", options.specVersion)) {
|
|
9601
9624
|
this.channel = new rpc_0_9_0_exports.RpcChannel({ ...options, waitMode: false });
|
|
9602
9625
|
} else if (isVersion("0.10", options.specVersion)) {
|
|
9603
|
-
this.channel = new
|
|
9626
|
+
this.channel = new rpc_0_10_3_exports.RpcChannel({ ...options, waitMode: false });
|
|
9604
9627
|
} else throw new Error(`unsupported channel for spec version: ${options.specVersion}`);
|
|
9605
9628
|
} else if (isVersion("0.9", config.get("rpcVersion"))) {
|
|
9606
9629
|
this.channel = new rpc_0_9_0_exports.RpcChannel({ ...options, waitMode: false });
|
|
9607
9630
|
} else if (isVersion("0.10", config.get("rpcVersion"))) {
|
|
9608
|
-
this.channel = new
|
|
9631
|
+
this.channel = new rpc_0_10_3_exports.RpcChannel({ ...options, waitMode: false });
|
|
9609
9632
|
} else throw new Error("unable to define spec version for channel");
|
|
9610
9633
|
this.responseParser = new RPCResponseParser(options?.resourceBoundsOverhead);
|
|
9611
9634
|
const plugins = options?.plugins === false ? [] : options?.plugins ?? defaultPlugins;
|
|
@@ -9634,7 +9657,7 @@ var RpcProvider = class {
|
|
|
9634
9657
|
if (isVersion("0.10", spec)) {
|
|
9635
9658
|
return new this({
|
|
9636
9659
|
...optionsOrProvider,
|
|
9637
|
-
specVersion: _SupportedRpcVersion.
|
|
9660
|
+
specVersion: _SupportedRpcVersion.v0_10_3
|
|
9638
9661
|
});
|
|
9639
9662
|
}
|
|
9640
9663
|
throw new LibraryError(
|
|
@@ -13415,7 +13438,8 @@ function units(amount, simbol = "fri") {
|
|
|
13415
13438
|
Provider,
|
|
13416
13439
|
ProviderInterface,
|
|
13417
13440
|
RPC,
|
|
13418
|
-
|
|
13441
|
+
RPC0102,
|
|
13442
|
+
RPC0103,
|
|
13419
13443
|
RPC09,
|
|
13420
13444
|
RPCResponseParser,
|
|
13421
13445
|
ReceiptTx,
|