starknet 9.1.1 → 9.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/index.d.ts +260 -170
- package/dist/index.global.js +280 -218
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +177 -115
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +178 -116
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.global.js
CHANGED
|
@@ -99,7 +99,7 @@ var starknet = (() => {
|
|
|
99
99
|
TransactionExecutionStatus: () => TransactionExecutionStatus,
|
|
100
100
|
TransactionFinalityStatus: () => TransactionFinalityStatus,
|
|
101
101
|
TransactionType: () => TransactionType,
|
|
102
|
-
TypedDataRevision: () =>
|
|
102
|
+
TypedDataRevision: () => TypedDataRevision2,
|
|
103
103
|
UINT_128_MAX: () => UINT_128_MAX,
|
|
104
104
|
UINT_128_MIN: () => UINT_128_MIN,
|
|
105
105
|
UINT_256_HIGH_MAX: () => UINT_256_HIGH_MAX,
|
|
@@ -229,52 +229,52 @@ var starknet = (() => {
|
|
|
229
229
|
// src/types/api/index.ts
|
|
230
230
|
var api_exports3 = {};
|
|
231
231
|
__export(api_exports3, {
|
|
232
|
-
ABI_TYPE_CONSTRUCTOR: () =>
|
|
233
|
-
ABI_TYPE_ENUM: () =>
|
|
234
|
-
ABI_TYPE_FUNCTION: () =>
|
|
235
|
-
ABI_TYPE_L1_HANDLER: () =>
|
|
236
|
-
API: () =>
|
|
237
|
-
CALL_TYPE: () =>
|
|
238
|
-
CONTRACT: () =>
|
|
239
|
-
EBlockStatus: () =>
|
|
240
|
-
EBlockTag: () =>
|
|
241
|
-
EDAMode: () =>
|
|
242
|
-
EDataAvailabilityMode: () =>
|
|
243
|
-
ESimulationFlag: () =>
|
|
244
|
-
ETransactionExecutionStatus: () =>
|
|
245
|
-
ETransactionFinalityStatus: () =>
|
|
246
|
-
ETransactionStatus: () =>
|
|
247
|
-
ETransactionType: () =>
|
|
248
|
-
ETransactionVersion: () =>
|
|
249
|
-
ETransactionVersion2: () =>
|
|
250
|
-
ETransactionVersion3: () =>
|
|
251
|
-
EVENT_ABI_TYPE: () =>
|
|
232
|
+
ABI_TYPE_CONSTRUCTOR: () => ABI_TYPE_CONSTRUCTOR2,
|
|
233
|
+
ABI_TYPE_ENUM: () => ABI_TYPE_ENUM2,
|
|
234
|
+
ABI_TYPE_FUNCTION: () => ABI_TYPE_FUNCTION2,
|
|
235
|
+
ABI_TYPE_L1_HANDLER: () => ABI_TYPE_L1_HANDLER2,
|
|
236
|
+
API: () => api_exports2,
|
|
237
|
+
CALL_TYPE: () => CALL_TYPE2,
|
|
238
|
+
CONTRACT: () => contract_exports2,
|
|
239
|
+
EBlockStatus: () => EBlockStatus2,
|
|
240
|
+
EBlockTag: () => EBlockTag2,
|
|
241
|
+
EDAMode: () => EDAMode2,
|
|
242
|
+
EDataAvailabilityMode: () => EDataAvailabilityMode2,
|
|
243
|
+
ESimulationFlag: () => ESimulationFlag2,
|
|
244
|
+
ETransactionExecutionStatus: () => ETransactionExecutionStatus2,
|
|
245
|
+
ETransactionFinalityStatus: () => ETransactionFinalityStatus2,
|
|
246
|
+
ETransactionStatus: () => ETransactionStatus2,
|
|
247
|
+
ETransactionType: () => ETransactionType2,
|
|
248
|
+
ETransactionVersion: () => ETransactionVersion4,
|
|
249
|
+
ETransactionVersion2: () => ETransactionVersion22,
|
|
250
|
+
ETransactionVersion3: () => ETransactionVersion32,
|
|
251
|
+
EVENT_ABI_TYPE: () => EVENT_ABI_TYPE2,
|
|
252
252
|
JRPC: () => jsonrpc_exports,
|
|
253
|
-
L1_DA_MODE: () =>
|
|
253
|
+
L1_DA_MODE: () => L1_DA_MODE2,
|
|
254
254
|
PAYMASTER_API: () => snip_29_exports2,
|
|
255
|
-
PRICE_UNIT_FRI: () =>
|
|
256
|
-
PRICE_UNIT_WEI: () =>
|
|
257
|
-
Permission: () =>
|
|
255
|
+
PRICE_UNIT_FRI: () => PRICE_UNIT_FRI2,
|
|
256
|
+
PRICE_UNIT_WEI: () => PRICE_UNIT_WEI2,
|
|
257
|
+
Permission: () => Permission2,
|
|
258
258
|
RPCSPEC010: () => esm_exports2,
|
|
259
259
|
RPCSPEC09: () => esm_exports,
|
|
260
|
-
STATE_MUTABILITY_EXTERNAL: () =>
|
|
261
|
-
STATE_MUTABILITY_VIEW: () =>
|
|
262
|
-
STATUS_ACCEPTED_ON_L1: () =>
|
|
263
|
-
STATUS_ACCEPTED_ON_L2: () =>
|
|
264
|
-
STATUS_CANDIDATE: () =>
|
|
265
|
-
STATUS_PRE_CONFIRMED: () =>
|
|
266
|
-
STATUS_PRE_CONFIRMED_LOWERCASE: () =>
|
|
267
|
-
STATUS_RECEIVED: () =>
|
|
268
|
-
STATUS_REVERTED: () =>
|
|
269
|
-
STATUS_SUCCEEDED: () =>
|
|
270
|
-
STRUCT_ABI_TYPE: () =>
|
|
271
|
-
TXN_TYPE_DECLARE: () =>
|
|
272
|
-
TXN_TYPE_DEPLOY: () =>
|
|
273
|
-
TXN_TYPE_DEPLOY_ACCOUNT: () =>
|
|
274
|
-
TXN_TYPE_INVOKE: () =>
|
|
275
|
-
TXN_TYPE_L1_HANDLER: () =>
|
|
276
|
-
TypedDataRevision: () =>
|
|
277
|
-
WALLET_API: () =>
|
|
260
|
+
STATE_MUTABILITY_EXTERNAL: () => STATE_MUTABILITY_EXTERNAL2,
|
|
261
|
+
STATE_MUTABILITY_VIEW: () => STATE_MUTABILITY_VIEW2,
|
|
262
|
+
STATUS_ACCEPTED_ON_L1: () => STATUS_ACCEPTED_ON_L12,
|
|
263
|
+
STATUS_ACCEPTED_ON_L2: () => STATUS_ACCEPTED_ON_L22,
|
|
264
|
+
STATUS_CANDIDATE: () => STATUS_CANDIDATE2,
|
|
265
|
+
STATUS_PRE_CONFIRMED: () => STATUS_PRE_CONFIRMED2,
|
|
266
|
+
STATUS_PRE_CONFIRMED_LOWERCASE: () => STATUS_PRE_CONFIRMED_LOWERCASE2,
|
|
267
|
+
STATUS_RECEIVED: () => STATUS_RECEIVED2,
|
|
268
|
+
STATUS_REVERTED: () => STATUS_REVERTED2,
|
|
269
|
+
STATUS_SUCCEEDED: () => STATUS_SUCCEEDED2,
|
|
270
|
+
STRUCT_ABI_TYPE: () => STRUCT_ABI_TYPE2,
|
|
271
|
+
TXN_TYPE_DECLARE: () => TXN_TYPE_DECLARE2,
|
|
272
|
+
TXN_TYPE_DEPLOY: () => TXN_TYPE_DEPLOY2,
|
|
273
|
+
TXN_TYPE_DEPLOY_ACCOUNT: () => TXN_TYPE_DEPLOY_ACCOUNT2,
|
|
274
|
+
TXN_TYPE_INVOKE: () => TXN_TYPE_INVOKE2,
|
|
275
|
+
TXN_TYPE_L1_HANDLER: () => TXN_TYPE_L1_HANDLER2,
|
|
276
|
+
TypedDataRevision: () => TypedDataRevision2,
|
|
277
|
+
WALLET_API: () => wallet_api_exports2
|
|
278
278
|
});
|
|
279
279
|
|
|
280
280
|
// src/types/api/jsonrpc.ts
|
|
@@ -766,6 +766,26 @@ var starknet = (() => {
|
|
|
766
766
|
LEGACY: "0"
|
|
767
767
|
};
|
|
768
768
|
|
|
769
|
+
// src/provider/types/spec.type.ts
|
|
770
|
+
var { ETransactionVersion: ETransactionVersion5 } = esm_exports;
|
|
771
|
+
var { ETransactionVersion2: ETransactionVersion23 } = esm_exports;
|
|
772
|
+
var { ETransactionVersion3: ETransactionVersion33 } = esm_exports;
|
|
773
|
+
var { EDataAvailabilityMode: EDataAvailabilityMode3 } = esm_exports2;
|
|
774
|
+
var { EDAMode: EDAMode3 } = esm_exports2;
|
|
775
|
+
function isRPC08Plus_ResourceBounds(entry) {
|
|
776
|
+
return "l1_data_gas" in entry;
|
|
777
|
+
}
|
|
778
|
+
function isRPC08Plus_ResourceBoundsBN(entry) {
|
|
779
|
+
return "l1_data_gas" in entry;
|
|
780
|
+
}
|
|
781
|
+
var { ETransactionStatus: ETransactionStatus3 } = esm_exports2;
|
|
782
|
+
var { ETransactionExecutionStatus: ETransactionExecutionStatus3 } = esm_exports2;
|
|
783
|
+
var { ETransactionType: TransactionType } = esm_exports;
|
|
784
|
+
var { EBlockStatus: BlockStatus } = esm_exports;
|
|
785
|
+
var { ETransactionFinalityStatus: TransactionFinalityStatus } = esm_exports;
|
|
786
|
+
var { ETransactionExecutionStatus: TransactionExecutionStatus } = esm_exports;
|
|
787
|
+
var { EBlockTag: BlockTag } = esm_exports;
|
|
788
|
+
|
|
769
789
|
// src/utils/encode.ts
|
|
770
790
|
var encode_exports = {};
|
|
771
791
|
__export(encode_exports, {
|
|
@@ -1180,7 +1200,7 @@ var starknet = (() => {
|
|
|
1180
1200
|
};
|
|
1181
1201
|
var DEFAULT_GLOBAL_CONFIG = {
|
|
1182
1202
|
rpcVersion: "0.10.0",
|
|
1183
|
-
transactionVersion:
|
|
1203
|
+
transactionVersion: ETransactionVersion4.V3,
|
|
1184
1204
|
// Starknet 0.14.0 only V3 transactions
|
|
1185
1205
|
logLevel: "INFO",
|
|
1186
1206
|
resourceBoundsOverhead: {
|
|
@@ -1198,6 +1218,22 @@ var starknet = (() => {
|
|
|
1198
1218
|
}
|
|
1199
1219
|
},
|
|
1200
1220
|
defaultTipType: "recommendedTip",
|
|
1221
|
+
channelDefaults: {
|
|
1222
|
+
options: {
|
|
1223
|
+
headers: { "Content-Type": "application/json" },
|
|
1224
|
+
blockIdentifier: BlockTag.LATEST,
|
|
1225
|
+
retries: 200
|
|
1226
|
+
},
|
|
1227
|
+
methods: {
|
|
1228
|
+
simulateTransaction: {
|
|
1229
|
+
skipValidate: true,
|
|
1230
|
+
skipFeeCharge: true
|
|
1231
|
+
},
|
|
1232
|
+
getEstimateFee: {
|
|
1233
|
+
skipValidate: true
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
},
|
|
1201
1237
|
fetch: void 0,
|
|
1202
1238
|
websocket: void 0,
|
|
1203
1239
|
buffer: void 0,
|
|
@@ -1242,11 +1278,51 @@ var starknet = (() => {
|
|
|
1242
1278
|
}
|
|
1243
1279
|
return _Configuration.instance;
|
|
1244
1280
|
}
|
|
1281
|
+
/**
|
|
1282
|
+
* Get a nested value from an object using a dot-notation path
|
|
1283
|
+
* @param obj - The object to traverse
|
|
1284
|
+
* @param path - The dot-notation path (e.g., 'a.b.c')
|
|
1285
|
+
* @returns The value at the path, or undefined if not found
|
|
1286
|
+
*/
|
|
1287
|
+
getNestedValue(obj, path) {
|
|
1288
|
+
const keys = path.split(".");
|
|
1289
|
+
return keys.reduce((current, key) => {
|
|
1290
|
+
if (current === null || current === void 0) {
|
|
1291
|
+
return void 0;
|
|
1292
|
+
}
|
|
1293
|
+
return current[key];
|
|
1294
|
+
}, obj);
|
|
1295
|
+
}
|
|
1296
|
+
/**
|
|
1297
|
+
* Set a nested value in an object using a dot-notation path
|
|
1298
|
+
* @param obj - The object to modify
|
|
1299
|
+
* @param path - The dot-notation path (e.g., 'a.b.c')
|
|
1300
|
+
* @param value - The value to set
|
|
1301
|
+
*/
|
|
1302
|
+
setNestedValue(obj, path, value) {
|
|
1303
|
+
const keys = path.split(".");
|
|
1304
|
+
const lastKey = keys.pop();
|
|
1305
|
+
const target = keys.reduce((current, key) => {
|
|
1306
|
+
if (!(key in current) || typeof current[key] !== "object" || current[key] === null) {
|
|
1307
|
+
current[key] = {};
|
|
1308
|
+
}
|
|
1309
|
+
return current[key];
|
|
1310
|
+
}, obj);
|
|
1311
|
+
target[lastKey] = value;
|
|
1312
|
+
}
|
|
1245
1313
|
get(key, defaultValue) {
|
|
1314
|
+
if (key.includes(".")) {
|
|
1315
|
+
const value = this.getNestedValue(this.config, key);
|
|
1316
|
+
return value ?? defaultValue;
|
|
1317
|
+
}
|
|
1246
1318
|
return this.config[key] ?? defaultValue;
|
|
1247
1319
|
}
|
|
1248
1320
|
set(key, value) {
|
|
1249
|
-
|
|
1321
|
+
if (key.includes(".")) {
|
|
1322
|
+
this.setNestedValue(this.config, key, value);
|
|
1323
|
+
} else {
|
|
1324
|
+
this.config[key] = value;
|
|
1325
|
+
}
|
|
1250
1326
|
}
|
|
1251
1327
|
update(configData) {
|
|
1252
1328
|
this.config = {
|
|
@@ -1415,26 +1491,6 @@ ${JSON.stringify(data, null, 2)}`;
|
|
|
1415
1491
|
CONSTRUCTOR: "CONSTRUCTOR"
|
|
1416
1492
|
};
|
|
1417
1493
|
|
|
1418
|
-
// src/provider/types/spec.type.ts
|
|
1419
|
-
var { ETransactionVersion: ETransactionVersion5 } = esm_exports;
|
|
1420
|
-
var { ETransactionVersion2: ETransactionVersion23 } = esm_exports;
|
|
1421
|
-
var { ETransactionVersion3: ETransactionVersion33 } = esm_exports;
|
|
1422
|
-
var { EDataAvailabilityMode: EDataAvailabilityMode3 } = esm_exports2;
|
|
1423
|
-
var { EDAMode: EDAMode3 } = esm_exports2;
|
|
1424
|
-
function isRPC08Plus_ResourceBounds(entry) {
|
|
1425
|
-
return "l1_data_gas" in entry;
|
|
1426
|
-
}
|
|
1427
|
-
function isRPC08Plus_ResourceBoundsBN(entry) {
|
|
1428
|
-
return "l1_data_gas" in entry;
|
|
1429
|
-
}
|
|
1430
|
-
var { ETransactionStatus: ETransactionStatus3 } = esm_exports2;
|
|
1431
|
-
var { ETransactionExecutionStatus: ETransactionExecutionStatus3 } = esm_exports2;
|
|
1432
|
-
var { ETransactionType: TransactionType } = esm_exports;
|
|
1433
|
-
var { EBlockStatus: BlockStatus } = esm_exports;
|
|
1434
|
-
var { ETransactionFinalityStatus: TransactionFinalityStatus } = esm_exports;
|
|
1435
|
-
var { ETransactionExecutionStatus: TransactionExecutionStatus } = esm_exports;
|
|
1436
|
-
var { EBlockTag: BlockTag } = esm_exports;
|
|
1437
|
-
|
|
1438
1494
|
// src/types/calldata.ts
|
|
1439
1495
|
var ValidateType = {
|
|
1440
1496
|
DEPLOY: "DEPLOY",
|
|
@@ -9174,7 +9230,7 @@ ${indent}}` : "}";
|
|
|
9174
9230
|
|
|
9175
9231
|
// src/utils/hash/transactionHash/index.ts
|
|
9176
9232
|
function isV3InvokeTx(args) {
|
|
9177
|
-
return [
|
|
9233
|
+
return [ETransactionVersion4.V3, ETransactionVersion4.F3].includes(args.version);
|
|
9178
9234
|
}
|
|
9179
9235
|
function calculateInvokeTransactionHash2(args) {
|
|
9180
9236
|
if (isV3InvokeTx(args)) {
|
|
@@ -9195,7 +9251,7 @@ ${indent}}` : "}";
|
|
|
9195
9251
|
throw new Error("Invalid Tx version for hash calculation");
|
|
9196
9252
|
}
|
|
9197
9253
|
function isV3DeclareTx(args) {
|
|
9198
|
-
return [
|
|
9254
|
+
return [ETransactionVersion4.V3, ETransactionVersion4.F3].includes(args.version);
|
|
9199
9255
|
}
|
|
9200
9256
|
function calculateDeclareTransactionHash3(args) {
|
|
9201
9257
|
if (isV3DeclareTx(args)) {
|
|
@@ -9217,7 +9273,7 @@ ${indent}}` : "}";
|
|
|
9217
9273
|
throw new Error("Invalid Tx version for hash calculation");
|
|
9218
9274
|
}
|
|
9219
9275
|
function isV3DeployAccountTx(args) {
|
|
9220
|
-
return [
|
|
9276
|
+
return [ETransactionVersion4.V3, ETransactionVersion4.F3].includes(args.version);
|
|
9221
9277
|
}
|
|
9222
9278
|
function calculateDeployAccountTransactionHash3(args) {
|
|
9223
9279
|
if (isV3DeployAccountTx(args)) {
|
|
@@ -9947,7 +10003,7 @@ ${indent}}` : "}";
|
|
|
9947
10003
|
return 0;
|
|
9948
10004
|
}
|
|
9949
10005
|
function isPreConfirmedBlock(response) {
|
|
9950
|
-
return response.status ===
|
|
10006
|
+
return response.status === EBlockStatus2.PRE_CONFIRMED;
|
|
9951
10007
|
}
|
|
9952
10008
|
function isPreConfirmedTransaction(response) {
|
|
9953
10009
|
return !("block_hash" in response);
|
|
@@ -14956,11 +15012,6 @@ ${indent}}` : "}";
|
|
|
14956
15012
|
}
|
|
14957
15013
|
|
|
14958
15014
|
// src/channel/rpc_0_9_0.ts
|
|
14959
|
-
var defaultOptions = {
|
|
14960
|
-
headers: { "Content-Type": "application/json" },
|
|
14961
|
-
blockIdentifier: BlockTag.LATEST,
|
|
14962
|
-
retries: 200
|
|
14963
|
-
};
|
|
14964
15015
|
var RpcChannel = class {
|
|
14965
15016
|
id = "RPC090";
|
|
14966
15017
|
/**
|
|
@@ -15010,11 +15061,12 @@ ${indent}}` : "}";
|
|
|
15010
15061
|
this.channelSpecVersion
|
|
15011
15062
|
);
|
|
15012
15063
|
}
|
|
15064
|
+
const channelDefaults = config.get("channelDefaults");
|
|
15013
15065
|
this.baseFetch = baseFetch || config.get("fetch") || fetch_default;
|
|
15014
|
-
this.blockIdentifier = blockIdentifier ??
|
|
15066
|
+
this.blockIdentifier = blockIdentifier ?? channelDefaults.options.blockIdentifier;
|
|
15015
15067
|
this.chainId = chainId;
|
|
15016
|
-
this.headers = { ...
|
|
15017
|
-
this.retries = retries ??
|
|
15068
|
+
this.headers = { ...channelDefaults.options.headers, ...headers };
|
|
15069
|
+
this.retries = retries ?? channelDefaults.options.retries;
|
|
15018
15070
|
this.specVersion = specVersion;
|
|
15019
15071
|
this.transactionRetryIntervalFallback = transactionRetryIntervalFallback;
|
|
15020
15072
|
this.waitMode = waitMode ?? false;
|
|
@@ -15228,14 +15280,16 @@ ${indent}}` : "}";
|
|
|
15228
15280
|
* @param invocations AccountInvocations
|
|
15229
15281
|
* @param simulateTransactionOptions blockIdentifier and flags to skip validation and fee charge<br/>
|
|
15230
15282
|
* - blockIdentifier<br/>
|
|
15231
|
-
* - skipValidate (default
|
|
15283
|
+
* - skipValidate (default true)<br/>
|
|
15232
15284
|
* - skipFeeCharge (default true)<br/>
|
|
15233
15285
|
*/
|
|
15234
15286
|
simulateTransaction(invocations, simulateTransactionOptions = {}) {
|
|
15287
|
+
const channelDefaults = config.get("channelDefaults");
|
|
15288
|
+
const methodDefaults = channelDefaults.methods.simulateTransaction || {};
|
|
15235
15289
|
const {
|
|
15236
15290
|
blockIdentifier = this.blockIdentifier,
|
|
15237
|
-
skipValidate =
|
|
15238
|
-
skipFeeCharge =
|
|
15291
|
+
skipValidate = methodDefaults.skipValidate,
|
|
15292
|
+
skipFeeCharge = methodDefaults.skipFeeCharge
|
|
15239
15293
|
} = simulateTransactionOptions;
|
|
15240
15294
|
const block_id = new Block(blockIdentifier).identifier;
|
|
15241
15295
|
const simulationFlags = [];
|
|
@@ -15395,7 +15449,10 @@ ${indent}}` : "}";
|
|
|
15395
15449
|
contract_address
|
|
15396
15450
|
});
|
|
15397
15451
|
}
|
|
15398
|
-
async getEstimateFee(invocations,
|
|
15452
|
+
async getEstimateFee(invocations, options = {}) {
|
|
15453
|
+
const channelDefaults = config.get("channelDefaults");
|
|
15454
|
+
const methodDefaults = channelDefaults.methods.getEstimateFee || {};
|
|
15455
|
+
const { blockIdentifier = this.blockIdentifier, skipValidate = methodDefaults.skipValidate } = options;
|
|
15399
15456
|
const block_id = new Block(blockIdentifier).identifier;
|
|
15400
15457
|
const flags = {
|
|
15401
15458
|
simulation_flags: skipValidate ? [esm_exports.ESimulationFlag.SKIP_VALIDATE] : []
|
|
@@ -15409,7 +15466,7 @@ ${indent}}` : "}";
|
|
|
15409
15466
|
async invoke(functionInvocation, details) {
|
|
15410
15467
|
const transaction = this.buildTransaction(
|
|
15411
15468
|
{
|
|
15412
|
-
type:
|
|
15469
|
+
type: ETransactionType2.INVOKE,
|
|
15413
15470
|
...functionInvocation,
|
|
15414
15471
|
...details
|
|
15415
15472
|
},
|
|
@@ -15423,7 +15480,7 @@ ${indent}}` : "}";
|
|
|
15423
15480
|
async declare(declareTransaction, details) {
|
|
15424
15481
|
const transaction = this.buildTransaction(
|
|
15425
15482
|
{
|
|
15426
|
-
type:
|
|
15483
|
+
type: ETransactionType2.DECLARE,
|
|
15427
15484
|
...declareTransaction,
|
|
15428
15485
|
...details
|
|
15429
15486
|
},
|
|
@@ -15437,7 +15494,7 @@ ${indent}}` : "}";
|
|
|
15437
15494
|
async deployAccount(deployAccountTransaction, details) {
|
|
15438
15495
|
const transaction = this.buildTransaction(
|
|
15439
15496
|
{
|
|
15440
|
-
type:
|
|
15497
|
+
type: ETransactionType2.DEPLOY_ACCOUNT,
|
|
15441
15498
|
...deployAccountTransaction,
|
|
15442
15499
|
...details
|
|
15443
15500
|
},
|
|
@@ -15510,7 +15567,7 @@ ${indent}}` : "}";
|
|
|
15510
15567
|
account_deployment_data: invocation.accountDeploymentData.map((it) => toHex(it)),
|
|
15511
15568
|
version: toTransactionVersion(defaultVersions.v3, invocation.version)
|
|
15512
15569
|
};
|
|
15513
|
-
if (invocation.type ===
|
|
15570
|
+
if (invocation.type === ETransactionType2.INVOKE) {
|
|
15514
15571
|
const btx = {
|
|
15515
15572
|
type: esm_exports.ETransactionType.INVOKE,
|
|
15516
15573
|
sender_address: invocation.contractAddress,
|
|
@@ -15519,7 +15576,7 @@ ${indent}}` : "}";
|
|
|
15519
15576
|
};
|
|
15520
15577
|
return btx;
|
|
15521
15578
|
}
|
|
15522
|
-
if (invocation.type ===
|
|
15579
|
+
if (invocation.type === ETransactionType2.DECLARE) {
|
|
15523
15580
|
assert(isSierra(invocation.contract), "Declaring non Sierra contract using RPC 0.9");
|
|
15524
15581
|
const btx = {
|
|
15525
15582
|
type: invocation.type,
|
|
@@ -15533,7 +15590,7 @@ ${indent}}` : "}";
|
|
|
15533
15590
|
};
|
|
15534
15591
|
return btx;
|
|
15535
15592
|
}
|
|
15536
|
-
if (invocation.type ===
|
|
15593
|
+
if (invocation.type === ETransactionType2.DEPLOY_ACCOUNT) {
|
|
15537
15594
|
const { account_deployment_data, ...restDetails } = details;
|
|
15538
15595
|
const btx = {
|
|
15539
15596
|
type: invocation.type,
|
|
@@ -15553,11 +15610,6 @@ ${indent}}` : "}";
|
|
|
15553
15610
|
__export(rpc_0_10_0_exports, {
|
|
15554
15611
|
RpcChannel: () => RpcChannel2
|
|
15555
15612
|
});
|
|
15556
|
-
var defaultOptions2 = {
|
|
15557
|
-
headers: { "Content-Type": "application/json" },
|
|
15558
|
-
blockIdentifier: BlockTag.LATEST,
|
|
15559
|
-
retries: 200
|
|
15560
|
-
};
|
|
15561
15613
|
var RpcChannel2 = class {
|
|
15562
15614
|
id = "RPC0.10.0";
|
|
15563
15615
|
/**
|
|
@@ -15607,11 +15659,12 @@ ${indent}}` : "}";
|
|
|
15607
15659
|
this.channelSpecVersion
|
|
15608
15660
|
);
|
|
15609
15661
|
}
|
|
15662
|
+
const channelDefaults = config.get("channelDefaults");
|
|
15610
15663
|
this.baseFetch = baseFetch || config.get("fetch") || fetch_default;
|
|
15611
|
-
this.blockIdentifier = blockIdentifier ??
|
|
15664
|
+
this.blockIdentifier = blockIdentifier ?? channelDefaults.options.blockIdentifier;
|
|
15612
15665
|
this.chainId = chainId;
|
|
15613
|
-
this.headers = { ...
|
|
15614
|
-
this.retries = retries ??
|
|
15666
|
+
this.headers = { ...channelDefaults.options.headers, ...headers };
|
|
15667
|
+
this.retries = retries ?? channelDefaults.options.retries;
|
|
15615
15668
|
this.specVersion = specVersion;
|
|
15616
15669
|
this.transactionRetryIntervalFallback = transactionRetryIntervalFallback;
|
|
15617
15670
|
this.waitMode = waitMode ?? false;
|
|
@@ -15825,14 +15878,16 @@ ${indent}}` : "}";
|
|
|
15825
15878
|
* @param invocations AccountInvocations
|
|
15826
15879
|
* @param simulateTransactionOptions blockIdentifier and flags to skip validation and fee charge<br/>
|
|
15827
15880
|
* - blockIdentifier<br/>
|
|
15828
|
-
* - skipValidate (default
|
|
15881
|
+
* - skipValidate (default true)<br/>
|
|
15829
15882
|
* - skipFeeCharge (default true)<br/>
|
|
15830
15883
|
*/
|
|
15831
15884
|
simulateTransaction(invocations, simulateTransactionOptions = {}) {
|
|
15885
|
+
const channelDefaults = config.get("channelDefaults");
|
|
15886
|
+
const methodDefaults = channelDefaults.methods.simulateTransaction || {};
|
|
15832
15887
|
const {
|
|
15833
15888
|
blockIdentifier = this.blockIdentifier,
|
|
15834
|
-
skipValidate =
|
|
15835
|
-
skipFeeCharge =
|
|
15889
|
+
skipValidate = methodDefaults.skipValidate,
|
|
15890
|
+
skipFeeCharge = methodDefaults.skipFeeCharge
|
|
15836
15891
|
} = simulateTransactionOptions;
|
|
15837
15892
|
const block_id = new Block(blockIdentifier).identifier;
|
|
15838
15893
|
const simulationFlags = [];
|
|
@@ -15992,7 +16047,10 @@ ${indent}}` : "}";
|
|
|
15992
16047
|
contract_address
|
|
15993
16048
|
});
|
|
15994
16049
|
}
|
|
15995
|
-
async getEstimateFee(invocations,
|
|
16050
|
+
async getEstimateFee(invocations, options = {}) {
|
|
16051
|
+
const channelDefaults = config.get("channelDefaults");
|
|
16052
|
+
const methodDefaults = channelDefaults.methods.getEstimateFee || {};
|
|
16053
|
+
const { blockIdentifier = this.blockIdentifier, skipValidate = methodDefaults.skipValidate } = options;
|
|
15996
16054
|
const block_id = new Block(blockIdentifier).identifier;
|
|
15997
16055
|
const flags = {
|
|
15998
16056
|
simulation_flags: skipValidate ? [esm_exports2.ESimulationFlag.SKIP_VALIDATE] : []
|
|
@@ -16006,7 +16064,7 @@ ${indent}}` : "}";
|
|
|
16006
16064
|
async invoke(functionInvocation, details) {
|
|
16007
16065
|
const transaction = this.buildTransaction(
|
|
16008
16066
|
{
|
|
16009
|
-
type:
|
|
16067
|
+
type: ETransactionType2.INVOKE,
|
|
16010
16068
|
...functionInvocation,
|
|
16011
16069
|
...details
|
|
16012
16070
|
},
|
|
@@ -16020,7 +16078,7 @@ ${indent}}` : "}";
|
|
|
16020
16078
|
async declare(declareTransaction, details) {
|
|
16021
16079
|
const transaction = this.buildTransaction(
|
|
16022
16080
|
{
|
|
16023
|
-
type:
|
|
16081
|
+
type: ETransactionType2.DECLARE,
|
|
16024
16082
|
...declareTransaction,
|
|
16025
16083
|
...details
|
|
16026
16084
|
},
|
|
@@ -16034,7 +16092,7 @@ ${indent}}` : "}";
|
|
|
16034
16092
|
async deployAccount(deployAccountTransaction, details) {
|
|
16035
16093
|
const transaction = this.buildTransaction(
|
|
16036
16094
|
{
|
|
16037
|
-
type:
|
|
16095
|
+
type: ETransactionType2.DEPLOY_ACCOUNT,
|
|
16038
16096
|
...deployAccountTransaction,
|
|
16039
16097
|
...details
|
|
16040
16098
|
},
|
|
@@ -16107,7 +16165,7 @@ ${indent}}` : "}";
|
|
|
16107
16165
|
account_deployment_data: invocation.accountDeploymentData.map((it) => toHex(it)),
|
|
16108
16166
|
version: toTransactionVersion(defaultVersions.v3, invocation.version)
|
|
16109
16167
|
};
|
|
16110
|
-
if (invocation.type ===
|
|
16168
|
+
if (invocation.type === ETransactionType2.INVOKE) {
|
|
16111
16169
|
const btx = {
|
|
16112
16170
|
type: esm_exports2.ETransactionType.INVOKE,
|
|
16113
16171
|
sender_address: invocation.contractAddress,
|
|
@@ -16116,7 +16174,7 @@ ${indent}}` : "}";
|
|
|
16116
16174
|
};
|
|
16117
16175
|
return btx;
|
|
16118
16176
|
}
|
|
16119
|
-
if (invocation.type ===
|
|
16177
|
+
if (invocation.type === ETransactionType2.DECLARE) {
|
|
16120
16178
|
assert(isSierra(invocation.contract), "Declaring non Sierra contract using RPC 0.9");
|
|
16121
16179
|
const btx = {
|
|
16122
16180
|
type: invocation.type,
|
|
@@ -16130,7 +16188,7 @@ ${indent}}` : "}";
|
|
|
16130
16188
|
};
|
|
16131
16189
|
return btx;
|
|
16132
16190
|
}
|
|
16133
|
-
if (invocation.type ===
|
|
16191
|
+
if (invocation.type === ETransactionType2.DEPLOY_ACCOUNT) {
|
|
16134
16192
|
const { account_deployment_data, ...restDetails } = details;
|
|
16135
16193
|
const btx = {
|
|
16136
16194
|
type: invocation.type,
|
|
@@ -16281,7 +16339,7 @@ ${indent}}` : "}";
|
|
|
16281
16339
|
}
|
|
16282
16340
|
};
|
|
16283
16341
|
|
|
16284
|
-
// src/channel/ws/
|
|
16342
|
+
// src/channel/ws/ws_0_10.ts
|
|
16285
16343
|
var WebSocketChannel = class {
|
|
16286
16344
|
/**
|
|
16287
16345
|
* The URL of the WebSocket RPC Node.
|
|
@@ -17274,14 +17332,14 @@ ${indent}}` : "}";
|
|
|
17274
17332
|
)
|
|
17275
17333
|
};
|
|
17276
17334
|
var revisionConfiguration = {
|
|
17277
|
-
[
|
|
17335
|
+
[TypedDataRevision2.ACTIVE]: {
|
|
17278
17336
|
domain: "StarknetDomain",
|
|
17279
17337
|
hashMethod: computePoseidonHashOnElements,
|
|
17280
17338
|
hashMerkleMethod: computePoseidonHash,
|
|
17281
17339
|
escapeTypeString: (s) => `"${s}"`,
|
|
17282
17340
|
presetTypes
|
|
17283
17341
|
},
|
|
17284
|
-
[
|
|
17342
|
+
[TypedDataRevision2.LEGACY]: {
|
|
17285
17343
|
domain: "StarkNetDomain",
|
|
17286
17344
|
hashMethod: computePedersenHashOnElements,
|
|
17287
17345
|
hashMerkleMethod: computePedersenHash,
|
|
@@ -17294,10 +17352,10 @@ ${indent}}` : "}";
|
|
|
17294
17352
|
assert(value >= min && value <= max, `${value} (${type}) is out of bounds [${min}, ${max}]`);
|
|
17295
17353
|
}
|
|
17296
17354
|
function identifyRevision({ types, domain }) {
|
|
17297
|
-
if (revisionConfiguration[
|
|
17298
|
-
return
|
|
17299
|
-
if (revisionConfiguration[
|
|
17300
|
-
return
|
|
17355
|
+
if (revisionConfiguration[TypedDataRevision2.ACTIVE].domain in types && domain.revision?.toString() === TypedDataRevision2.ACTIVE)
|
|
17356
|
+
return TypedDataRevision2.ACTIVE;
|
|
17357
|
+
if (revisionConfiguration[TypedDataRevision2.LEGACY].domain in types && (domain.revision ?? TypedDataRevision2.LEGACY) === TypedDataRevision2.LEGACY)
|
|
17358
|
+
return TypedDataRevision2.LEGACY;
|
|
17301
17359
|
return void 0;
|
|
17302
17360
|
}
|
|
17303
17361
|
function getHex(value) {
|
|
@@ -17322,11 +17380,11 @@ ${indent}}` : "}";
|
|
|
17322
17380
|
function isMerkleTreeType(type) {
|
|
17323
17381
|
return type.type === "merkletree";
|
|
17324
17382
|
}
|
|
17325
|
-
function getDependencies(types, type, dependencies = [], contains = "", revision =
|
|
17383
|
+
function getDependencies(types, type, dependencies = [], contains = "", revision = TypedDataRevision2.LEGACY) {
|
|
17326
17384
|
let dependencyTypes = [type];
|
|
17327
17385
|
if (type[type.length - 1] === "*") {
|
|
17328
17386
|
dependencyTypes = [type.slice(0, -1)];
|
|
17329
|
-
} else if (revision ===
|
|
17387
|
+
} else if (revision === TypedDataRevision2.ACTIVE) {
|
|
17330
17388
|
if (type === "enum") {
|
|
17331
17389
|
dependencyTypes = [contains];
|
|
17332
17390
|
} else if (type.match(/^\(.*\)$/)) {
|
|
@@ -17368,8 +17426,8 @@ ${indent}}` : "}";
|
|
|
17368
17426
|
}
|
|
17369
17427
|
return "raw";
|
|
17370
17428
|
}
|
|
17371
|
-
function encodeType(types, type, revision =
|
|
17372
|
-
const allTypes = revision ===
|
|
17429
|
+
function encodeType(types, type, revision = TypedDataRevision2.LEGACY) {
|
|
17430
|
+
const allTypes = revision === TypedDataRevision2.ACTIVE ? { ...types, ...revisionConfiguration[revision].presetTypes } : types;
|
|
17373
17431
|
const [primary, ...dependencies] = getDependencies(
|
|
17374
17432
|
allTypes,
|
|
17375
17433
|
type,
|
|
@@ -17381,17 +17439,17 @@ ${indent}}` : "}";
|
|
|
17381
17439
|
const esc = revisionConfiguration[revision].escapeTypeString;
|
|
17382
17440
|
return newTypes.map((dependency) => {
|
|
17383
17441
|
const dependencyElements = allTypes[dependency].map((t) => {
|
|
17384
|
-
const targetType = t.type === "enum" && revision ===
|
|
17442
|
+
const targetType = t.type === "enum" && revision === TypedDataRevision2.ACTIVE ? t.contains : t.type;
|
|
17385
17443
|
const typeString = targetType.match(/^\(.*\)$/) ? `(${targetType.slice(1, -1).split(",").map((e) => e ? esc(e) : e).join(",")})` : esc(targetType);
|
|
17386
17444
|
return `${esc(t.name)}:${typeString}`;
|
|
17387
17445
|
});
|
|
17388
17446
|
return `${esc(dependency)}(${dependencyElements})`;
|
|
17389
17447
|
}).join("");
|
|
17390
17448
|
}
|
|
17391
|
-
function getTypeHash(types, type, revision =
|
|
17449
|
+
function getTypeHash(types, type, revision = TypedDataRevision2.LEGACY) {
|
|
17392
17450
|
return getSelectorFromName(encodeType(types, type, revision));
|
|
17393
17451
|
}
|
|
17394
|
-
function encodeValue(types, type, data, ctx = {}, revision =
|
|
17452
|
+
function encodeValue(types, type, data, ctx = {}, revision = TypedDataRevision2.LEGACY) {
|
|
17395
17453
|
if (types[type]) {
|
|
17396
17454
|
return [type, getStructHash(types, type, data, revision)];
|
|
17397
17455
|
}
|
|
@@ -17414,7 +17472,7 @@ ${indent}}` : "}";
|
|
|
17414
17472
|
}
|
|
17415
17473
|
switch (type) {
|
|
17416
17474
|
case "enum": {
|
|
17417
|
-
if (revision ===
|
|
17475
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
17418
17476
|
const [variantKey, variantData] = Object.entries(data)[0];
|
|
17419
17477
|
const parentType = types[ctx.parent].find((t) => t.name === ctx.key);
|
|
17420
17478
|
const enumType = types[parentType.contains];
|
|
@@ -17447,7 +17505,7 @@ ${indent}}` : "}";
|
|
|
17447
17505
|
return ["felt", prepareSelector(data)];
|
|
17448
17506
|
}
|
|
17449
17507
|
case "string": {
|
|
17450
|
-
if (revision ===
|
|
17508
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
17451
17509
|
const byteArray = byteArrayFromString(data);
|
|
17452
17510
|
const elements = [
|
|
17453
17511
|
byteArray.data.length,
|
|
@@ -17460,7 +17518,7 @@ ${indent}}` : "}";
|
|
|
17460
17518
|
return [type, getHex(data)];
|
|
17461
17519
|
}
|
|
17462
17520
|
case "i128": {
|
|
17463
|
-
if (revision ===
|
|
17521
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
17464
17522
|
const value = BigInt(data);
|
|
17465
17523
|
assertRange(value, type, RANGE_I128);
|
|
17466
17524
|
return [type, getHex(value < 0n ? PRIME + value : value)];
|
|
@@ -17469,40 +17527,40 @@ ${indent}}` : "}";
|
|
|
17469
17527
|
}
|
|
17470
17528
|
case "timestamp":
|
|
17471
17529
|
case "u128": {
|
|
17472
|
-
if (revision ===
|
|
17530
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
17473
17531
|
assertRange(data, type, RANGE_U128);
|
|
17474
17532
|
}
|
|
17475
17533
|
return [type, getHex(data)];
|
|
17476
17534
|
}
|
|
17477
17535
|
case "felt":
|
|
17478
17536
|
case "shortstring": {
|
|
17479
|
-
if (revision ===
|
|
17537
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
17480
17538
|
assertRange(getHex(data), type, RANGE_FELT);
|
|
17481
17539
|
}
|
|
17482
17540
|
return [type, getHex(data)];
|
|
17483
17541
|
}
|
|
17484
17542
|
case "ClassHash":
|
|
17485
17543
|
case "ContractAddress": {
|
|
17486
|
-
if (revision ===
|
|
17544
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
17487
17545
|
assertRange(data, type, RANGE_FELT);
|
|
17488
17546
|
}
|
|
17489
17547
|
return [type, getHex(data)];
|
|
17490
17548
|
}
|
|
17491
17549
|
case "bool": {
|
|
17492
|
-
if (revision ===
|
|
17550
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
17493
17551
|
assert(isBoolean(data), `Type mismatch for ${type} ${data}`);
|
|
17494
17552
|
}
|
|
17495
17553
|
return [type, getHex(data)];
|
|
17496
17554
|
}
|
|
17497
17555
|
default: {
|
|
17498
|
-
if (revision ===
|
|
17556
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
17499
17557
|
throw new Error(`Unsupported type: ${type}`);
|
|
17500
17558
|
}
|
|
17501
17559
|
return [type, getHex(data)];
|
|
17502
17560
|
}
|
|
17503
17561
|
}
|
|
17504
17562
|
}
|
|
17505
|
-
function encodeData(types, type, data, revision =
|
|
17563
|
+
function encodeData(types, type, data, revision = TypedDataRevision2.LEGACY) {
|
|
17506
17564
|
const targetType = types[type] ?? revisionConfiguration[revision].presetTypes[type];
|
|
17507
17565
|
const [returnTypes, values] = targetType.reduce(
|
|
17508
17566
|
([ts, vs], field) => {
|
|
@@ -17521,7 +17579,7 @@ ${indent}}` : "}";
|
|
|
17521
17579
|
);
|
|
17522
17580
|
return [returnTypes, values];
|
|
17523
17581
|
}
|
|
17524
|
-
function getStructHash(types, type, data, revision =
|
|
17582
|
+
function getStructHash(types, type, data, revision = TypedDataRevision2.LEGACY) {
|
|
17525
17583
|
return revisionConfiguration[revision].hashMethod(encodeData(types, type, data, revision)[1]);
|
|
17526
17584
|
}
|
|
17527
17585
|
function getMessageHash(typedData, accountAddress) {
|
|
@@ -17872,19 +17930,19 @@ ${indent}}` : "}";
|
|
|
17872
17930
|
}
|
|
17873
17931
|
async getInvokeEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
17874
17932
|
return (await this.getEstimateFeeBulk(
|
|
17875
|
-
[{ type:
|
|
17933
|
+
[{ type: ETransactionType2.INVOKE, ...invocation, ...details }],
|
|
17876
17934
|
{ blockIdentifier, skipValidate }
|
|
17877
17935
|
))[0];
|
|
17878
17936
|
}
|
|
17879
17937
|
async getDeclareEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
17880
17938
|
return (await this.getEstimateFeeBulk(
|
|
17881
|
-
[{ type:
|
|
17939
|
+
[{ type: ETransactionType2.DECLARE, ...invocation, ...details }],
|
|
17882
17940
|
{ blockIdentifier, skipValidate }
|
|
17883
17941
|
))[0];
|
|
17884
17942
|
}
|
|
17885
17943
|
async getDeployAccountEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
17886
17944
|
return (await this.getEstimateFeeBulk(
|
|
17887
|
-
[{ type:
|
|
17945
|
+
[{ type: ETransactionType2.DEPLOY_ACCOUNT, ...invocation, ...details }],
|
|
17888
17946
|
{ blockIdentifier, skipValidate }
|
|
17889
17947
|
))[0];
|
|
17890
17948
|
}
|
|
@@ -17954,7 +18012,7 @@ ${indent}}` : "}";
|
|
|
17954
18012
|
async prepareInvocations(invocations) {
|
|
17955
18013
|
const bulk = [];
|
|
17956
18014
|
for (const invocation of invocations) {
|
|
17957
|
-
if (invocation.type ===
|
|
18015
|
+
if (invocation.type === ETransactionType2.DECLARE) {
|
|
17958
18016
|
const isDeclared = await this.isClassDeclared(
|
|
17959
18017
|
"payload" in invocation ? invocation.payload : invocation
|
|
17960
18018
|
);
|
|
@@ -18842,7 +18900,7 @@ ${indent}}` : "}";
|
|
|
18842
18900
|
async signTransaction(transactions, details) {
|
|
18843
18901
|
const compiledCalldata = getExecuteCalldata(transactions, details.cairoVersion);
|
|
18844
18902
|
let msgHash;
|
|
18845
|
-
if (Object.values(
|
|
18903
|
+
if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
18846
18904
|
const det = details;
|
|
18847
18905
|
msgHash = calculateInvokeTransactionHash2({
|
|
18848
18906
|
...det,
|
|
@@ -18860,7 +18918,7 @@ ${indent}}` : "}";
|
|
|
18860
18918
|
async signDeployAccountTransaction(details) {
|
|
18861
18919
|
const compiledConstructorCalldata = CallData.compile(details.constructorCalldata);
|
|
18862
18920
|
let msgHash;
|
|
18863
|
-
if (Object.values(
|
|
18921
|
+
if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
18864
18922
|
const det = details;
|
|
18865
18923
|
msgHash = calculateDeployAccountTransactionHash3({
|
|
18866
18924
|
...det,
|
|
@@ -18877,7 +18935,7 @@ ${indent}}` : "}";
|
|
|
18877
18935
|
}
|
|
18878
18936
|
async signDeclareTransaction(details) {
|
|
18879
18937
|
let msgHash;
|
|
18880
|
-
if (Object.values(
|
|
18938
|
+
if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
18881
18939
|
const det = details;
|
|
18882
18940
|
msgHash = calculateDeclareTransactionHash3({
|
|
18883
18941
|
...det,
|
|
@@ -18939,7 +18997,7 @@ ${indent}}` : "}";
|
|
|
18939
18997
|
async signTransaction(transactions, details) {
|
|
18940
18998
|
const compiledCalldata = getExecuteCalldata(transactions, details.cairoVersion);
|
|
18941
18999
|
let msgHash;
|
|
18942
|
-
if (Object.values(
|
|
19000
|
+
if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
18943
19001
|
const det = details;
|
|
18944
19002
|
msgHash = calculateInvokeTransactionHash2({
|
|
18945
19003
|
...det,
|
|
@@ -18961,7 +19019,7 @@ ${indent}}` : "}";
|
|
|
18961
19019
|
async signDeployAccountTransaction(details) {
|
|
18962
19020
|
const compiledConstructorCalldata = CallData.compile(details.constructorCalldata);
|
|
18963
19021
|
let msgHash;
|
|
18964
|
-
if (Object.values(
|
|
19022
|
+
if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
18965
19023
|
const det = details;
|
|
18966
19024
|
msgHash = calculateDeployAccountTransactionHash3({
|
|
18967
19025
|
...det,
|
|
@@ -18982,7 +19040,7 @@ ${indent}}` : "}";
|
|
|
18982
19040
|
}
|
|
18983
19041
|
async signDeclareTransaction(details) {
|
|
18984
19042
|
let msgHash;
|
|
18985
|
-
if (Object.values(
|
|
19043
|
+
if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
18986
19044
|
const det = details;
|
|
18987
19045
|
msgHash = calculateDeclareTransactionHash3({
|
|
18988
19046
|
...det,
|
|
@@ -19155,7 +19213,7 @@ ${indent}}` : "}";
|
|
|
19155
19213
|
async signTransaction(transactions, transactionsDetail) {
|
|
19156
19214
|
const compiledCalldata = getExecuteCalldata(transactions, transactionsDetail.cairoVersion);
|
|
19157
19215
|
let msgHash;
|
|
19158
|
-
if (Object.values(
|
|
19216
|
+
if (Object.values(ETransactionVersion32).includes(transactionsDetail.version)) {
|
|
19159
19217
|
const det = transactionsDetail;
|
|
19160
19218
|
msgHash = calculateInvokeTransactionHash2({
|
|
19161
19219
|
...det,
|
|
@@ -19185,7 +19243,7 @@ ${indent}}` : "}";
|
|
|
19185
19243
|
async signDeployAccountTransaction(details) {
|
|
19186
19244
|
const compiledConstructorCalldata = CallData.compile(details.constructorCalldata);
|
|
19187
19245
|
let msgHash;
|
|
19188
|
-
if (Object.values(
|
|
19246
|
+
if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
19189
19247
|
const det = details;
|
|
19190
19248
|
msgHash = calculateDeployAccountTransactionHash3({
|
|
19191
19249
|
...det,
|
|
@@ -19214,7 +19272,7 @@ ${indent}}` : "}";
|
|
|
19214
19272
|
*/
|
|
19215
19273
|
async signDeclareTransaction(details) {
|
|
19216
19274
|
let msgHash;
|
|
19217
|
-
if (Object.values(
|
|
19275
|
+
if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
19218
19276
|
const det = details;
|
|
19219
19277
|
msgHash = calculateDeclareTransactionHash3({
|
|
19220
19278
|
...det,
|
|
@@ -19373,7 +19431,7 @@ ${indent}}` : "}";
|
|
|
19373
19431
|
*/
|
|
19374
19432
|
async signTransaction(transactions, transactionsDetail) {
|
|
19375
19433
|
const compiledCalldata = getExecuteCalldata(transactions, transactionsDetail.cairoVersion);
|
|
19376
|
-
if (Object.values(
|
|
19434
|
+
if (Object.values(ETransactionVersion32).includes(transactionsDetail.version)) {
|
|
19377
19435
|
const det = transactionsDetail;
|
|
19378
19436
|
const msgHash = calculateInvokeTransactionHash2({
|
|
19379
19437
|
...det,
|
|
@@ -19407,7 +19465,7 @@ ${indent}}` : "}";
|
|
|
19407
19465
|
async signDeployAccountTransaction(details) {
|
|
19408
19466
|
const compiledConstructorCalldata = CallData.compile(details.constructorCalldata);
|
|
19409
19467
|
let msgHash;
|
|
19410
|
-
if (Object.values(
|
|
19468
|
+
if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
19411
19469
|
const det = details;
|
|
19412
19470
|
msgHash = calculateDeployAccountTransactionHash3({
|
|
19413
19471
|
...det,
|
|
@@ -19513,8 +19571,8 @@ ${indent}}` : "}";
|
|
|
19513
19571
|
const nonceBuf = this.convertBnToLedger(txDetails.nonce);
|
|
19514
19572
|
const dAModeHashBuf = this.convertBnToLedger(
|
|
19515
19573
|
hashDAMode(
|
|
19516
|
-
txDetails.nonceDataAvailabilityMode ===
|
|
19517
|
-
txDetails.feeDataAvailabilityMode ===
|
|
19574
|
+
txDetails.nonceDataAvailabilityMode === EDataAvailabilityMode2.L1 ? EDAMode2.L1 : EDAMode2.L2,
|
|
19575
|
+
txDetails.feeDataAvailabilityMode === EDataAvailabilityMode2.L1 ? EDAMode2.L1 : EDAMode2.L2
|
|
19518
19576
|
)
|
|
19519
19577
|
);
|
|
19520
19578
|
const l1_gasBuf = this.convertBnToLedger(encodeResourceBoundsL1(txDetails.resourceBounds));
|
|
@@ -19596,8 +19654,8 @@ ${indent}}` : "}";
|
|
|
19596
19654
|
const nonceBuf = this.convertBnToLedger(deployAccountDetail.nonce);
|
|
19597
19655
|
const dAModeHashBuf = this.convertBnToLedger(
|
|
19598
19656
|
hashDAMode(
|
|
19599
|
-
deployAccountDetail.nonceDataAvailabilityMode ===
|
|
19600
|
-
deployAccountDetail.feeDataAvailabilityMode ===
|
|
19657
|
+
deployAccountDetail.nonceDataAvailabilityMode === EDataAvailabilityMode2.L1 ? EDAMode2.L1 : EDAMode2.L2,
|
|
19658
|
+
deployAccountDetail.feeDataAvailabilityMode === EDataAvailabilityMode2.L1 ? EDAMode2.L1 : EDAMode2.L2
|
|
19601
19659
|
)
|
|
19602
19660
|
);
|
|
19603
19661
|
const classHashBuf = this.convertBnToLedger(deployAccountDetail.classHash);
|
|
@@ -20166,7 +20224,7 @@ ${indent}}` : "}";
|
|
|
20166
20224
|
feeMode: convertFEE_MODE(parameters.fee_mode),
|
|
20167
20225
|
timeBounds: convertTIME_BOUNDS(parameters.time_bounds)
|
|
20168
20226
|
});
|
|
20169
|
-
var
|
|
20227
|
+
var defaultOptions = {
|
|
20170
20228
|
headers: { "Content-Type": "application/json" }
|
|
20171
20229
|
};
|
|
20172
20230
|
var PaymasterRpc = class _PaymasterRpc {
|
|
@@ -20177,14 +20235,14 @@ ${indent}}` : "}";
|
|
|
20177
20235
|
constructor(options) {
|
|
20178
20236
|
if (options instanceof _PaymasterRpc) {
|
|
20179
20237
|
this.nodeUrl = options.nodeUrl;
|
|
20180
|
-
this.headers = { ...
|
|
20238
|
+
this.headers = { ...defaultOptions.headers, ...options.headers };
|
|
20181
20239
|
this.baseFetch = options.baseFetch;
|
|
20182
20240
|
this.requestId = options.requestId;
|
|
20183
20241
|
return;
|
|
20184
20242
|
}
|
|
20185
20243
|
if (options && "nodeUrl" in options && "headers" in options && "baseFetch" in options) {
|
|
20186
20244
|
this.nodeUrl = options.nodeUrl ?? getDefaultPaymasterNodeUrl(void 0);
|
|
20187
|
-
this.headers = { ...
|
|
20245
|
+
this.headers = { ...defaultOptions.headers, ...options.headers };
|
|
20188
20246
|
this.baseFetch = options.baseFetch ?? fetch_default;
|
|
20189
20247
|
this.requestId = 0;
|
|
20190
20248
|
return;
|
|
@@ -20198,7 +20256,7 @@ ${indent}}` : "}";
|
|
|
20198
20256
|
this.nodeUrl = getDefaultPaymasterNodeUrl(void 0, options?.default);
|
|
20199
20257
|
}
|
|
20200
20258
|
this.baseFetch = baseFetch ?? fetch_default;
|
|
20201
|
-
this.headers = { ...
|
|
20259
|
+
this.headers = { ...defaultOptions.headers, ...headers };
|
|
20202
20260
|
this.requestId = 0;
|
|
20203
20261
|
}
|
|
20204
20262
|
fetch(method, params, id = 0) {
|
|
@@ -20512,7 +20570,7 @@ ${indent}}` : "}";
|
|
|
20512
20570
|
}
|
|
20513
20571
|
// TODO: TT Cairo version is still needed for invoke on existing contracts
|
|
20514
20572
|
async estimateInvokeFee(calls, details = {}) {
|
|
20515
|
-
const invocations = [{ type:
|
|
20573
|
+
const invocations = [{ type: ETransactionType2.INVOKE, payload: [calls].flat() }];
|
|
20516
20574
|
const estimateBulk = await this.estimateFeeBulk(invocations, details);
|
|
20517
20575
|
return estimateBulk[0];
|
|
20518
20576
|
}
|
|
@@ -20523,7 +20581,7 @@ ${indent}}` : "}";
|
|
|
20523
20581
|
);
|
|
20524
20582
|
const invocations = [
|
|
20525
20583
|
{
|
|
20526
|
-
type:
|
|
20584
|
+
type: ETransactionType2.DECLARE,
|
|
20527
20585
|
payload: extractContractHashes(payload, await this.channel.getStarknetVersion())
|
|
20528
20586
|
}
|
|
20529
20587
|
];
|
|
@@ -20540,7 +20598,7 @@ ${indent}}` : "}";
|
|
|
20540
20598
|
const contractAddressFinal = contractAddress ?? calculateContractAddressFromHash(addressSalt, classHash, compiledCalldata, 0);
|
|
20541
20599
|
const invocations = [
|
|
20542
20600
|
{
|
|
20543
|
-
type:
|
|
20601
|
+
type: ETransactionType2.DEPLOY_ACCOUNT,
|
|
20544
20602
|
payload: {
|
|
20545
20603
|
classHash,
|
|
20546
20604
|
constructorCalldata: compiledCalldata,
|
|
@@ -20613,7 +20671,7 @@ ${indent}}` : "}";
|
|
|
20613
20671
|
resourceBounds = estimateResponse.resourceBounds;
|
|
20614
20672
|
}
|
|
20615
20673
|
const accountInvocations = await this.accountInvocationsFactory(
|
|
20616
|
-
[{ type:
|
|
20674
|
+
[{ type: ETransactionType2.INVOKE, payload: calls }],
|
|
20617
20675
|
{
|
|
20618
20676
|
...v3Details(detailsWithTip),
|
|
20619
20677
|
resourceBounds,
|
|
@@ -20712,7 +20770,7 @@ ${indent}}` : "}";
|
|
|
20712
20770
|
resourceBounds = estimateResponse.resourceBounds;
|
|
20713
20771
|
}
|
|
20714
20772
|
const accountInvocations = await this.accountInvocationsFactory(
|
|
20715
|
-
[{ type:
|
|
20773
|
+
[{ type: ETransactionType2.DECLARE, payload: declareContractPayload }],
|
|
20716
20774
|
{
|
|
20717
20775
|
...v3Details(detailsWithTip),
|
|
20718
20776
|
resourceBounds,
|
|
@@ -20791,7 +20849,7 @@ ${indent}}` : "}";
|
|
|
20791
20849
|
const accountInvocations = await this.accountInvocationsFactory(
|
|
20792
20850
|
[
|
|
20793
20851
|
{
|
|
20794
|
-
type:
|
|
20852
|
+
type: ETransactionType2.DEPLOY_ACCOUNT,
|
|
20795
20853
|
payload: {
|
|
20796
20854
|
classHash,
|
|
20797
20855
|
constructorCalldata: compiledCalldata,
|
|
@@ -21063,7 +21121,7 @@ ${indent}}` : "}";
|
|
|
21063
21121
|
const chainId = await this.getChainId();
|
|
21064
21122
|
const versions = details.versions.map((it) => toTransactionVersion(it));
|
|
21065
21123
|
const tx0Payload = "payload" in invocations[0] ? invocations[0].payload : invocations[0];
|
|
21066
|
-
const cairoVersion = invocations[0].type ===
|
|
21124
|
+
const cairoVersion = invocations[0].type === ETransactionType2.DEPLOY_ACCOUNT ? await this.getCairoVersion(tx0Payload.classHash) : await this.getCairoVersion();
|
|
21067
21125
|
return Promise.all(
|
|
21068
21126
|
[].concat(invocations).map(async (transaction, index) => {
|
|
21069
21127
|
const txPayload = "payload" in transaction ? transaction.payload : transaction;
|
|
@@ -21082,7 +21140,7 @@ ${indent}}` : "}";
|
|
|
21082
21140
|
blockIdentifier,
|
|
21083
21141
|
version: versions[0]
|
|
21084
21142
|
};
|
|
21085
|
-
if (transaction.type ===
|
|
21143
|
+
if (transaction.type === ETransactionType2.INVOKE) {
|
|
21086
21144
|
const payload = await this.buildInvocation(
|
|
21087
21145
|
[].concat(txPayload),
|
|
21088
21146
|
signerDetails
|
|
@@ -21093,17 +21151,17 @@ ${indent}}` : "}";
|
|
|
21093
21151
|
...signerDetails
|
|
21094
21152
|
};
|
|
21095
21153
|
}
|
|
21096
|
-
if (transaction.type ===
|
|
21154
|
+
if (transaction.type === ETransactionType2.DEPLOY) {
|
|
21097
21155
|
const { calls } = this.deployer.buildDeployerCall(txPayload, this.address);
|
|
21098
21156
|
const payload = await this.buildInvocation(calls, signerDetails);
|
|
21099
21157
|
return {
|
|
21100
21158
|
...common2,
|
|
21101
21159
|
...payload,
|
|
21102
21160
|
...signerDetails,
|
|
21103
|
-
type:
|
|
21161
|
+
type: ETransactionType2.INVOKE
|
|
21104
21162
|
};
|
|
21105
21163
|
}
|
|
21106
|
-
if (transaction.type ===
|
|
21164
|
+
if (transaction.type === ETransactionType2.DECLARE) {
|
|
21107
21165
|
assert(
|
|
21108
21166
|
isSierra(txPayload.contract),
|
|
21109
21167
|
"Declare fee estimation is not supported for Cairo0 contracts"
|
|
@@ -21115,7 +21173,7 @@ ${indent}}` : "}";
|
|
|
21115
21173
|
...signerDetails
|
|
21116
21174
|
};
|
|
21117
21175
|
}
|
|
21118
|
-
if (transaction.type ===
|
|
21176
|
+
if (transaction.type === ETransactionType2.DEPLOY_ACCOUNT) {
|
|
21119
21177
|
const payload = await this.buildAccountDeployPayload(txPayload, signerDetails);
|
|
21120
21178
|
return {
|
|
21121
21179
|
...common2,
|
|
@@ -21590,7 +21648,10 @@ ${indent}}` : "}";
|
|
|
21590
21648
|
// src/utils/events/index.ts
|
|
21591
21649
|
var events_exports = {};
|
|
21592
21650
|
__export(events_exports, {
|
|
21651
|
+
addGetByPathMethod: () => addGetByPathMethod,
|
|
21652
|
+
filterEventsByAddress: () => filterEventsByAddress,
|
|
21593
21653
|
getAbiEvents: () => getAbiEvents,
|
|
21654
|
+
getEmittedEvents: () => getEmittedEvents,
|
|
21594
21655
|
isAbiEvent: () => isAbiEvent,
|
|
21595
21656
|
parseEvents: () => parseEvents
|
|
21596
21657
|
});
|
|
@@ -21664,52 +21725,79 @@ ${indent}}` : "}";
|
|
|
21664
21725
|
return output;
|
|
21665
21726
|
}
|
|
21666
21727
|
function parseEvents(providerReceivedEvents, abiEvents, abiStructs, abiEnums, parser) {
|
|
21667
|
-
const ret = providerReceivedEvents.
|
|
21668
|
-
const
|
|
21669
|
-
|
|
21728
|
+
const ret = providerReceivedEvents.reduce((acc, recEvent) => {
|
|
21729
|
+
const eventKeys = [...recEvent.keys];
|
|
21730
|
+
const eventData = [...recEvent.data];
|
|
21731
|
+
let abiEvent = abiEvents[eventKeys.shift() ?? 0];
|
|
21670
21732
|
if (!abiEvent) {
|
|
21671
21733
|
return acc;
|
|
21672
21734
|
}
|
|
21673
21735
|
while (!abiEvent.name) {
|
|
21674
|
-
const hashName =
|
|
21736
|
+
const hashName = eventKeys.shift();
|
|
21675
21737
|
assert(!!hashName, 'Not enough data in "keys" property of this event.');
|
|
21676
21738
|
abiEvent = abiEvent[hashName];
|
|
21677
21739
|
}
|
|
21678
|
-
const
|
|
21679
|
-
parsedEvent
|
|
21680
|
-
const
|
|
21681
|
-
|
|
21740
|
+
const { from_address: _from, keys: _keys, data: _data, ...eventMetadata } = recEvent;
|
|
21741
|
+
const parsedEvent = eventMetadata;
|
|
21742
|
+
const eventName = abiEvent.name;
|
|
21743
|
+
parsedEvent[eventName] = {};
|
|
21744
|
+
const keysIter = eventKeys[Symbol.iterator]();
|
|
21745
|
+
const dataIter = eventData[Symbol.iterator]();
|
|
21682
21746
|
const abiEventKeys = abiEvent.members?.filter((it) => it.kind === "key") || abiEvent.keys;
|
|
21683
21747
|
const abiEventData = abiEvent.members?.filter((it) => it.kind === "data") || abiEvent.data;
|
|
21748
|
+
const parsedEventData = parsedEvent[eventName];
|
|
21684
21749
|
abiEventKeys.forEach((key) => {
|
|
21685
|
-
|
|
21750
|
+
parsedEventData[key.name] = responseParser({
|
|
21686
21751
|
responseIterator: keysIter,
|
|
21687
21752
|
output: key,
|
|
21688
21753
|
structs: abiStructs,
|
|
21689
21754
|
enums: abiEnums,
|
|
21690
21755
|
parser,
|
|
21691
|
-
parsedResult:
|
|
21756
|
+
parsedResult: parsedEventData
|
|
21692
21757
|
});
|
|
21693
21758
|
});
|
|
21694
21759
|
abiEventData.forEach((data) => {
|
|
21695
|
-
|
|
21760
|
+
parsedEventData[data.name] = responseParser({
|
|
21696
21761
|
responseIterator: dataIter,
|
|
21697
21762
|
output: data,
|
|
21698
21763
|
structs: abiStructs,
|
|
21699
21764
|
enums: abiEnums,
|
|
21700
21765
|
parser,
|
|
21701
|
-
parsedResult:
|
|
21766
|
+
parsedResult: parsedEventData
|
|
21702
21767
|
});
|
|
21703
21768
|
});
|
|
21704
|
-
if ("block_hash" in currentEvent) parsedEvent.block_hash = currentEvent.block_hash;
|
|
21705
|
-
if ("block_number" in currentEvent) parsedEvent.block_number = currentEvent.block_number;
|
|
21706
|
-
if ("transaction_hash" in currentEvent)
|
|
21707
|
-
parsedEvent.transaction_hash = currentEvent.transaction_hash;
|
|
21708
21769
|
acc.push(parsedEvent);
|
|
21709
21770
|
return acc;
|
|
21710
21771
|
}, []);
|
|
21711
21772
|
return ret;
|
|
21712
21773
|
}
|
|
21774
|
+
function addGetByPathMethod(parsedEvents) {
|
|
21775
|
+
Object.defineProperty(parsedEvents, "getByPath", {
|
|
21776
|
+
value: (path) => {
|
|
21777
|
+
const event = parsedEvents.find((ev) => Object.keys(ev).some((key) => key.includes(path)));
|
|
21778
|
+
const eventKey = Object.keys(event || {}).find((key) => key.includes(path));
|
|
21779
|
+
return eventKey && event ? event[eventKey] : null;
|
|
21780
|
+
},
|
|
21781
|
+
writable: false,
|
|
21782
|
+
enumerable: false,
|
|
21783
|
+
configurable: false
|
|
21784
|
+
});
|
|
21785
|
+
return parsedEvents;
|
|
21786
|
+
}
|
|
21787
|
+
function getEmittedEvents(receipt, contractAddress) {
|
|
21788
|
+
if (!receipt.events) return [];
|
|
21789
|
+
const eventsToEnrich = contractAddress ? filterEventsByAddress(receipt.events, contractAddress) : receipt.events;
|
|
21790
|
+
return eventsToEnrich.map((event) => ({
|
|
21791
|
+
...event,
|
|
21792
|
+
transaction_hash: receipt.transaction_hash,
|
|
21793
|
+
block_hash: receipt.block_hash,
|
|
21794
|
+
block_number: receipt.block_number
|
|
21795
|
+
}));
|
|
21796
|
+
}
|
|
21797
|
+
function filterEventsByAddress(events, contractAddress) {
|
|
21798
|
+
if (!events) return [];
|
|
21799
|
+
return events.filter((event) => toHex(event.from_address) === toHex(contractAddress));
|
|
21800
|
+
}
|
|
21713
21801
|
|
|
21714
21802
|
// src/contract/default.ts
|
|
21715
21803
|
function buildCall(contract, functionAbi) {
|
|
@@ -21970,45 +22058,19 @@ ${indent}}` : "}";
|
|
|
21970
22058
|
calldata
|
|
21971
22059
|
};
|
|
21972
22060
|
}
|
|
21973
|
-
// TODO: Demistify what is going on here ???
|
|
21974
|
-
// TODO: receipt status filtering test and fix this do not look right
|
|
21975
22061
|
parseEvents(receipt) {
|
|
21976
|
-
|
|
21977
|
-
|
|
21978
|
-
|
|
21979
|
-
|
|
21980
|
-
|
|
21981
|
-
|
|
21982
|
-
|
|
21983
|
-
|
|
21984
|
-
|
|
21985
|
-
|
|
21986
|
-
|
|
21987
|
-
|
|
21988
|
-
}).filter((event) => toHex(event.from_address) === toHex(this.address), []) || [];
|
|
21989
|
-
parsed = parseEvents(
|
|
21990
|
-
emittedEvents,
|
|
21991
|
-
this.events,
|
|
21992
|
-
this.structs,
|
|
21993
|
-
CallData.getAbiEnum(this.abi),
|
|
21994
|
-
this.callData.parser
|
|
21995
|
-
);
|
|
21996
|
-
},
|
|
21997
|
-
_: () => {
|
|
21998
|
-
throw Error("This transaction was not successful.");
|
|
21999
|
-
}
|
|
22000
|
-
});
|
|
22001
|
-
Object.defineProperty(parsed, "getByPath", {
|
|
22002
|
-
value: (path) => {
|
|
22003
|
-
const event = parsed.find((ev) => Object.keys(ev).some((key) => key.includes(path)));
|
|
22004
|
-
const eventKey = Object.keys(event || {}).find((key) => key.includes(path));
|
|
22005
|
-
return eventKey && event ? event[eventKey] : null;
|
|
22006
|
-
},
|
|
22007
|
-
writable: false,
|
|
22008
|
-
enumerable: false,
|
|
22009
|
-
configurable: false
|
|
22010
|
-
});
|
|
22011
|
-
return parsed;
|
|
22062
|
+
if (!receipt.isSuccess()) {
|
|
22063
|
+
throw Error("This transaction was not successful.");
|
|
22064
|
+
}
|
|
22065
|
+
return addGetByPathMethod(
|
|
22066
|
+
parseEvents(
|
|
22067
|
+
getEmittedEvents(receipt.value, this.address),
|
|
22068
|
+
this.events,
|
|
22069
|
+
this.structs,
|
|
22070
|
+
CallData.getAbiEnum(this.abi),
|
|
22071
|
+
this.callData.parser
|
|
22072
|
+
)
|
|
22073
|
+
);
|
|
22012
22074
|
}
|
|
22013
22075
|
isCairo1() {
|
|
22014
22076
|
return cairo_exports.isCairo1Abi(this.abi);
|