starknet 6.8.0 → 6.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -1
- package/dist/index.d.ts +367 -109
- package/dist/index.global.js +1140 -801
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +339 -218
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +337 -215
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -5
package/dist/index.mjs
CHANGED
|
@@ -242,19 +242,16 @@ var RANGE_I128 = range(-(2n ** 127n), 2n ** 127n - 1n);
|
|
|
242
242
|
var RANGE_U128 = range(ZERO, 2n ** 128n - 1n);
|
|
243
243
|
var BaseUrl = /* @__PURE__ */ ((BaseUrl2) => {
|
|
244
244
|
BaseUrl2["SN_MAIN"] = "https://alpha-mainnet.starknet.io";
|
|
245
|
-
BaseUrl2["SN_GOERLI"] = "https://alpha4.starknet.io";
|
|
246
245
|
BaseUrl2["SN_SEPOLIA"] = "https://alpha-sepolia.starknet.io";
|
|
247
246
|
return BaseUrl2;
|
|
248
247
|
})(BaseUrl || {});
|
|
249
248
|
var NetworkName = /* @__PURE__ */ ((NetworkName2) => {
|
|
250
249
|
NetworkName2["SN_MAIN"] = "SN_MAIN";
|
|
251
|
-
NetworkName2["SN_GOERLI"] = "SN_GOERLI";
|
|
252
250
|
NetworkName2["SN_SEPOLIA"] = "SN_SEPOLIA";
|
|
253
251
|
return NetworkName2;
|
|
254
252
|
})(NetworkName || {});
|
|
255
253
|
var StarknetChainId = /* @__PURE__ */ ((StarknetChainId6) => {
|
|
256
254
|
StarknetChainId6["SN_MAIN"] = "0x534e5f4d41494e";
|
|
257
|
-
StarknetChainId6["SN_GOERLI"] = "0x534e5f474f45524c49";
|
|
258
255
|
StarknetChainId6["SN_SEPOLIA"] = "0x534e5f5345504f4c4941";
|
|
259
256
|
return StarknetChainId6;
|
|
260
257
|
})(StarknetChainId || {});
|
|
@@ -278,10 +275,6 @@ var UDC = {
|
|
|
278
275
|
};
|
|
279
276
|
var RPC_DEFAULT_VERSION = "v0_7";
|
|
280
277
|
var RPC_NODES = {
|
|
281
|
-
SN_GOERLI: [
|
|
282
|
-
`https://starknet-testnet.public.blastapi.io/rpc/${RPC_DEFAULT_VERSION}`,
|
|
283
|
-
`https://free-rpc.nethermind.io/goerli-juno/${RPC_DEFAULT_VERSION}`
|
|
284
|
-
],
|
|
285
278
|
SN_MAIN: [
|
|
286
279
|
`https://starknet-mainnet.public.blastapi.io/rpc/${RPC_DEFAULT_VERSION}`,
|
|
287
280
|
`https://free-rpc.nethermind.io/mainnet-juno/${RPC_DEFAULT_VERSION}`
|
|
@@ -292,6 +285,16 @@ var RPC_NODES = {
|
|
|
292
285
|
]
|
|
293
286
|
};
|
|
294
287
|
|
|
288
|
+
// src/provider/rpc.ts
|
|
289
|
+
import { bytesToHex } from "@noble/curves/abstract/utils";
|
|
290
|
+
import { keccak_256 } from "@noble/hashes/sha3";
|
|
291
|
+
|
|
292
|
+
// src/channel/rpc_0_6.ts
|
|
293
|
+
var rpc_0_6_exports = {};
|
|
294
|
+
__export(rpc_0_6_exports, {
|
|
295
|
+
RpcChannel: () => RpcChannel
|
|
296
|
+
});
|
|
297
|
+
|
|
295
298
|
// src/provider/errors.ts
|
|
296
299
|
function fixStack(target, fn = target.constructor) {
|
|
297
300
|
const { captureStackTrace } = Error;
|
|
@@ -329,12 +332,6 @@ var HttpError = class extends LibraryError {
|
|
|
329
332
|
}
|
|
330
333
|
};
|
|
331
334
|
|
|
332
|
-
// src/channel/rpc_0_6.ts
|
|
333
|
-
var rpc_0_6_exports = {};
|
|
334
|
-
__export(rpc_0_6_exports, {
|
|
335
|
-
RpcChannel: () => RpcChannel
|
|
336
|
-
});
|
|
337
|
-
|
|
338
335
|
// src/types/index.ts
|
|
339
336
|
var types_exports = {};
|
|
340
337
|
__export(types_exports, {
|
|
@@ -343,7 +340,6 @@ __export(types_exports, {
|
|
|
343
340
|
EntryPointType: () => EntryPointType,
|
|
344
341
|
Literal: () => Literal,
|
|
345
342
|
RPC: () => api_exports,
|
|
346
|
-
SIMULATION_FLAG: () => SIMULATION_FLAG,
|
|
347
343
|
TransactionExecutionStatus: () => TransactionExecutionStatus,
|
|
348
344
|
TransactionFinalityStatus: () => TransactionFinalityStatus,
|
|
349
345
|
TransactionStatus: () => TransactionStatus,
|
|
@@ -353,13 +349,6 @@ __export(types_exports, {
|
|
|
353
349
|
ValidateType: () => ValidateType
|
|
354
350
|
});
|
|
355
351
|
|
|
356
|
-
// src/types/account.ts
|
|
357
|
-
var SIMULATION_FLAG = /* @__PURE__ */ ((SIMULATION_FLAG2) => {
|
|
358
|
-
SIMULATION_FLAG2["SKIP_VALIDATE"] = "SKIP_VALIDATE";
|
|
359
|
-
SIMULATION_FLAG2["SKIP_EXECUTE"] = "SKIP_EXECUTE";
|
|
360
|
-
return SIMULATION_FLAG2;
|
|
361
|
-
})(SIMULATION_FLAG || {});
|
|
362
|
-
|
|
363
352
|
// src/types/calldata.ts
|
|
364
353
|
var ValidateType = /* @__PURE__ */ ((ValidateType2) => {
|
|
365
354
|
ValidateType2["DEPLOY"] = "DEPLOY";
|
|
@@ -1180,46 +1169,49 @@ var guard = {
|
|
|
1180
1169
|
}
|
|
1181
1170
|
};
|
|
1182
1171
|
function formatter(data, type, sameType) {
|
|
1183
|
-
return Object.entries(data).reduce(
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
}
|
|
1189
|
-
if (elType === "string") {
|
|
1190
|
-
if (Array.isArray(data[key])) {
|
|
1191
|
-
const arrayStr = formatter(
|
|
1192
|
-
data[key],
|
|
1193
|
-
data[key].map((_) => elType)
|
|
1194
|
-
);
|
|
1195
|
-
acc[key] = Object.values(arrayStr).join("");
|
|
1172
|
+
return Object.entries(data).reduce(
|
|
1173
|
+
(acc, [key, value]) => {
|
|
1174
|
+
const elType = sameType ?? type[key];
|
|
1175
|
+
if (!(key in type) && !sameType) {
|
|
1176
|
+
acc[key] = value;
|
|
1196
1177
|
return acc;
|
|
1197
1178
|
}
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1179
|
+
if (elType === "string") {
|
|
1180
|
+
if (Array.isArray(data[key])) {
|
|
1181
|
+
const arrayStr = formatter(
|
|
1182
|
+
data[key],
|
|
1183
|
+
data[key].map((_) => elType)
|
|
1184
|
+
);
|
|
1185
|
+
acc[key] = Object.values(arrayStr).join("");
|
|
1186
|
+
return acc;
|
|
1187
|
+
}
|
|
1188
|
+
guard.isBN(data, type, key);
|
|
1189
|
+
acc[key] = decodeShortString(value);
|
|
1190
|
+
return acc;
|
|
1191
|
+
}
|
|
1192
|
+
if (elType === "number") {
|
|
1193
|
+
guard.isBN(data, type, key);
|
|
1194
|
+
acc[key] = Number(value);
|
|
1195
|
+
return acc;
|
|
1196
|
+
}
|
|
1197
|
+
if (typeof elType === "function") {
|
|
1198
|
+
acc[key] = elType(value);
|
|
1199
|
+
return acc;
|
|
1200
|
+
}
|
|
1201
|
+
if (Array.isArray(elType)) {
|
|
1202
|
+
const arrayObj = formatter(data[key], elType, elType[0]);
|
|
1203
|
+
acc[key] = Object.values(arrayObj);
|
|
1204
|
+
return acc;
|
|
1205
|
+
}
|
|
1206
|
+
if (typeof elType === "object") {
|
|
1207
|
+
acc[key] = formatter(data[key], elType);
|
|
1208
|
+
return acc;
|
|
1209
|
+
}
|
|
1210
|
+
guard.unknown(data, type, key);
|
|
1218
1211
|
return acc;
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
}, {});
|
|
1212
|
+
},
|
|
1213
|
+
{}
|
|
1214
|
+
);
|
|
1223
1215
|
}
|
|
1224
1216
|
|
|
1225
1217
|
// src/utils/calldata/parser/parser-0-1.1.0.ts
|
|
@@ -1274,7 +1266,9 @@ var AbiParser2 = class {
|
|
|
1274
1266
|
* @returns FunctionAbi | undefined
|
|
1275
1267
|
*/
|
|
1276
1268
|
getMethod(name) {
|
|
1277
|
-
const intf = this.abi.find(
|
|
1269
|
+
const intf = this.abi.find(
|
|
1270
|
+
(it) => it.type === "interface"
|
|
1271
|
+
);
|
|
1278
1272
|
return intf.items.find((it) => it.name === name);
|
|
1279
1273
|
}
|
|
1280
1274
|
/**
|
|
@@ -2244,7 +2238,7 @@ var CallData = class _CallData {
|
|
|
2244
2238
|
* Compile contract callData with abi
|
|
2245
2239
|
* Parse the calldata by using input fields from the abi for that method
|
|
2246
2240
|
* @param method string - method name
|
|
2247
|
-
* @param
|
|
2241
|
+
* @param argsCalldata RawArgs - arguments passed to the method. Can be an array of arguments (in the order of abi definition), or an object constructed in conformity with abi (in this case, the parameter can be in a wrong order).
|
|
2248
2242
|
* @return Calldata - parsed arguments in format that contract is expecting
|
|
2249
2243
|
* @example
|
|
2250
2244
|
* ```typescript
|
|
@@ -3094,7 +3088,7 @@ function ethRandomPrivateKey() {
|
|
|
3094
3088
|
function validateAndParseEthAddress(address) {
|
|
3095
3089
|
assertInRange(address, ZERO, 2n ** 160n - 1n, "Ethereum Address ");
|
|
3096
3090
|
const result = addHexPrefix(removeHexPrefix(toHex(address)).padStart(40, "0"));
|
|
3097
|
-
assert(result.match(/^(0x)?[0-9a-f]{40}$/), "Invalid Ethereum Address Format");
|
|
3091
|
+
assert(Boolean(result.match(/^(0x)?[0-9a-f]{40}$/)), "Invalid Ethereum Address Format");
|
|
3098
3092
|
return result;
|
|
3099
3093
|
}
|
|
3100
3094
|
|
|
@@ -3502,11 +3496,12 @@ var RpcChannel = class {
|
|
|
3502
3496
|
* - skipValidate (default false)<br/>
|
|
3503
3497
|
* - skipFeeCharge (default true)<br/>
|
|
3504
3498
|
*/
|
|
3505
|
-
simulateTransaction(invocations, {
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3499
|
+
simulateTransaction(invocations, simulateTransactionOptions = {}) {
|
|
3500
|
+
const {
|
|
3501
|
+
blockIdentifier = this.blockIdentifier,
|
|
3502
|
+
skipValidate = true,
|
|
3503
|
+
skipFeeCharge = true
|
|
3504
|
+
} = simulateTransactionOptions;
|
|
3510
3505
|
const block_id = new Block(blockIdentifier).identifier;
|
|
3511
3506
|
const simulationFlags = [];
|
|
3512
3507
|
if (skipValidate)
|
|
@@ -3891,10 +3886,20 @@ var RpcChannel2 = class {
|
|
|
3891
3886
|
blockIdentifier;
|
|
3892
3887
|
chainId;
|
|
3893
3888
|
specVersion;
|
|
3889
|
+
transactionRetryIntervalFallback;
|
|
3894
3890
|
waitMode;
|
|
3895
3891
|
// behave like web2 rpc and return when tx is processed
|
|
3896
3892
|
constructor(optionsOrProvider) {
|
|
3897
|
-
const {
|
|
3893
|
+
const {
|
|
3894
|
+
nodeUrl,
|
|
3895
|
+
retries,
|
|
3896
|
+
headers,
|
|
3897
|
+
blockIdentifier,
|
|
3898
|
+
chainId,
|
|
3899
|
+
specVersion,
|
|
3900
|
+
waitMode,
|
|
3901
|
+
transactionRetryIntervalFallback
|
|
3902
|
+
} = optionsOrProvider || {};
|
|
3898
3903
|
if (Object.values(NetworkName).includes(nodeUrl)) {
|
|
3899
3904
|
this.nodeUrl = getDefaultNodeUrl(nodeUrl, optionsOrProvider?.default);
|
|
3900
3905
|
} else if (nodeUrl) {
|
|
@@ -3909,6 +3914,10 @@ var RpcChannel2 = class {
|
|
|
3909
3914
|
this.specVersion = specVersion;
|
|
3910
3915
|
this.waitMode = waitMode || false;
|
|
3911
3916
|
this.requestId = 0;
|
|
3917
|
+
this.transactionRetryIntervalFallback = transactionRetryIntervalFallback;
|
|
3918
|
+
}
|
|
3919
|
+
get transactionRetryIntervalDefault() {
|
|
3920
|
+
return this.transactionRetryIntervalFallback ?? 5e3;
|
|
3912
3921
|
}
|
|
3913
3922
|
setChainId(chainId) {
|
|
3914
3923
|
this.chainId = chainId;
|
|
@@ -4039,11 +4048,12 @@ var RpcChannel2 = class {
|
|
|
4039
4048
|
* - skipValidate (default false)<br/>
|
|
4040
4049
|
* - skipFeeCharge (default true)<br/>
|
|
4041
4050
|
*/
|
|
4042
|
-
simulateTransaction(invocations, {
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4051
|
+
simulateTransaction(invocations, simulateTransactionOptions = {}) {
|
|
4052
|
+
const {
|
|
4053
|
+
blockIdentifier = this.blockIdentifier,
|
|
4054
|
+
skipValidate = true,
|
|
4055
|
+
skipFeeCharge = true
|
|
4056
|
+
} = simulateTransactionOptions;
|
|
4047
4057
|
const block_id = new Block(blockIdentifier).identifier;
|
|
4048
4058
|
const simulationFlags = [];
|
|
4049
4059
|
if (skipValidate)
|
|
@@ -4061,7 +4071,7 @@ var RpcChannel2 = class {
|
|
|
4061
4071
|
let { retries } = this;
|
|
4062
4072
|
let onchain = false;
|
|
4063
4073
|
let isErrorState = false;
|
|
4064
|
-
const retryInterval = options?.retryInterval ??
|
|
4074
|
+
const retryInterval = options?.retryInterval ?? this.transactionRetryIntervalDefault;
|
|
4065
4075
|
const errorStates = options?.errorStates ?? [
|
|
4066
4076
|
RPCSPEC07.ETransactionStatus.REJECTED
|
|
4067
4077
|
// TODO: commented out to preserve the long-standing behavior of "reverted" not being treated as an error by default
|
|
@@ -4582,9 +4592,63 @@ var RpcProvider = class {
|
|
|
4582
4592
|
async getBlockWithTxs(blockIdentifier) {
|
|
4583
4593
|
return this.channel.getBlockWithTxs(blockIdentifier);
|
|
4584
4594
|
}
|
|
4595
|
+
/**
|
|
4596
|
+
* Pause the execution of the script until a specified block is created.
|
|
4597
|
+
* @param {BlockIdentifier} blockIdentifier bloc number (BigNumberisk) or 'pending' or 'latest'.
|
|
4598
|
+
* Use of 'latest" or of a block already created will generate no pause.
|
|
4599
|
+
* @param {number} [retryInterval] number of milliseconds between 2 requests to the node
|
|
4600
|
+
* @example
|
|
4601
|
+
* ```typescript
|
|
4602
|
+
* await myProvider.waitForBlock();
|
|
4603
|
+
* // wait the creation of the pending block
|
|
4604
|
+
* ```
|
|
4605
|
+
*/
|
|
4606
|
+
async waitForBlock(blockIdentifier = "pending", retryInterval = 5e3) {
|
|
4607
|
+
if (blockIdentifier === "latest" /* latest */)
|
|
4608
|
+
return;
|
|
4609
|
+
const currentBlock = await this.getBlockNumber();
|
|
4610
|
+
const targetBlock = blockIdentifier === "pending" /* pending */ ? currentBlock + 1 : Number(toHex(blockIdentifier));
|
|
4611
|
+
if (targetBlock <= currentBlock)
|
|
4612
|
+
return;
|
|
4613
|
+
const { retries } = this.channel;
|
|
4614
|
+
let retriesCount = retries;
|
|
4615
|
+
let isTargetBlock = false;
|
|
4616
|
+
while (!isTargetBlock) {
|
|
4617
|
+
const currBlock = await this.getBlockNumber();
|
|
4618
|
+
if (currBlock === targetBlock) {
|
|
4619
|
+
isTargetBlock = true;
|
|
4620
|
+
} else {
|
|
4621
|
+
await wait(retryInterval);
|
|
4622
|
+
}
|
|
4623
|
+
retriesCount -= 1;
|
|
4624
|
+
if (retriesCount <= 0) {
|
|
4625
|
+
throw new Error(`waitForBlock() timed-out after ${retries} tries.`);
|
|
4626
|
+
}
|
|
4627
|
+
}
|
|
4628
|
+
}
|
|
4585
4629
|
async getL1GasPrice(blockIdentifier) {
|
|
4586
4630
|
return this.channel.getBlockWithTxHashes(blockIdentifier).then(this.responseParser.parseL1GasPriceResponse);
|
|
4587
4631
|
}
|
|
4632
|
+
async getL1MessageHash(l2TxHash) {
|
|
4633
|
+
const transaction = await this.channel.getTransactionByHash(l2TxHash);
|
|
4634
|
+
assert(transaction.type === "L1_HANDLER", "This L2 transaction is not a L1 message.");
|
|
4635
|
+
const { calldata, contract_address, entry_point_selector, nonce } = transaction;
|
|
4636
|
+
const params = [
|
|
4637
|
+
calldata[0],
|
|
4638
|
+
contract_address,
|
|
4639
|
+
nonce,
|
|
4640
|
+
entry_point_selector,
|
|
4641
|
+
calldata.length - 1,
|
|
4642
|
+
...calldata.slice(1)
|
|
4643
|
+
];
|
|
4644
|
+
const myEncode = addHexPrefix(
|
|
4645
|
+
params.reduce(
|
|
4646
|
+
(res, par) => res + removeHexPrefix(toHex(par)).padStart(64, "0"),
|
|
4647
|
+
""
|
|
4648
|
+
)
|
|
4649
|
+
);
|
|
4650
|
+
return addHexPrefix(bytesToHex(keccak_256(hexToBytes(myEncode))));
|
|
4651
|
+
}
|
|
4588
4652
|
async getBlockWithReceipts(blockIdentifier) {
|
|
4589
4653
|
if (this.channel instanceof rpc_0_6_exports.RpcChannel)
|
|
4590
4654
|
throw new LibraryError("Unsupported method for RPC version");
|
|
@@ -4636,7 +4700,7 @@ var RpcProvider = class {
|
|
|
4636
4700
|
}
|
|
4637
4701
|
/**
|
|
4638
4702
|
* @param invocations AccountInvocations
|
|
4639
|
-
* @param
|
|
4703
|
+
* @param options blockIdentifier and flags to skip validation and fee charge<br/>
|
|
4640
4704
|
* - blockIdentifier<br/>
|
|
4641
4705
|
* - skipValidate (default false)<br/>
|
|
4642
4706
|
* - skipFeeCharge (default true)<br/>
|
|
@@ -4877,7 +4941,6 @@ function useEncoded(decoded) {
|
|
|
4877
4941
|
}
|
|
4878
4942
|
var StarknetIdContract = /* @__PURE__ */ ((StarknetIdContract2) => {
|
|
4879
4943
|
StarknetIdContract2["MAINNET"] = "0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678";
|
|
4880
|
-
StarknetIdContract2["TESTNET"] = "0x3bab268e932d2cecd1946f100ae67ce3dff9fd234119ea2f6da57d16d29fce";
|
|
4881
4944
|
StarknetIdContract2["TESTNET_SEPOLIA"] = "0x0707f09bc576bd7cfee59694846291047e965f4184fe13dac62c56759b3b6fa7";
|
|
4882
4945
|
return StarknetIdContract2;
|
|
4883
4946
|
})(StarknetIdContract || {});
|
|
@@ -4885,8 +4948,6 @@ function getStarknetIdContract(chainId) {
|
|
|
4885
4948
|
switch (chainId) {
|
|
4886
4949
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
4887
4950
|
return "0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678" /* MAINNET */;
|
|
4888
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
4889
|
-
return "0x3bab268e932d2cecd1946f100ae67ce3dff9fd234119ea2f6da57d16d29fce" /* TESTNET */;
|
|
4890
4951
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
4891
4952
|
return "0x0707f09bc576bd7cfee59694846291047e965f4184fe13dac62c56759b3b6fa7" /* TESTNET_SEPOLIA */;
|
|
4892
4953
|
default:
|
|
@@ -4895,7 +4956,6 @@ function getStarknetIdContract(chainId) {
|
|
|
4895
4956
|
}
|
|
4896
4957
|
var StarknetIdIdentityContract = /* @__PURE__ */ ((StarknetIdIdentityContract2) => {
|
|
4897
4958
|
StarknetIdIdentityContract2["MAINNET"] = "0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af";
|
|
4898
|
-
StarknetIdIdentityContract2["TESTNET"] = "0x783a9097b26eae0586373b2ce0ed3529ddc44069d1e0fbc4f66d42b69d6850d";
|
|
4899
4959
|
StarknetIdIdentityContract2["TESTNET_SEPOLIA"] = "0x070DF8B4F5cb2879f8592849fA8f3134da39d25326B8558cc9C8FE8D47EA3A90";
|
|
4900
4960
|
return StarknetIdIdentityContract2;
|
|
4901
4961
|
})(StarknetIdIdentityContract || {});
|
|
@@ -4903,8 +4963,6 @@ function getStarknetIdIdentityContract(chainId) {
|
|
|
4903
4963
|
switch (chainId) {
|
|
4904
4964
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
4905
4965
|
return "0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af" /* MAINNET */;
|
|
4906
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
4907
|
-
return "0x783a9097b26eae0586373b2ce0ed3529ddc44069d1e0fbc4f66d42b69d6850d" /* TESTNET */;
|
|
4908
4966
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
4909
4967
|
return "0x070DF8B4F5cb2879f8592849fA8f3134da39d25326B8558cc9C8FE8D47EA3A90" /* TESTNET_SEPOLIA */;
|
|
4910
4968
|
default:
|
|
@@ -4916,8 +4974,6 @@ function getStarknetIdMulticallContract(chainId) {
|
|
|
4916
4974
|
switch (chainId) {
|
|
4917
4975
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
4918
4976
|
return StarknetIdMulticallContract;
|
|
4919
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
4920
|
-
return StarknetIdMulticallContract;
|
|
4921
4977
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
4922
4978
|
return StarknetIdMulticallContract;
|
|
4923
4979
|
default:
|
|
@@ -4926,7 +4982,6 @@ function getStarknetIdMulticallContract(chainId) {
|
|
|
4926
4982
|
}
|
|
4927
4983
|
var StarknetIdVerifierContract = /* @__PURE__ */ ((StarknetIdVerifierContract2) => {
|
|
4928
4984
|
StarknetIdVerifierContract2["MAINNET"] = "0x07d14dfd8ee95b41fce179170d88ba1f0d5a512e13aeb232f19cfeec0a88f8bf";
|
|
4929
|
-
StarknetIdVerifierContract2["TESTNET"] = "0x057c942544063c3aea6ea6c37009cc9d1beacd750cb6801549a129c7265f0f11";
|
|
4930
4985
|
StarknetIdVerifierContract2["TESTNET_SEPOLIA"] = "0x0182EcE8173C216A395f4828e1523541b7e3600bf190CB252E1a1A0cE219d184";
|
|
4931
4986
|
return StarknetIdVerifierContract2;
|
|
4932
4987
|
})(StarknetIdVerifierContract || {});
|
|
@@ -4934,8 +4989,6 @@ function getStarknetIdVerifierContract(chainId) {
|
|
|
4934
4989
|
switch (chainId) {
|
|
4935
4990
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
4936
4991
|
return "0x07d14dfd8ee95b41fce179170d88ba1f0d5a512e13aeb232f19cfeec0a88f8bf" /* MAINNET */;
|
|
4937
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
4938
|
-
return "0x057c942544063c3aea6ea6c37009cc9d1beacd750cb6801549a129c7265f0f11" /* TESTNET */;
|
|
4939
4992
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
4940
4993
|
return "0x0182EcE8173C216A395f4828e1523541b7e3600bf190CB252E1a1A0cE219d184" /* TESTNET_SEPOLIA */;
|
|
4941
4994
|
default:
|
|
@@ -4944,7 +4997,6 @@ function getStarknetIdVerifierContract(chainId) {
|
|
|
4944
4997
|
}
|
|
4945
4998
|
var StarknetIdPfpContract = /* @__PURE__ */ ((StarknetIdPfpContract2) => {
|
|
4946
4999
|
StarknetIdPfpContract2["MAINNET"] = "0x070aaa20ec4a46da57c932d9fd89ca5e6bb9ca3188d3df361a32306aff7d59c7";
|
|
4947
|
-
StarknetIdPfpContract2["TESTNET"] = "0x03cac3228b434259734ee0e4ff445f642206ea11adace7e4f45edd2596748698";
|
|
4948
5000
|
StarknetIdPfpContract2["TESTNET_SEPOLIA"] = "0x058061bb6bdc501eE215172c9f87d557C1E0f466dC498cA81b18f998Bf1362b2";
|
|
4949
5001
|
return StarknetIdPfpContract2;
|
|
4950
5002
|
})(StarknetIdPfpContract || {});
|
|
@@ -4952,8 +5004,6 @@ function getStarknetIdPfpContract(chainId) {
|
|
|
4952
5004
|
switch (chainId) {
|
|
4953
5005
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
4954
5006
|
return "0x070aaa20ec4a46da57c932d9fd89ca5e6bb9ca3188d3df361a32306aff7d59c7" /* MAINNET */;
|
|
4955
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
4956
|
-
return "0x03cac3228b434259734ee0e4ff445f642206ea11adace7e4f45edd2596748698" /* TESTNET */;
|
|
4957
5007
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
4958
5008
|
return "0x058061bb6bdc501eE215172c9f87d557C1E0f466dC498cA81b18f998Bf1362b2" /* TESTNET_SEPOLIA */;
|
|
4959
5009
|
default:
|
|
@@ -4964,7 +5014,6 @@ function getStarknetIdPfpContract(chainId) {
|
|
|
4964
5014
|
}
|
|
4965
5015
|
var StarknetIdPopContract = /* @__PURE__ */ ((StarknetIdPopContract2) => {
|
|
4966
5016
|
StarknetIdPopContract2["MAINNET"] = "0x0293eb2ba9862f762bd3036586d5755a782bd22e6f5028320f1d0405fd47bff4";
|
|
4967
|
-
StarknetIdPopContract2["TESTNET"] = "0x03528caf090179e337931ee669a5b0214041e1bae30d460ff07d2cea2c7a9106";
|
|
4968
5017
|
StarknetIdPopContract2["TESTNET_SEPOLIA"] = "0x0023FE3b845ed5665a9eb3792bbB17347B490EE4090f855C1298d03BB5F49B49";
|
|
4969
5018
|
return StarknetIdPopContract2;
|
|
4970
5019
|
})(StarknetIdPopContract || {});
|
|
@@ -4972,8 +5021,6 @@ function getStarknetIdPopContract(chainId) {
|
|
|
4972
5021
|
switch (chainId) {
|
|
4973
5022
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
4974
5023
|
return "0x0293eb2ba9862f762bd3036586d5755a782bd22e6f5028320f1d0405fd47bff4" /* MAINNET */;
|
|
4975
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
4976
|
-
return "0x03528caf090179e337931ee669a5b0214041e1bae30d460ff07d2cea2c7a9106" /* TESTNET */;
|
|
4977
5024
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
4978
5025
|
return "0x0023FE3b845ed5665a9eb3792bbB17347B490EE4090f855C1298d03BB5F49B49" /* TESTNET_SEPOLIA */;
|
|
4979
5026
|
default:
|
|
@@ -5038,13 +5085,7 @@ var StarknetId = class _StarknetId {
|
|
|
5038
5085
|
const chainId = await provider.getChainId();
|
|
5039
5086
|
const contract = StarknetIdContract2 ?? getStarknetIdContract(chainId);
|
|
5040
5087
|
try {
|
|
5041
|
-
const hexDomain = await
|
|
5042
|
-
contractAddress: contract,
|
|
5043
|
-
entrypoint: "address_to_domain",
|
|
5044
|
-
calldata: CallData.compile({
|
|
5045
|
-
address
|
|
5046
|
-
})
|
|
5047
|
-
});
|
|
5088
|
+
const hexDomain = await this.executeStarkName(provider, address, contract);
|
|
5048
5089
|
const decimalDomain = hexDomain.map((element) => BigInt(element)).slice(1);
|
|
5049
5090
|
const stringDomain = useDecoded(decimalDomain);
|
|
5050
5091
|
if (!stringDomain) {
|
|
@@ -5058,6 +5099,26 @@ var StarknetId = class _StarknetId {
|
|
|
5058
5099
|
throw Error("Could not get stark name");
|
|
5059
5100
|
}
|
|
5060
5101
|
}
|
|
5102
|
+
static async executeStarkName(provider, address, contract) {
|
|
5103
|
+
try {
|
|
5104
|
+
return await provider.callContract({
|
|
5105
|
+
contractAddress: contract,
|
|
5106
|
+
entrypoint: "address_to_domain",
|
|
5107
|
+
calldata: CallData.compile({
|
|
5108
|
+
address,
|
|
5109
|
+
hint: []
|
|
5110
|
+
})
|
|
5111
|
+
});
|
|
5112
|
+
} catch (initialError) {
|
|
5113
|
+
return await provider.callContract({
|
|
5114
|
+
contractAddress: contract,
|
|
5115
|
+
entrypoint: "address_to_domain",
|
|
5116
|
+
calldata: CallData.compile({
|
|
5117
|
+
address
|
|
5118
|
+
})
|
|
5119
|
+
});
|
|
5120
|
+
}
|
|
5121
|
+
}
|
|
5061
5122
|
static async getAddressFromStarkName(provider, name, StarknetIdContract2) {
|
|
5062
5123
|
const chainId = await provider.getChainId();
|
|
5063
5124
|
const contract = StarknetIdContract2 ?? getStarknetIdContract(chainId);
|
|
@@ -5082,100 +5143,111 @@ var StarknetId = class _StarknetId {
|
|
|
5082
5143
|
const popContract = StarknetIdPopContract2 ?? getStarknetIdPopContract(chainId);
|
|
5083
5144
|
const multicallAddress = StarknetIdMulticallContract2 ?? getStarknetIdMulticallContract(chainId);
|
|
5084
5145
|
try {
|
|
5085
|
-
const
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
to: dynamicFelt(contract),
|
|
5093
|
-
selector: dynamicFelt(getSelectorFromName("address_to_domain")),
|
|
5094
|
-
calldata: [dynamicCallData(address)]
|
|
5095
|
-
},
|
|
5096
|
-
{
|
|
5097
|
-
execution: execution({}),
|
|
5098
|
-
to: dynamicFelt(contract),
|
|
5099
|
-
selector: dynamicFelt(getSelectorFromName("domain_to_id")),
|
|
5100
|
-
calldata: [dynamicCallData(void 0, void 0, [0, 0])]
|
|
5101
|
-
},
|
|
5102
|
-
{
|
|
5103
|
-
execution: execution({}),
|
|
5104
|
-
to: dynamicFelt(identityContract),
|
|
5105
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5106
|
-
calldata: [
|
|
5107
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5108
|
-
dynamicCallData(encodeShortString("twitter")),
|
|
5109
|
-
dynamicCallData(verifierContract),
|
|
5110
|
-
dynamicCallData("0")
|
|
5111
|
-
]
|
|
5112
|
-
},
|
|
5113
|
-
{
|
|
5114
|
-
execution: execution({}),
|
|
5115
|
-
to: dynamicFelt(identityContract),
|
|
5116
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5117
|
-
calldata: [
|
|
5118
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5119
|
-
dynamicCallData(encodeShortString("github")),
|
|
5120
|
-
dynamicCallData(verifierContract),
|
|
5121
|
-
dynamicCallData("0")
|
|
5122
|
-
]
|
|
5123
|
-
},
|
|
5124
|
-
{
|
|
5125
|
-
execution: execution({}),
|
|
5126
|
-
to: dynamicFelt(identityContract),
|
|
5127
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5128
|
-
calldata: [
|
|
5129
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5130
|
-
dynamicCallData(encodeShortString("discord")),
|
|
5131
|
-
dynamicCallData(verifierContract),
|
|
5132
|
-
dynamicCallData("0")
|
|
5133
|
-
]
|
|
5134
|
-
},
|
|
5135
|
-
{
|
|
5136
|
-
execution: execution({}),
|
|
5137
|
-
to: dynamicFelt(identityContract),
|
|
5138
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5139
|
-
calldata: [
|
|
5140
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5141
|
-
dynamicCallData(encodeShortString("proof_of_personhood")),
|
|
5142
|
-
dynamicCallData(popContract),
|
|
5143
|
-
dynamicCallData("0")
|
|
5144
|
-
]
|
|
5145
|
-
},
|
|
5146
|
-
// PFP
|
|
5147
|
-
{
|
|
5148
|
-
execution: execution({}),
|
|
5149
|
-
to: dynamicFelt(identityContract),
|
|
5150
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5151
|
-
calldata: [
|
|
5152
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5153
|
-
dynamicCallData(encodeShortString("nft_pp_contract")),
|
|
5154
|
-
dynamicCallData(pfpContract),
|
|
5155
|
-
dynamicCallData("0")
|
|
5156
|
-
]
|
|
5157
|
-
},
|
|
5158
|
-
{
|
|
5159
|
-
execution: execution({}),
|
|
5160
|
-
to: dynamicFelt(identityContract),
|
|
5161
|
-
selector: dynamicFelt(getSelectorFromName("get_extended_verifier_data")),
|
|
5162
|
-
calldata: [
|
|
5163
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5164
|
-
dynamicCallData(encodeShortString("nft_pp_id")),
|
|
5165
|
-
dynamicCallData("2"),
|
|
5166
|
-
dynamicCallData(pfpContract),
|
|
5167
|
-
dynamicCallData("0")
|
|
5168
|
-
]
|
|
5169
|
-
},
|
|
5170
|
-
{
|
|
5171
|
-
execution: execution(void 0, void 0, [6, 0, 0]),
|
|
5172
|
-
to: dynamicFelt(void 0, [6, 0]),
|
|
5173
|
-
selector: dynamicFelt(getSelectorFromName("tokenURI")),
|
|
5174
|
-
calldata: [dynamicCallData(void 0, [7, 1]), dynamicCallData(void 0, [7, 2])]
|
|
5175
|
-
}
|
|
5176
|
-
]
|
|
5177
|
-
})
|
|
5146
|
+
const initialCalldata = [];
|
|
5147
|
+
const fallbackCalldata = [];
|
|
5148
|
+
initialCalldata.push({
|
|
5149
|
+
execution: execution({}),
|
|
5150
|
+
to: dynamicCallData(contract),
|
|
5151
|
+
selector: dynamicCallData(getSelectorFromName("address_to_domain")),
|
|
5152
|
+
calldata: [dynamicCallData(address), dynamicCallData("0")]
|
|
5178
5153
|
});
|
|
5154
|
+
fallbackCalldata.push({
|
|
5155
|
+
execution: execution({}),
|
|
5156
|
+
to: dynamicCallData(contract),
|
|
5157
|
+
selector: dynamicFelt(getSelectorFromName("address_to_domain")),
|
|
5158
|
+
calldata: [dynamicCallData(address)]
|
|
5159
|
+
});
|
|
5160
|
+
const calls = [
|
|
5161
|
+
{
|
|
5162
|
+
execution: execution({}),
|
|
5163
|
+
to: dynamicFelt(contract),
|
|
5164
|
+
selector: dynamicFelt(getSelectorFromName("domain_to_id")),
|
|
5165
|
+
calldata: [dynamicCallData(void 0, void 0, [0, 0])]
|
|
5166
|
+
},
|
|
5167
|
+
{
|
|
5168
|
+
execution: execution({}),
|
|
5169
|
+
to: dynamicFelt(identityContract),
|
|
5170
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5171
|
+
calldata: [
|
|
5172
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5173
|
+
dynamicCallData(encodeShortString("twitter")),
|
|
5174
|
+
dynamicCallData(verifierContract),
|
|
5175
|
+
dynamicCallData("0")
|
|
5176
|
+
]
|
|
5177
|
+
},
|
|
5178
|
+
{
|
|
5179
|
+
execution: execution({}),
|
|
5180
|
+
to: dynamicFelt(identityContract),
|
|
5181
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5182
|
+
calldata: [
|
|
5183
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5184
|
+
dynamicCallData(encodeShortString("github")),
|
|
5185
|
+
dynamicCallData(verifierContract),
|
|
5186
|
+
dynamicCallData("0")
|
|
5187
|
+
]
|
|
5188
|
+
},
|
|
5189
|
+
{
|
|
5190
|
+
execution: execution({}),
|
|
5191
|
+
to: dynamicFelt(identityContract),
|
|
5192
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5193
|
+
calldata: [
|
|
5194
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5195
|
+
dynamicCallData(encodeShortString("discord")),
|
|
5196
|
+
dynamicCallData(verifierContract),
|
|
5197
|
+
dynamicCallData("0")
|
|
5198
|
+
]
|
|
5199
|
+
},
|
|
5200
|
+
{
|
|
5201
|
+
execution: execution({}),
|
|
5202
|
+
to: dynamicFelt(identityContract),
|
|
5203
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5204
|
+
calldata: [
|
|
5205
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5206
|
+
dynamicCallData(encodeShortString("proof_of_personhood")),
|
|
5207
|
+
dynamicCallData(popContract),
|
|
5208
|
+
dynamicCallData("0")
|
|
5209
|
+
]
|
|
5210
|
+
},
|
|
5211
|
+
// PFP
|
|
5212
|
+
{
|
|
5213
|
+
execution: execution({}),
|
|
5214
|
+
to: dynamicFelt(identityContract),
|
|
5215
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5216
|
+
calldata: [
|
|
5217
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5218
|
+
dynamicCallData(encodeShortString("nft_pp_contract")),
|
|
5219
|
+
dynamicCallData(pfpContract),
|
|
5220
|
+
dynamicCallData("0")
|
|
5221
|
+
]
|
|
5222
|
+
},
|
|
5223
|
+
{
|
|
5224
|
+
execution: execution({}),
|
|
5225
|
+
to: dynamicFelt(identityContract),
|
|
5226
|
+
selector: dynamicFelt(getSelectorFromName("get_extended_verifier_data")),
|
|
5227
|
+
calldata: [
|
|
5228
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5229
|
+
dynamicCallData(encodeShortString("nft_pp_id")),
|
|
5230
|
+
dynamicCallData("2"),
|
|
5231
|
+
dynamicCallData(pfpContract),
|
|
5232
|
+
dynamicCallData("0")
|
|
5233
|
+
]
|
|
5234
|
+
},
|
|
5235
|
+
{
|
|
5236
|
+
execution: execution(void 0, void 0, [6, 0, 0]),
|
|
5237
|
+
to: dynamicFelt(void 0, [6, 0]),
|
|
5238
|
+
selector: dynamicFelt(getSelectorFromName("tokenURI")),
|
|
5239
|
+
calldata: [dynamicCallData(void 0, [7, 1]), dynamicCallData(void 0, [7, 2])]
|
|
5240
|
+
}
|
|
5241
|
+
];
|
|
5242
|
+
initialCalldata.push(...calls);
|
|
5243
|
+
fallbackCalldata.push(...calls);
|
|
5244
|
+
const data = await this.executeStarkProfile(
|
|
5245
|
+
provider,
|
|
5246
|
+
multicallAddress,
|
|
5247
|
+
"aggregate",
|
|
5248
|
+
initialCalldata,
|
|
5249
|
+
fallbackCalldata
|
|
5250
|
+
);
|
|
5179
5251
|
if (Array.isArray(data)) {
|
|
5180
5252
|
const size = parseInt(data[0], 16);
|
|
5181
5253
|
const finalArray = [];
|
|
@@ -5215,6 +5287,25 @@ var StarknetId = class _StarknetId {
|
|
|
5215
5287
|
throw Error("Could not get user stark profile data from address");
|
|
5216
5288
|
}
|
|
5217
5289
|
}
|
|
5290
|
+
static async executeStarkProfile(provider, contract, functionName, initialCalldata, fallbackCalldata) {
|
|
5291
|
+
try {
|
|
5292
|
+
return await provider.callContract({
|
|
5293
|
+
contractAddress: contract,
|
|
5294
|
+
entrypoint: functionName,
|
|
5295
|
+
calldata: CallData.compile({
|
|
5296
|
+
calls: initialCalldata
|
|
5297
|
+
})
|
|
5298
|
+
});
|
|
5299
|
+
} catch (initialError) {
|
|
5300
|
+
return await provider.callContract({
|
|
5301
|
+
contractAddress: contract,
|
|
5302
|
+
entrypoint: functionName,
|
|
5303
|
+
calldata: CallData.compile({
|
|
5304
|
+
calls: fallbackCalldata
|
|
5305
|
+
})
|
|
5306
|
+
});
|
|
5307
|
+
}
|
|
5308
|
+
}
|
|
5218
5309
|
};
|
|
5219
5310
|
|
|
5220
5311
|
// src/provider/extensions/default.ts
|
|
@@ -5897,7 +5988,7 @@ var Account = class extends RpcProvider2 {
|
|
|
5897
5988
|
}
|
|
5898
5989
|
}
|
|
5899
5990
|
/**
|
|
5900
|
-
* Retrieves the Cairo version from the network and sets `cairoVersion` if not already set in the constructor
|
|
5991
|
+
* Retrieves the Cairo version from the network and sets `cairoVersion` if not already set in the constructor.
|
|
5901
5992
|
* @param classHash if provided detects Cairo version from classHash, otherwise from the account address
|
|
5902
5993
|
*/
|
|
5903
5994
|
async getCairoVersion(classHash) {
|
|
@@ -6232,32 +6323,64 @@ var Account = class extends RpcProvider2 {
|
|
|
6232
6323
|
async hashMessage(typedData) {
|
|
6233
6324
|
return getMessageHash(typedData, this.address);
|
|
6234
6325
|
}
|
|
6235
|
-
async verifyMessageHash(hash, signature) {
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6326
|
+
async verifyMessageHash(hash, signature, signatureVerificationFunctionName, signatureVerificationResponse) {
|
|
6327
|
+
const knownSigVerificationFName = signatureVerificationFunctionName ? [signatureVerificationFunctionName] : ["isValidSignature", "is_valid_signature"];
|
|
6328
|
+
const knownSignatureResponse = signatureVerificationResponse || {
|
|
6329
|
+
okResponse: [
|
|
6330
|
+
// any non-nok response is true
|
|
6331
|
+
],
|
|
6332
|
+
nokResponse: [
|
|
6333
|
+
"0x0",
|
|
6334
|
+
// Devnet
|
|
6335
|
+
"0x00"
|
|
6336
|
+
// OpenZeppelin 0.7.0 to 0.9.0 invalid signature
|
|
6337
|
+
],
|
|
6338
|
+
error: [
|
|
6339
|
+
"argent/invalid-signature",
|
|
6340
|
+
// ArgentX 0.3.0 to 0.3.1
|
|
6341
|
+
"is invalid, with respect to the public key",
|
|
6342
|
+
// OpenZeppelin until 0.6.1, Braavos 0.0.11
|
|
6343
|
+
"INVALID_SIG"
|
|
6344
|
+
// Braavos 1.0.0
|
|
6345
|
+
]
|
|
6346
|
+
};
|
|
6347
|
+
let error;
|
|
6348
|
+
for (const SigVerificationFName of knownSigVerificationFName) {
|
|
6349
|
+
try {
|
|
6350
|
+
const resp = await this.callContract({
|
|
6351
|
+
contractAddress: this.address,
|
|
6352
|
+
entrypoint: SigVerificationFName,
|
|
6353
|
+
calldata: CallData.compile({
|
|
6354
|
+
hash: toBigInt(hash).toString(),
|
|
6355
|
+
signature: formatSignature(signature)
|
|
6356
|
+
})
|
|
6357
|
+
});
|
|
6358
|
+
if (knownSignatureResponse.nokResponse.includes(resp[0].toString())) {
|
|
6359
|
+
return false;
|
|
6360
|
+
}
|
|
6361
|
+
if (knownSignatureResponse.okResponse.length === 0 || knownSignatureResponse.okResponse.includes(resp[0].toString())) {
|
|
6362
|
+
return true;
|
|
6363
|
+
}
|
|
6364
|
+
throw Error("signatureVerificationResponse Error: response is not part of known responses");
|
|
6365
|
+
} catch (err) {
|
|
6366
|
+
if (knownSignatureResponse.error.some(
|
|
6367
|
+
(errMessage) => err.message.includes(errMessage)
|
|
6368
|
+
)) {
|
|
6369
|
+
return false;
|
|
6370
|
+
}
|
|
6371
|
+
error = err;
|
|
6254
6372
|
}
|
|
6255
|
-
throw Error(`Signature verification request is rejected by the network: ${err}`);
|
|
6256
6373
|
}
|
|
6374
|
+
throw Error(`Signature verification Error: ${error}`);
|
|
6257
6375
|
}
|
|
6258
|
-
async verifyMessage(typedData, signature) {
|
|
6376
|
+
async verifyMessage(typedData, signature, signatureVerificationFunctionName, signatureVerificationResponse) {
|
|
6259
6377
|
const hash = await this.hashMessage(typedData);
|
|
6260
|
-
return this.verifyMessageHash(
|
|
6378
|
+
return this.verifyMessageHash(
|
|
6379
|
+
hash,
|
|
6380
|
+
signature,
|
|
6381
|
+
signatureVerificationFunctionName,
|
|
6382
|
+
signatureVerificationResponse
|
|
6383
|
+
);
|
|
6261
6384
|
}
|
|
6262
6385
|
/*
|
|
6263
6386
|
* Support methods
|
|
@@ -7133,7 +7256,6 @@ export {
|
|
|
7133
7256
|
ReceiptTx,
|
|
7134
7257
|
RpcChannel2 as RpcChannel,
|
|
7135
7258
|
RpcProvider2 as RpcProvider,
|
|
7136
|
-
SIMULATION_FLAG,
|
|
7137
7259
|
Signer,
|
|
7138
7260
|
SignerInterface,
|
|
7139
7261
|
TransactionExecutionStatus,
|