starknet 9.2.0 → 9.2.2
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 +172 -118
- package/dist/index.global.js +173 -169
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +60 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -57
- 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
|
|
@@ -1200,7 +1200,7 @@ var starknet = (() => {
|
|
|
1200
1200
|
};
|
|
1201
1201
|
var DEFAULT_GLOBAL_CONFIG = {
|
|
1202
1202
|
rpcVersion: "0.10.0",
|
|
1203
|
-
transactionVersion:
|
|
1203
|
+
transactionVersion: ETransactionVersion4.V3,
|
|
1204
1204
|
// Starknet 0.14.0 only V3 transactions
|
|
1205
1205
|
logLevel: "INFO",
|
|
1206
1206
|
resourceBoundsOverhead: {
|
|
@@ -9230,7 +9230,7 @@ ${indent}}` : "}";
|
|
|
9230
9230
|
|
|
9231
9231
|
// src/utils/hash/transactionHash/index.ts
|
|
9232
9232
|
function isV3InvokeTx(args) {
|
|
9233
|
-
return [
|
|
9233
|
+
return [ETransactionVersion4.V3, ETransactionVersion4.F3].includes(args.version);
|
|
9234
9234
|
}
|
|
9235
9235
|
function calculateInvokeTransactionHash2(args) {
|
|
9236
9236
|
if (isV3InvokeTx(args)) {
|
|
@@ -9251,7 +9251,7 @@ ${indent}}` : "}";
|
|
|
9251
9251
|
throw new Error("Invalid Tx version for hash calculation");
|
|
9252
9252
|
}
|
|
9253
9253
|
function isV3DeclareTx(args) {
|
|
9254
|
-
return [
|
|
9254
|
+
return [ETransactionVersion4.V3, ETransactionVersion4.F3].includes(args.version);
|
|
9255
9255
|
}
|
|
9256
9256
|
function calculateDeclareTransactionHash3(args) {
|
|
9257
9257
|
if (isV3DeclareTx(args)) {
|
|
@@ -9273,7 +9273,7 @@ ${indent}}` : "}";
|
|
|
9273
9273
|
throw new Error("Invalid Tx version for hash calculation");
|
|
9274
9274
|
}
|
|
9275
9275
|
function isV3DeployAccountTx(args) {
|
|
9276
|
-
return [
|
|
9276
|
+
return [ETransactionVersion4.V3, ETransactionVersion4.F3].includes(args.version);
|
|
9277
9277
|
}
|
|
9278
9278
|
function calculateDeployAccountTransactionHash3(args) {
|
|
9279
9279
|
if (isV3DeployAccountTx(args)) {
|
|
@@ -10003,7 +10003,7 @@ ${indent}}` : "}";
|
|
|
10003
10003
|
return 0;
|
|
10004
10004
|
}
|
|
10005
10005
|
function isPreConfirmedBlock(response) {
|
|
10006
|
-
return response.status ===
|
|
10006
|
+
return response.status === EBlockStatus2.PRE_CONFIRMED;
|
|
10007
10007
|
}
|
|
10008
10008
|
function isPreConfirmedTransaction(response) {
|
|
10009
10009
|
return !("block_hash" in response);
|
|
@@ -15466,7 +15466,7 @@ ${indent}}` : "}";
|
|
|
15466
15466
|
async invoke(functionInvocation, details) {
|
|
15467
15467
|
const transaction = this.buildTransaction(
|
|
15468
15468
|
{
|
|
15469
|
-
type:
|
|
15469
|
+
type: ETransactionType2.INVOKE,
|
|
15470
15470
|
...functionInvocation,
|
|
15471
15471
|
...details
|
|
15472
15472
|
},
|
|
@@ -15480,7 +15480,7 @@ ${indent}}` : "}";
|
|
|
15480
15480
|
async declare(declareTransaction, details) {
|
|
15481
15481
|
const transaction = this.buildTransaction(
|
|
15482
15482
|
{
|
|
15483
|
-
type:
|
|
15483
|
+
type: ETransactionType2.DECLARE,
|
|
15484
15484
|
...declareTransaction,
|
|
15485
15485
|
...details
|
|
15486
15486
|
},
|
|
@@ -15494,7 +15494,7 @@ ${indent}}` : "}";
|
|
|
15494
15494
|
async deployAccount(deployAccountTransaction, details) {
|
|
15495
15495
|
const transaction = this.buildTransaction(
|
|
15496
15496
|
{
|
|
15497
|
-
type:
|
|
15497
|
+
type: ETransactionType2.DEPLOY_ACCOUNT,
|
|
15498
15498
|
...deployAccountTransaction,
|
|
15499
15499
|
...details
|
|
15500
15500
|
},
|
|
@@ -15567,7 +15567,7 @@ ${indent}}` : "}";
|
|
|
15567
15567
|
account_deployment_data: invocation.accountDeploymentData.map((it) => toHex(it)),
|
|
15568
15568
|
version: toTransactionVersion(defaultVersions.v3, invocation.version)
|
|
15569
15569
|
};
|
|
15570
|
-
if (invocation.type ===
|
|
15570
|
+
if (invocation.type === ETransactionType2.INVOKE) {
|
|
15571
15571
|
const btx = {
|
|
15572
15572
|
type: esm_exports.ETransactionType.INVOKE,
|
|
15573
15573
|
sender_address: invocation.contractAddress,
|
|
@@ -15576,7 +15576,7 @@ ${indent}}` : "}";
|
|
|
15576
15576
|
};
|
|
15577
15577
|
return btx;
|
|
15578
15578
|
}
|
|
15579
|
-
if (invocation.type ===
|
|
15579
|
+
if (invocation.type === ETransactionType2.DECLARE) {
|
|
15580
15580
|
assert(isSierra(invocation.contract), "Declaring non Sierra contract using RPC 0.9");
|
|
15581
15581
|
const btx = {
|
|
15582
15582
|
type: invocation.type,
|
|
@@ -15590,7 +15590,7 @@ ${indent}}` : "}";
|
|
|
15590
15590
|
};
|
|
15591
15591
|
return btx;
|
|
15592
15592
|
}
|
|
15593
|
-
if (invocation.type ===
|
|
15593
|
+
if (invocation.type === ETransactionType2.DEPLOY_ACCOUNT) {
|
|
15594
15594
|
const { account_deployment_data, ...restDetails } = details;
|
|
15595
15595
|
const btx = {
|
|
15596
15596
|
type: invocation.type,
|
|
@@ -16064,7 +16064,7 @@ ${indent}}` : "}";
|
|
|
16064
16064
|
async invoke(functionInvocation, details) {
|
|
16065
16065
|
const transaction = this.buildTransaction(
|
|
16066
16066
|
{
|
|
16067
|
-
type:
|
|
16067
|
+
type: ETransactionType2.INVOKE,
|
|
16068
16068
|
...functionInvocation,
|
|
16069
16069
|
...details
|
|
16070
16070
|
},
|
|
@@ -16078,7 +16078,7 @@ ${indent}}` : "}";
|
|
|
16078
16078
|
async declare(declareTransaction, details) {
|
|
16079
16079
|
const transaction = this.buildTransaction(
|
|
16080
16080
|
{
|
|
16081
|
-
type:
|
|
16081
|
+
type: ETransactionType2.DECLARE,
|
|
16082
16082
|
...declareTransaction,
|
|
16083
16083
|
...details
|
|
16084
16084
|
},
|
|
@@ -16092,7 +16092,7 @@ ${indent}}` : "}";
|
|
|
16092
16092
|
async deployAccount(deployAccountTransaction, details) {
|
|
16093
16093
|
const transaction = this.buildTransaction(
|
|
16094
16094
|
{
|
|
16095
|
-
type:
|
|
16095
|
+
type: ETransactionType2.DEPLOY_ACCOUNT,
|
|
16096
16096
|
...deployAccountTransaction,
|
|
16097
16097
|
...details
|
|
16098
16098
|
},
|
|
@@ -16165,7 +16165,7 @@ ${indent}}` : "}";
|
|
|
16165
16165
|
account_deployment_data: invocation.accountDeploymentData.map((it) => toHex(it)),
|
|
16166
16166
|
version: toTransactionVersion(defaultVersions.v3, invocation.version)
|
|
16167
16167
|
};
|
|
16168
|
-
if (invocation.type ===
|
|
16168
|
+
if (invocation.type === ETransactionType2.INVOKE) {
|
|
16169
16169
|
const btx = {
|
|
16170
16170
|
type: esm_exports2.ETransactionType.INVOKE,
|
|
16171
16171
|
sender_address: invocation.contractAddress,
|
|
@@ -16174,7 +16174,7 @@ ${indent}}` : "}";
|
|
|
16174
16174
|
};
|
|
16175
16175
|
return btx;
|
|
16176
16176
|
}
|
|
16177
|
-
if (invocation.type ===
|
|
16177
|
+
if (invocation.type === ETransactionType2.DECLARE) {
|
|
16178
16178
|
assert(isSierra(invocation.contract), "Declaring non Sierra contract using RPC 0.9");
|
|
16179
16179
|
const btx = {
|
|
16180
16180
|
type: invocation.type,
|
|
@@ -16188,7 +16188,7 @@ ${indent}}` : "}";
|
|
|
16188
16188
|
};
|
|
16189
16189
|
return btx;
|
|
16190
16190
|
}
|
|
16191
|
-
if (invocation.type ===
|
|
16191
|
+
if (invocation.type === ETransactionType2.DEPLOY_ACCOUNT) {
|
|
16192
16192
|
const { account_deployment_data, ...restDetails } = details;
|
|
16193
16193
|
const btx = {
|
|
16194
16194
|
type: invocation.type,
|
|
@@ -16339,7 +16339,7 @@ ${indent}}` : "}";
|
|
|
16339
16339
|
}
|
|
16340
16340
|
};
|
|
16341
16341
|
|
|
16342
|
-
// src/channel/ws/
|
|
16342
|
+
// src/channel/ws/ws_0_10.ts
|
|
16343
16343
|
var WebSocketChannel = class {
|
|
16344
16344
|
/**
|
|
16345
16345
|
* The URL of the WebSocket RPC Node.
|
|
@@ -17332,14 +17332,14 @@ ${indent}}` : "}";
|
|
|
17332
17332
|
)
|
|
17333
17333
|
};
|
|
17334
17334
|
var revisionConfiguration = {
|
|
17335
|
-
[
|
|
17335
|
+
[TypedDataRevision2.ACTIVE]: {
|
|
17336
17336
|
domain: "StarknetDomain",
|
|
17337
17337
|
hashMethod: computePoseidonHashOnElements,
|
|
17338
17338
|
hashMerkleMethod: computePoseidonHash,
|
|
17339
17339
|
escapeTypeString: (s) => `"${s}"`,
|
|
17340
17340
|
presetTypes
|
|
17341
17341
|
},
|
|
17342
|
-
[
|
|
17342
|
+
[TypedDataRevision2.LEGACY]: {
|
|
17343
17343
|
domain: "StarkNetDomain",
|
|
17344
17344
|
hashMethod: computePedersenHashOnElements,
|
|
17345
17345
|
hashMerkleMethod: computePedersenHash,
|
|
@@ -17352,10 +17352,10 @@ ${indent}}` : "}";
|
|
|
17352
17352
|
assert(value >= min && value <= max, `${value} (${type}) is out of bounds [${min}, ${max}]`);
|
|
17353
17353
|
}
|
|
17354
17354
|
function identifyRevision({ types, domain }) {
|
|
17355
|
-
if (revisionConfiguration[
|
|
17356
|
-
return
|
|
17357
|
-
if (revisionConfiguration[
|
|
17358
|
-
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;
|
|
17359
17359
|
return void 0;
|
|
17360
17360
|
}
|
|
17361
17361
|
function getHex(value) {
|
|
@@ -17380,11 +17380,11 @@ ${indent}}` : "}";
|
|
|
17380
17380
|
function isMerkleTreeType(type) {
|
|
17381
17381
|
return type.type === "merkletree";
|
|
17382
17382
|
}
|
|
17383
|
-
function getDependencies(types, type, dependencies = [], contains = "", revision =
|
|
17383
|
+
function getDependencies(types, type, dependencies = [], contains = "", revision = TypedDataRevision2.LEGACY) {
|
|
17384
17384
|
let dependencyTypes = [type];
|
|
17385
17385
|
if (type[type.length - 1] === "*") {
|
|
17386
17386
|
dependencyTypes = [type.slice(0, -1)];
|
|
17387
|
-
} else if (revision ===
|
|
17387
|
+
} else if (revision === TypedDataRevision2.ACTIVE) {
|
|
17388
17388
|
if (type === "enum") {
|
|
17389
17389
|
dependencyTypes = [contains];
|
|
17390
17390
|
} else if (type.match(/^\(.*\)$/)) {
|
|
@@ -17426,8 +17426,8 @@ ${indent}}` : "}";
|
|
|
17426
17426
|
}
|
|
17427
17427
|
return "raw";
|
|
17428
17428
|
}
|
|
17429
|
-
function encodeType(types, type, revision =
|
|
17430
|
-
const allTypes = revision ===
|
|
17429
|
+
function encodeType(types, type, revision = TypedDataRevision2.LEGACY) {
|
|
17430
|
+
const allTypes = revision === TypedDataRevision2.ACTIVE ? { ...types, ...revisionConfiguration[revision].presetTypes } : types;
|
|
17431
17431
|
const [primary, ...dependencies] = getDependencies(
|
|
17432
17432
|
allTypes,
|
|
17433
17433
|
type,
|
|
@@ -17439,17 +17439,17 @@ ${indent}}` : "}";
|
|
|
17439
17439
|
const esc = revisionConfiguration[revision].escapeTypeString;
|
|
17440
17440
|
return newTypes.map((dependency) => {
|
|
17441
17441
|
const dependencyElements = allTypes[dependency].map((t) => {
|
|
17442
|
-
const targetType = t.type === "enum" && revision ===
|
|
17442
|
+
const targetType = t.type === "enum" && revision === TypedDataRevision2.ACTIVE ? t.contains : t.type;
|
|
17443
17443
|
const typeString = targetType.match(/^\(.*\)$/) ? `(${targetType.slice(1, -1).split(",").map((e) => e ? esc(e) : e).join(",")})` : esc(targetType);
|
|
17444
17444
|
return `${esc(t.name)}:${typeString}`;
|
|
17445
17445
|
});
|
|
17446
17446
|
return `${esc(dependency)}(${dependencyElements})`;
|
|
17447
17447
|
}).join("");
|
|
17448
17448
|
}
|
|
17449
|
-
function getTypeHash(types, type, revision =
|
|
17449
|
+
function getTypeHash(types, type, revision = TypedDataRevision2.LEGACY) {
|
|
17450
17450
|
return getSelectorFromName(encodeType(types, type, revision));
|
|
17451
17451
|
}
|
|
17452
|
-
function encodeValue(types, type, data, ctx = {}, revision =
|
|
17452
|
+
function encodeValue(types, type, data, ctx = {}, revision = TypedDataRevision2.LEGACY) {
|
|
17453
17453
|
if (types[type]) {
|
|
17454
17454
|
return [type, getStructHash(types, type, data, revision)];
|
|
17455
17455
|
}
|
|
@@ -17472,7 +17472,7 @@ ${indent}}` : "}";
|
|
|
17472
17472
|
}
|
|
17473
17473
|
switch (type) {
|
|
17474
17474
|
case "enum": {
|
|
17475
|
-
if (revision ===
|
|
17475
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
17476
17476
|
const [variantKey, variantData] = Object.entries(data)[0];
|
|
17477
17477
|
const parentType = types[ctx.parent].find((t) => t.name === ctx.key);
|
|
17478
17478
|
const enumType = types[parentType.contains];
|
|
@@ -17505,7 +17505,7 @@ ${indent}}` : "}";
|
|
|
17505
17505
|
return ["felt", prepareSelector(data)];
|
|
17506
17506
|
}
|
|
17507
17507
|
case "string": {
|
|
17508
|
-
if (revision ===
|
|
17508
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
17509
17509
|
const byteArray = byteArrayFromString(data);
|
|
17510
17510
|
const elements = [
|
|
17511
17511
|
byteArray.data.length,
|
|
@@ -17518,7 +17518,7 @@ ${indent}}` : "}";
|
|
|
17518
17518
|
return [type, getHex(data)];
|
|
17519
17519
|
}
|
|
17520
17520
|
case "i128": {
|
|
17521
|
-
if (revision ===
|
|
17521
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
17522
17522
|
const value = BigInt(data);
|
|
17523
17523
|
assertRange(value, type, RANGE_I128);
|
|
17524
17524
|
return [type, getHex(value < 0n ? PRIME + value : value)];
|
|
@@ -17527,40 +17527,40 @@ ${indent}}` : "}";
|
|
|
17527
17527
|
}
|
|
17528
17528
|
case "timestamp":
|
|
17529
17529
|
case "u128": {
|
|
17530
|
-
if (revision ===
|
|
17530
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
17531
17531
|
assertRange(data, type, RANGE_U128);
|
|
17532
17532
|
}
|
|
17533
17533
|
return [type, getHex(data)];
|
|
17534
17534
|
}
|
|
17535
17535
|
case "felt":
|
|
17536
17536
|
case "shortstring": {
|
|
17537
|
-
if (revision ===
|
|
17537
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
17538
17538
|
assertRange(getHex(data), type, RANGE_FELT);
|
|
17539
17539
|
}
|
|
17540
17540
|
return [type, getHex(data)];
|
|
17541
17541
|
}
|
|
17542
17542
|
case "ClassHash":
|
|
17543
17543
|
case "ContractAddress": {
|
|
17544
|
-
if (revision ===
|
|
17544
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
17545
17545
|
assertRange(data, type, RANGE_FELT);
|
|
17546
17546
|
}
|
|
17547
17547
|
return [type, getHex(data)];
|
|
17548
17548
|
}
|
|
17549
17549
|
case "bool": {
|
|
17550
|
-
if (revision ===
|
|
17550
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
17551
17551
|
assert(isBoolean(data), `Type mismatch for ${type} ${data}`);
|
|
17552
17552
|
}
|
|
17553
17553
|
return [type, getHex(data)];
|
|
17554
17554
|
}
|
|
17555
17555
|
default: {
|
|
17556
|
-
if (revision ===
|
|
17556
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
17557
17557
|
throw new Error(`Unsupported type: ${type}`);
|
|
17558
17558
|
}
|
|
17559
17559
|
return [type, getHex(data)];
|
|
17560
17560
|
}
|
|
17561
17561
|
}
|
|
17562
17562
|
}
|
|
17563
|
-
function encodeData(types, type, data, revision =
|
|
17563
|
+
function encodeData(types, type, data, revision = TypedDataRevision2.LEGACY) {
|
|
17564
17564
|
const targetType = types[type] ?? revisionConfiguration[revision].presetTypes[type];
|
|
17565
17565
|
const [returnTypes, values] = targetType.reduce(
|
|
17566
17566
|
([ts, vs], field) => {
|
|
@@ -17579,7 +17579,7 @@ ${indent}}` : "}";
|
|
|
17579
17579
|
);
|
|
17580
17580
|
return [returnTypes, values];
|
|
17581
17581
|
}
|
|
17582
|
-
function getStructHash(types, type, data, revision =
|
|
17582
|
+
function getStructHash(types, type, data, revision = TypedDataRevision2.LEGACY) {
|
|
17583
17583
|
return revisionConfiguration[revision].hashMethod(encodeData(types, type, data, revision)[1]);
|
|
17584
17584
|
}
|
|
17585
17585
|
function getMessageHash(typedData, accountAddress) {
|
|
@@ -17930,19 +17930,19 @@ ${indent}}` : "}";
|
|
|
17930
17930
|
}
|
|
17931
17931
|
async getInvokeEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
17932
17932
|
return (await this.getEstimateFeeBulk(
|
|
17933
|
-
[{ type:
|
|
17933
|
+
[{ type: ETransactionType2.INVOKE, ...invocation, ...details }],
|
|
17934
17934
|
{ blockIdentifier, skipValidate }
|
|
17935
17935
|
))[0];
|
|
17936
17936
|
}
|
|
17937
17937
|
async getDeclareEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
17938
17938
|
return (await this.getEstimateFeeBulk(
|
|
17939
|
-
[{ type:
|
|
17939
|
+
[{ type: ETransactionType2.DECLARE, ...invocation, ...details }],
|
|
17940
17940
|
{ blockIdentifier, skipValidate }
|
|
17941
17941
|
))[0];
|
|
17942
17942
|
}
|
|
17943
17943
|
async getDeployAccountEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
17944
17944
|
return (await this.getEstimateFeeBulk(
|
|
17945
|
-
[{ type:
|
|
17945
|
+
[{ type: ETransactionType2.DEPLOY_ACCOUNT, ...invocation, ...details }],
|
|
17946
17946
|
{ blockIdentifier, skipValidate }
|
|
17947
17947
|
))[0];
|
|
17948
17948
|
}
|
|
@@ -18012,7 +18012,7 @@ ${indent}}` : "}";
|
|
|
18012
18012
|
async prepareInvocations(invocations) {
|
|
18013
18013
|
const bulk = [];
|
|
18014
18014
|
for (const invocation of invocations) {
|
|
18015
|
-
if (invocation.type ===
|
|
18015
|
+
if (invocation.type === ETransactionType2.DECLARE) {
|
|
18016
18016
|
const isDeclared = await this.isClassDeclared(
|
|
18017
18017
|
"payload" in invocation ? invocation.payload : invocation
|
|
18018
18018
|
);
|
|
@@ -18900,7 +18900,7 @@ ${indent}}` : "}";
|
|
|
18900
18900
|
async signTransaction(transactions, details) {
|
|
18901
18901
|
const compiledCalldata = getExecuteCalldata(transactions, details.cairoVersion);
|
|
18902
18902
|
let msgHash;
|
|
18903
|
-
if (Object.values(
|
|
18903
|
+
if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
18904
18904
|
const det = details;
|
|
18905
18905
|
msgHash = calculateInvokeTransactionHash2({
|
|
18906
18906
|
...det,
|
|
@@ -18918,7 +18918,7 @@ ${indent}}` : "}";
|
|
|
18918
18918
|
async signDeployAccountTransaction(details) {
|
|
18919
18919
|
const compiledConstructorCalldata = CallData.compile(details.constructorCalldata);
|
|
18920
18920
|
let msgHash;
|
|
18921
|
-
if (Object.values(
|
|
18921
|
+
if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
18922
18922
|
const det = details;
|
|
18923
18923
|
msgHash = calculateDeployAccountTransactionHash3({
|
|
18924
18924
|
...det,
|
|
@@ -18935,7 +18935,7 @@ ${indent}}` : "}";
|
|
|
18935
18935
|
}
|
|
18936
18936
|
async signDeclareTransaction(details) {
|
|
18937
18937
|
let msgHash;
|
|
18938
|
-
if (Object.values(
|
|
18938
|
+
if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
18939
18939
|
const det = details;
|
|
18940
18940
|
msgHash = calculateDeclareTransactionHash3({
|
|
18941
18941
|
...det,
|
|
@@ -18997,7 +18997,7 @@ ${indent}}` : "}";
|
|
|
18997
18997
|
async signTransaction(transactions, details) {
|
|
18998
18998
|
const compiledCalldata = getExecuteCalldata(transactions, details.cairoVersion);
|
|
18999
18999
|
let msgHash;
|
|
19000
|
-
if (Object.values(
|
|
19000
|
+
if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
19001
19001
|
const det = details;
|
|
19002
19002
|
msgHash = calculateInvokeTransactionHash2({
|
|
19003
19003
|
...det,
|
|
@@ -19019,7 +19019,7 @@ ${indent}}` : "}";
|
|
|
19019
19019
|
async signDeployAccountTransaction(details) {
|
|
19020
19020
|
const compiledConstructorCalldata = CallData.compile(details.constructorCalldata);
|
|
19021
19021
|
let msgHash;
|
|
19022
|
-
if (Object.values(
|
|
19022
|
+
if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
19023
19023
|
const det = details;
|
|
19024
19024
|
msgHash = calculateDeployAccountTransactionHash3({
|
|
19025
19025
|
...det,
|
|
@@ -19040,7 +19040,7 @@ ${indent}}` : "}";
|
|
|
19040
19040
|
}
|
|
19041
19041
|
async signDeclareTransaction(details) {
|
|
19042
19042
|
let msgHash;
|
|
19043
|
-
if (Object.values(
|
|
19043
|
+
if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
19044
19044
|
const det = details;
|
|
19045
19045
|
msgHash = calculateDeclareTransactionHash3({
|
|
19046
19046
|
...det,
|
|
@@ -19213,7 +19213,7 @@ ${indent}}` : "}";
|
|
|
19213
19213
|
async signTransaction(transactions, transactionsDetail) {
|
|
19214
19214
|
const compiledCalldata = getExecuteCalldata(transactions, transactionsDetail.cairoVersion);
|
|
19215
19215
|
let msgHash;
|
|
19216
|
-
if (Object.values(
|
|
19216
|
+
if (Object.values(ETransactionVersion32).includes(transactionsDetail.version)) {
|
|
19217
19217
|
const det = transactionsDetail;
|
|
19218
19218
|
msgHash = calculateInvokeTransactionHash2({
|
|
19219
19219
|
...det,
|
|
@@ -19243,7 +19243,7 @@ ${indent}}` : "}";
|
|
|
19243
19243
|
async signDeployAccountTransaction(details) {
|
|
19244
19244
|
const compiledConstructorCalldata = CallData.compile(details.constructorCalldata);
|
|
19245
19245
|
let msgHash;
|
|
19246
|
-
if (Object.values(
|
|
19246
|
+
if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
19247
19247
|
const det = details;
|
|
19248
19248
|
msgHash = calculateDeployAccountTransactionHash3({
|
|
19249
19249
|
...det,
|
|
@@ -19272,7 +19272,7 @@ ${indent}}` : "}";
|
|
|
19272
19272
|
*/
|
|
19273
19273
|
async signDeclareTransaction(details) {
|
|
19274
19274
|
let msgHash;
|
|
19275
|
-
if (Object.values(
|
|
19275
|
+
if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
19276
19276
|
const det = details;
|
|
19277
19277
|
msgHash = calculateDeclareTransactionHash3({
|
|
19278
19278
|
...det,
|
|
@@ -19431,7 +19431,7 @@ ${indent}}` : "}";
|
|
|
19431
19431
|
*/
|
|
19432
19432
|
async signTransaction(transactions, transactionsDetail) {
|
|
19433
19433
|
const compiledCalldata = getExecuteCalldata(transactions, transactionsDetail.cairoVersion);
|
|
19434
|
-
if (Object.values(
|
|
19434
|
+
if (Object.values(ETransactionVersion32).includes(transactionsDetail.version)) {
|
|
19435
19435
|
const det = transactionsDetail;
|
|
19436
19436
|
const msgHash = calculateInvokeTransactionHash2({
|
|
19437
19437
|
...det,
|
|
@@ -19465,7 +19465,7 @@ ${indent}}` : "}";
|
|
|
19465
19465
|
async signDeployAccountTransaction(details) {
|
|
19466
19466
|
const compiledConstructorCalldata = CallData.compile(details.constructorCalldata);
|
|
19467
19467
|
let msgHash;
|
|
19468
|
-
if (Object.values(
|
|
19468
|
+
if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
19469
19469
|
const det = details;
|
|
19470
19470
|
msgHash = calculateDeployAccountTransactionHash3({
|
|
19471
19471
|
...det,
|
|
@@ -19571,8 +19571,8 @@ ${indent}}` : "}";
|
|
|
19571
19571
|
const nonceBuf = this.convertBnToLedger(txDetails.nonce);
|
|
19572
19572
|
const dAModeHashBuf = this.convertBnToLedger(
|
|
19573
19573
|
hashDAMode(
|
|
19574
|
-
txDetails.nonceDataAvailabilityMode ===
|
|
19575
|
-
txDetails.feeDataAvailabilityMode ===
|
|
19574
|
+
txDetails.nonceDataAvailabilityMode === EDataAvailabilityMode2.L1 ? EDAMode2.L1 : EDAMode2.L2,
|
|
19575
|
+
txDetails.feeDataAvailabilityMode === EDataAvailabilityMode2.L1 ? EDAMode2.L1 : EDAMode2.L2
|
|
19576
19576
|
)
|
|
19577
19577
|
);
|
|
19578
19578
|
const l1_gasBuf = this.convertBnToLedger(encodeResourceBoundsL1(txDetails.resourceBounds));
|
|
@@ -19654,8 +19654,8 @@ ${indent}}` : "}";
|
|
|
19654
19654
|
const nonceBuf = this.convertBnToLedger(deployAccountDetail.nonce);
|
|
19655
19655
|
const dAModeHashBuf = this.convertBnToLedger(
|
|
19656
19656
|
hashDAMode(
|
|
19657
|
-
deployAccountDetail.nonceDataAvailabilityMode ===
|
|
19658
|
-
deployAccountDetail.feeDataAvailabilityMode ===
|
|
19657
|
+
deployAccountDetail.nonceDataAvailabilityMode === EDataAvailabilityMode2.L1 ? EDAMode2.L1 : EDAMode2.L2,
|
|
19658
|
+
deployAccountDetail.feeDataAvailabilityMode === EDataAvailabilityMode2.L1 ? EDAMode2.L1 : EDAMode2.L2
|
|
19659
19659
|
)
|
|
19660
19660
|
);
|
|
19661
19661
|
const classHashBuf = this.convertBnToLedger(deployAccountDetail.classHash);
|
|
@@ -20570,7 +20570,7 @@ ${indent}}` : "}";
|
|
|
20570
20570
|
}
|
|
20571
20571
|
// TODO: TT Cairo version is still needed for invoke on existing contracts
|
|
20572
20572
|
async estimateInvokeFee(calls, details = {}) {
|
|
20573
|
-
const invocations = [{ type:
|
|
20573
|
+
const invocations = [{ type: ETransactionType2.INVOKE, payload: [calls].flat() }];
|
|
20574
20574
|
const estimateBulk = await this.estimateFeeBulk(invocations, details);
|
|
20575
20575
|
return estimateBulk[0];
|
|
20576
20576
|
}
|
|
@@ -20581,7 +20581,7 @@ ${indent}}` : "}";
|
|
|
20581
20581
|
);
|
|
20582
20582
|
const invocations = [
|
|
20583
20583
|
{
|
|
20584
|
-
type:
|
|
20584
|
+
type: ETransactionType2.DECLARE,
|
|
20585
20585
|
payload: extractContractHashes(payload, await this.channel.getStarknetVersion())
|
|
20586
20586
|
}
|
|
20587
20587
|
];
|
|
@@ -20598,7 +20598,7 @@ ${indent}}` : "}";
|
|
|
20598
20598
|
const contractAddressFinal = contractAddress ?? calculateContractAddressFromHash(addressSalt, classHash, compiledCalldata, 0);
|
|
20599
20599
|
const invocations = [
|
|
20600
20600
|
{
|
|
20601
|
-
type:
|
|
20601
|
+
type: ETransactionType2.DEPLOY_ACCOUNT,
|
|
20602
20602
|
payload: {
|
|
20603
20603
|
classHash,
|
|
20604
20604
|
constructorCalldata: compiledCalldata,
|
|
@@ -20671,7 +20671,7 @@ ${indent}}` : "}";
|
|
|
20671
20671
|
resourceBounds = estimateResponse.resourceBounds;
|
|
20672
20672
|
}
|
|
20673
20673
|
const accountInvocations = await this.accountInvocationsFactory(
|
|
20674
|
-
[{ type:
|
|
20674
|
+
[{ type: ETransactionType2.INVOKE, payload: calls }],
|
|
20675
20675
|
{
|
|
20676
20676
|
...v3Details(detailsWithTip),
|
|
20677
20677
|
resourceBounds,
|
|
@@ -20770,7 +20770,7 @@ ${indent}}` : "}";
|
|
|
20770
20770
|
resourceBounds = estimateResponse.resourceBounds;
|
|
20771
20771
|
}
|
|
20772
20772
|
const accountInvocations = await this.accountInvocationsFactory(
|
|
20773
|
-
[{ type:
|
|
20773
|
+
[{ type: ETransactionType2.DECLARE, payload: declareContractPayload }],
|
|
20774
20774
|
{
|
|
20775
20775
|
...v3Details(detailsWithTip),
|
|
20776
20776
|
resourceBounds,
|
|
@@ -20849,7 +20849,7 @@ ${indent}}` : "}";
|
|
|
20849
20849
|
const accountInvocations = await this.accountInvocationsFactory(
|
|
20850
20850
|
[
|
|
20851
20851
|
{
|
|
20852
|
-
type:
|
|
20852
|
+
type: ETransactionType2.DEPLOY_ACCOUNT,
|
|
20853
20853
|
payload: {
|
|
20854
20854
|
classHash,
|
|
20855
20855
|
constructorCalldata: compiledCalldata,
|
|
@@ -21121,7 +21121,7 @@ ${indent}}` : "}";
|
|
|
21121
21121
|
const chainId = await this.getChainId();
|
|
21122
21122
|
const versions = details.versions.map((it) => toTransactionVersion(it));
|
|
21123
21123
|
const tx0Payload = "payload" in invocations[0] ? invocations[0].payload : invocations[0];
|
|
21124
|
-
const cairoVersion = invocations[0].type ===
|
|
21124
|
+
const cairoVersion = invocations[0].type === ETransactionType2.DEPLOY_ACCOUNT ? await this.getCairoVersion(tx0Payload.classHash) : await this.getCairoVersion();
|
|
21125
21125
|
return Promise.all(
|
|
21126
21126
|
[].concat(invocations).map(async (transaction, index) => {
|
|
21127
21127
|
const txPayload = "payload" in transaction ? transaction.payload : transaction;
|
|
@@ -21140,7 +21140,7 @@ ${indent}}` : "}";
|
|
|
21140
21140
|
blockIdentifier,
|
|
21141
21141
|
version: versions[0]
|
|
21142
21142
|
};
|
|
21143
|
-
if (transaction.type ===
|
|
21143
|
+
if (transaction.type === ETransactionType2.INVOKE) {
|
|
21144
21144
|
const payload = await this.buildInvocation(
|
|
21145
21145
|
[].concat(txPayload),
|
|
21146
21146
|
signerDetails
|
|
@@ -21151,17 +21151,17 @@ ${indent}}` : "}";
|
|
|
21151
21151
|
...signerDetails
|
|
21152
21152
|
};
|
|
21153
21153
|
}
|
|
21154
|
-
if (transaction.type ===
|
|
21154
|
+
if (transaction.type === ETransactionType2.DEPLOY) {
|
|
21155
21155
|
const { calls } = this.deployer.buildDeployerCall(txPayload, this.address);
|
|
21156
21156
|
const payload = await this.buildInvocation(calls, signerDetails);
|
|
21157
21157
|
return {
|
|
21158
21158
|
...common2,
|
|
21159
21159
|
...payload,
|
|
21160
21160
|
...signerDetails,
|
|
21161
|
-
type:
|
|
21161
|
+
type: ETransactionType2.INVOKE
|
|
21162
21162
|
};
|
|
21163
21163
|
}
|
|
21164
|
-
if (transaction.type ===
|
|
21164
|
+
if (transaction.type === ETransactionType2.DECLARE) {
|
|
21165
21165
|
assert(
|
|
21166
21166
|
isSierra(txPayload.contract),
|
|
21167
21167
|
"Declare fee estimation is not supported for Cairo0 contracts"
|
|
@@ -21173,7 +21173,7 @@ ${indent}}` : "}";
|
|
|
21173
21173
|
...signerDetails
|
|
21174
21174
|
};
|
|
21175
21175
|
}
|
|
21176
|
-
if (transaction.type ===
|
|
21176
|
+
if (transaction.type === ETransactionType2.DEPLOY_ACCOUNT) {
|
|
21177
21177
|
const payload = await this.buildAccountDeployPayload(txPayload, signerDetails);
|
|
21178
21178
|
return {
|
|
21179
21179
|
...common2,
|
|
@@ -21648,7 +21648,10 @@ ${indent}}` : "}";
|
|
|
21648
21648
|
// src/utils/events/index.ts
|
|
21649
21649
|
var events_exports = {};
|
|
21650
21650
|
__export(events_exports, {
|
|
21651
|
+
addGetByPathMethod: () => addGetByPathMethod,
|
|
21652
|
+
filterEventsByAddress: () => filterEventsByAddress,
|
|
21651
21653
|
getAbiEvents: () => getAbiEvents,
|
|
21654
|
+
getEmittedEvents: () => getEmittedEvents,
|
|
21652
21655
|
isAbiEvent: () => isAbiEvent,
|
|
21653
21656
|
parseEvents: () => parseEvents
|
|
21654
21657
|
});
|
|
@@ -21722,52 +21725,79 @@ ${indent}}` : "}";
|
|
|
21722
21725
|
return output;
|
|
21723
21726
|
}
|
|
21724
21727
|
function parseEvents(providerReceivedEvents, abiEvents, abiStructs, abiEnums, parser) {
|
|
21725
|
-
const ret = providerReceivedEvents.
|
|
21726
|
-
const
|
|
21727
|
-
|
|
21728
|
+
const ret = providerReceivedEvents.reduce((acc, recEvent) => {
|
|
21729
|
+
const eventKeys = [...recEvent.keys];
|
|
21730
|
+
const eventData = [...recEvent.data];
|
|
21731
|
+
let abiEvent = abiEvents[eventKeys.shift() ?? 0];
|
|
21728
21732
|
if (!abiEvent) {
|
|
21729
21733
|
return acc;
|
|
21730
21734
|
}
|
|
21731
21735
|
while (!abiEvent.name) {
|
|
21732
|
-
const hashName =
|
|
21736
|
+
const hashName = eventKeys.shift();
|
|
21733
21737
|
assert(!!hashName, 'Not enough data in "keys" property of this event.');
|
|
21734
21738
|
abiEvent = abiEvent[hashName];
|
|
21735
21739
|
}
|
|
21736
|
-
const
|
|
21737
|
-
parsedEvent
|
|
21738
|
-
const
|
|
21739
|
-
|
|
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]();
|
|
21740
21746
|
const abiEventKeys = abiEvent.members?.filter((it) => it.kind === "key") || abiEvent.keys;
|
|
21741
21747
|
const abiEventData = abiEvent.members?.filter((it) => it.kind === "data") || abiEvent.data;
|
|
21748
|
+
const parsedEventData = parsedEvent[eventName];
|
|
21742
21749
|
abiEventKeys.forEach((key) => {
|
|
21743
|
-
|
|
21750
|
+
parsedEventData[key.name] = responseParser({
|
|
21744
21751
|
responseIterator: keysIter,
|
|
21745
21752
|
output: key,
|
|
21746
21753
|
structs: abiStructs,
|
|
21747
21754
|
enums: abiEnums,
|
|
21748
21755
|
parser,
|
|
21749
|
-
parsedResult:
|
|
21756
|
+
parsedResult: parsedEventData
|
|
21750
21757
|
});
|
|
21751
21758
|
});
|
|
21752
21759
|
abiEventData.forEach((data) => {
|
|
21753
|
-
|
|
21760
|
+
parsedEventData[data.name] = responseParser({
|
|
21754
21761
|
responseIterator: dataIter,
|
|
21755
21762
|
output: data,
|
|
21756
21763
|
structs: abiStructs,
|
|
21757
21764
|
enums: abiEnums,
|
|
21758
21765
|
parser,
|
|
21759
|
-
parsedResult:
|
|
21766
|
+
parsedResult: parsedEventData
|
|
21760
21767
|
});
|
|
21761
21768
|
});
|
|
21762
|
-
if ("block_hash" in currentEvent) parsedEvent.block_hash = currentEvent.block_hash;
|
|
21763
|
-
if ("block_number" in currentEvent) parsedEvent.block_number = currentEvent.block_number;
|
|
21764
|
-
if ("transaction_hash" in currentEvent)
|
|
21765
|
-
parsedEvent.transaction_hash = currentEvent.transaction_hash;
|
|
21766
21769
|
acc.push(parsedEvent);
|
|
21767
21770
|
return acc;
|
|
21768
21771
|
}, []);
|
|
21769
21772
|
return ret;
|
|
21770
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
|
+
}
|
|
21771
21801
|
|
|
21772
21802
|
// src/contract/default.ts
|
|
21773
21803
|
function buildCall(contract, functionAbi) {
|
|
@@ -22028,45 +22058,19 @@ ${indent}}` : "}";
|
|
|
22028
22058
|
calldata
|
|
22029
22059
|
};
|
|
22030
22060
|
}
|
|
22031
|
-
// TODO: Demistify what is going on here ???
|
|
22032
|
-
// TODO: receipt status filtering test and fix this do not look right
|
|
22033
22061
|
parseEvents(receipt) {
|
|
22034
|
-
|
|
22035
|
-
|
|
22036
|
-
|
|
22037
|
-
|
|
22038
|
-
|
|
22039
|
-
|
|
22040
|
-
|
|
22041
|
-
|
|
22042
|
-
|
|
22043
|
-
|
|
22044
|
-
|
|
22045
|
-
|
|
22046
|
-
}).filter((event) => toHex(event.from_address) === toHex(this.address), []) || [];
|
|
22047
|
-
parsed = parseEvents(
|
|
22048
|
-
emittedEvents,
|
|
22049
|
-
this.events,
|
|
22050
|
-
this.structs,
|
|
22051
|
-
CallData.getAbiEnum(this.abi),
|
|
22052
|
-
this.callData.parser
|
|
22053
|
-
);
|
|
22054
|
-
},
|
|
22055
|
-
_: () => {
|
|
22056
|
-
throw Error("This transaction was not successful.");
|
|
22057
|
-
}
|
|
22058
|
-
});
|
|
22059
|
-
Object.defineProperty(parsed, "getByPath", {
|
|
22060
|
-
value: (path) => {
|
|
22061
|
-
const event = parsed.find((ev) => Object.keys(ev).some((key) => key.includes(path)));
|
|
22062
|
-
const eventKey = Object.keys(event || {}).find((key) => key.includes(path));
|
|
22063
|
-
return eventKey && event ? event[eventKey] : null;
|
|
22064
|
-
},
|
|
22065
|
-
writable: false,
|
|
22066
|
-
enumerable: false,
|
|
22067
|
-
configurable: false
|
|
22068
|
-
});
|
|
22069
|
-
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
|
+
);
|
|
22070
22074
|
}
|
|
22071
22075
|
isCairo1() {
|
|
22072
22076
|
return cairo_exports.isCairo1Abi(this.abi);
|