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.js
CHANGED
|
@@ -61,7 +61,6 @@ __export(src_exports, {
|
|
|
61
61
|
ReceiptTx: () => ReceiptTx,
|
|
62
62
|
RpcChannel: () => RpcChannel2,
|
|
63
63
|
RpcProvider: () => RpcProvider2,
|
|
64
|
-
SIMULATION_FLAG: () => SIMULATION_FLAG,
|
|
65
64
|
Signer: () => Signer,
|
|
66
65
|
SignerInterface: () => SignerInterface,
|
|
67
66
|
TransactionExecutionStatus: () => TransactionExecutionStatus,
|
|
@@ -350,19 +349,16 @@ var RANGE_I128 = range(-(2n ** 127n), 2n ** 127n - 1n);
|
|
|
350
349
|
var RANGE_U128 = range(ZERO, 2n ** 128n - 1n);
|
|
351
350
|
var BaseUrl = /* @__PURE__ */ ((BaseUrl2) => {
|
|
352
351
|
BaseUrl2["SN_MAIN"] = "https://alpha-mainnet.starknet.io";
|
|
353
|
-
BaseUrl2["SN_GOERLI"] = "https://alpha4.starknet.io";
|
|
354
352
|
BaseUrl2["SN_SEPOLIA"] = "https://alpha-sepolia.starknet.io";
|
|
355
353
|
return BaseUrl2;
|
|
356
354
|
})(BaseUrl || {});
|
|
357
355
|
var NetworkName = /* @__PURE__ */ ((NetworkName2) => {
|
|
358
356
|
NetworkName2["SN_MAIN"] = "SN_MAIN";
|
|
359
|
-
NetworkName2["SN_GOERLI"] = "SN_GOERLI";
|
|
360
357
|
NetworkName2["SN_SEPOLIA"] = "SN_SEPOLIA";
|
|
361
358
|
return NetworkName2;
|
|
362
359
|
})(NetworkName || {});
|
|
363
360
|
var StarknetChainId = /* @__PURE__ */ ((StarknetChainId6) => {
|
|
364
361
|
StarknetChainId6["SN_MAIN"] = "0x534e5f4d41494e";
|
|
365
|
-
StarknetChainId6["SN_GOERLI"] = "0x534e5f474f45524c49";
|
|
366
362
|
StarknetChainId6["SN_SEPOLIA"] = "0x534e5f5345504f4c4941";
|
|
367
363
|
return StarknetChainId6;
|
|
368
364
|
})(StarknetChainId || {});
|
|
@@ -386,10 +382,6 @@ var UDC = {
|
|
|
386
382
|
};
|
|
387
383
|
var RPC_DEFAULT_VERSION = "v0_7";
|
|
388
384
|
var RPC_NODES = {
|
|
389
|
-
SN_GOERLI: [
|
|
390
|
-
`https://starknet-testnet.public.blastapi.io/rpc/${RPC_DEFAULT_VERSION}`,
|
|
391
|
-
`https://free-rpc.nethermind.io/goerli-juno/${RPC_DEFAULT_VERSION}`
|
|
392
|
-
],
|
|
393
385
|
SN_MAIN: [
|
|
394
386
|
`https://starknet-mainnet.public.blastapi.io/rpc/${RPC_DEFAULT_VERSION}`,
|
|
395
387
|
`https://free-rpc.nethermind.io/mainnet-juno/${RPC_DEFAULT_VERSION}`
|
|
@@ -400,6 +392,16 @@ var RPC_NODES = {
|
|
|
400
392
|
]
|
|
401
393
|
};
|
|
402
394
|
|
|
395
|
+
// src/provider/rpc.ts
|
|
396
|
+
var import_utils2 = require("@noble/curves/abstract/utils");
|
|
397
|
+
var import_sha3 = require("@noble/hashes/sha3");
|
|
398
|
+
|
|
399
|
+
// src/channel/rpc_0_6.ts
|
|
400
|
+
var rpc_0_6_exports = {};
|
|
401
|
+
__export(rpc_0_6_exports, {
|
|
402
|
+
RpcChannel: () => RpcChannel
|
|
403
|
+
});
|
|
404
|
+
|
|
403
405
|
// src/provider/errors.ts
|
|
404
406
|
function fixStack(target, fn = target.constructor) {
|
|
405
407
|
const { captureStackTrace } = Error;
|
|
@@ -437,12 +439,6 @@ var HttpError = class extends LibraryError {
|
|
|
437
439
|
}
|
|
438
440
|
};
|
|
439
441
|
|
|
440
|
-
// src/channel/rpc_0_6.ts
|
|
441
|
-
var rpc_0_6_exports = {};
|
|
442
|
-
__export(rpc_0_6_exports, {
|
|
443
|
-
RpcChannel: () => RpcChannel
|
|
444
|
-
});
|
|
445
|
-
|
|
446
442
|
// src/types/index.ts
|
|
447
443
|
var types_exports = {};
|
|
448
444
|
__export(types_exports, {
|
|
@@ -451,7 +447,6 @@ __export(types_exports, {
|
|
|
451
447
|
EntryPointType: () => EntryPointType,
|
|
452
448
|
Literal: () => Literal,
|
|
453
449
|
RPC: () => api_exports,
|
|
454
|
-
SIMULATION_FLAG: () => SIMULATION_FLAG,
|
|
455
450
|
TransactionExecutionStatus: () => TransactionExecutionStatus,
|
|
456
451
|
TransactionFinalityStatus: () => TransactionFinalityStatus,
|
|
457
452
|
TransactionStatus: () => TransactionStatus,
|
|
@@ -461,13 +456,6 @@ __export(types_exports, {
|
|
|
461
456
|
ValidateType: () => ValidateType
|
|
462
457
|
});
|
|
463
458
|
|
|
464
|
-
// src/types/account.ts
|
|
465
|
-
var SIMULATION_FLAG = /* @__PURE__ */ ((SIMULATION_FLAG2) => {
|
|
466
|
-
SIMULATION_FLAG2["SKIP_VALIDATE"] = "SKIP_VALIDATE";
|
|
467
|
-
SIMULATION_FLAG2["SKIP_EXECUTE"] = "SKIP_EXECUTE";
|
|
468
|
-
return SIMULATION_FLAG2;
|
|
469
|
-
})(SIMULATION_FLAG || {});
|
|
470
|
-
|
|
471
459
|
// src/types/calldata.ts
|
|
472
460
|
var ValidateType = /* @__PURE__ */ ((ValidateType2) => {
|
|
473
461
|
ValidateType2["DEPLOY"] = "DEPLOY";
|
|
@@ -1286,46 +1274,49 @@ var guard = {
|
|
|
1286
1274
|
}
|
|
1287
1275
|
};
|
|
1288
1276
|
function formatter(data, type, sameType) {
|
|
1289
|
-
return Object.entries(data).reduce(
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
}
|
|
1295
|
-
if (elType === "string") {
|
|
1296
|
-
if (Array.isArray(data[key])) {
|
|
1297
|
-
const arrayStr = formatter(
|
|
1298
|
-
data[key],
|
|
1299
|
-
data[key].map((_) => elType)
|
|
1300
|
-
);
|
|
1301
|
-
acc[key] = Object.values(arrayStr).join("");
|
|
1277
|
+
return Object.entries(data).reduce(
|
|
1278
|
+
(acc, [key, value]) => {
|
|
1279
|
+
const elType = sameType ?? type[key];
|
|
1280
|
+
if (!(key in type) && !sameType) {
|
|
1281
|
+
acc[key] = value;
|
|
1302
1282
|
return acc;
|
|
1303
1283
|
}
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1284
|
+
if (elType === "string") {
|
|
1285
|
+
if (Array.isArray(data[key])) {
|
|
1286
|
+
const arrayStr = formatter(
|
|
1287
|
+
data[key],
|
|
1288
|
+
data[key].map((_) => elType)
|
|
1289
|
+
);
|
|
1290
|
+
acc[key] = Object.values(arrayStr).join("");
|
|
1291
|
+
return acc;
|
|
1292
|
+
}
|
|
1293
|
+
guard.isBN(data, type, key);
|
|
1294
|
+
acc[key] = decodeShortString(value);
|
|
1295
|
+
return acc;
|
|
1296
|
+
}
|
|
1297
|
+
if (elType === "number") {
|
|
1298
|
+
guard.isBN(data, type, key);
|
|
1299
|
+
acc[key] = Number(value);
|
|
1300
|
+
return acc;
|
|
1301
|
+
}
|
|
1302
|
+
if (typeof elType === "function") {
|
|
1303
|
+
acc[key] = elType(value);
|
|
1304
|
+
return acc;
|
|
1305
|
+
}
|
|
1306
|
+
if (Array.isArray(elType)) {
|
|
1307
|
+
const arrayObj = formatter(data[key], elType, elType[0]);
|
|
1308
|
+
acc[key] = Object.values(arrayObj);
|
|
1309
|
+
return acc;
|
|
1310
|
+
}
|
|
1311
|
+
if (typeof elType === "object") {
|
|
1312
|
+
acc[key] = formatter(data[key], elType);
|
|
1313
|
+
return acc;
|
|
1314
|
+
}
|
|
1315
|
+
guard.unknown(data, type, key);
|
|
1324
1316
|
return acc;
|
|
1325
|
-
}
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
}, {});
|
|
1317
|
+
},
|
|
1318
|
+
{}
|
|
1319
|
+
);
|
|
1329
1320
|
}
|
|
1330
1321
|
|
|
1331
1322
|
// src/utils/calldata/parser/parser-0-1.1.0.ts
|
|
@@ -1380,7 +1371,9 @@ var AbiParser2 = class {
|
|
|
1380
1371
|
* @returns FunctionAbi | undefined
|
|
1381
1372
|
*/
|
|
1382
1373
|
getMethod(name) {
|
|
1383
|
-
const intf = this.abi.find(
|
|
1374
|
+
const intf = this.abi.find(
|
|
1375
|
+
(it) => it.type === "interface"
|
|
1376
|
+
);
|
|
1384
1377
|
return intf.items.find((it) => it.name === name);
|
|
1385
1378
|
}
|
|
1386
1379
|
/**
|
|
@@ -2350,7 +2343,7 @@ var CallData = class _CallData {
|
|
|
2350
2343
|
* Compile contract callData with abi
|
|
2351
2344
|
* Parse the calldata by using input fields from the abi for that method
|
|
2352
2345
|
* @param method string - method name
|
|
2353
|
-
* @param
|
|
2346
|
+
* @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).
|
|
2354
2347
|
* @return Calldata - parsed arguments in format that contract is expecting
|
|
2355
2348
|
* @example
|
|
2356
2349
|
* ```typescript
|
|
@@ -3200,7 +3193,7 @@ function ethRandomPrivateKey() {
|
|
|
3200
3193
|
function validateAndParseEthAddress(address) {
|
|
3201
3194
|
assertInRange(address, ZERO, 2n ** 160n - 1n, "Ethereum Address ");
|
|
3202
3195
|
const result = addHexPrefix(removeHexPrefix(toHex(address)).padStart(40, "0"));
|
|
3203
|
-
assert(result.match(/^(0x)?[0-9a-f]{40}$/), "Invalid Ethereum Address Format");
|
|
3196
|
+
assert(Boolean(result.match(/^(0x)?[0-9a-f]{40}$/)), "Invalid Ethereum Address Format");
|
|
3204
3197
|
return result;
|
|
3205
3198
|
}
|
|
3206
3199
|
|
|
@@ -3608,11 +3601,12 @@ var RpcChannel = class {
|
|
|
3608
3601
|
* - skipValidate (default false)<br/>
|
|
3609
3602
|
* - skipFeeCharge (default true)<br/>
|
|
3610
3603
|
*/
|
|
3611
|
-
simulateTransaction(invocations, {
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3604
|
+
simulateTransaction(invocations, simulateTransactionOptions = {}) {
|
|
3605
|
+
const {
|
|
3606
|
+
blockIdentifier = this.blockIdentifier,
|
|
3607
|
+
skipValidate = true,
|
|
3608
|
+
skipFeeCharge = true
|
|
3609
|
+
} = simulateTransactionOptions;
|
|
3616
3610
|
const block_id = new Block(blockIdentifier).identifier;
|
|
3617
3611
|
const simulationFlags = [];
|
|
3618
3612
|
if (skipValidate)
|
|
@@ -3997,10 +3991,20 @@ var RpcChannel2 = class {
|
|
|
3997
3991
|
blockIdentifier;
|
|
3998
3992
|
chainId;
|
|
3999
3993
|
specVersion;
|
|
3994
|
+
transactionRetryIntervalFallback;
|
|
4000
3995
|
waitMode;
|
|
4001
3996
|
// behave like web2 rpc and return when tx is processed
|
|
4002
3997
|
constructor(optionsOrProvider) {
|
|
4003
|
-
const {
|
|
3998
|
+
const {
|
|
3999
|
+
nodeUrl,
|
|
4000
|
+
retries,
|
|
4001
|
+
headers,
|
|
4002
|
+
blockIdentifier,
|
|
4003
|
+
chainId,
|
|
4004
|
+
specVersion,
|
|
4005
|
+
waitMode,
|
|
4006
|
+
transactionRetryIntervalFallback
|
|
4007
|
+
} = optionsOrProvider || {};
|
|
4004
4008
|
if (Object.values(NetworkName).includes(nodeUrl)) {
|
|
4005
4009
|
this.nodeUrl = getDefaultNodeUrl(nodeUrl, optionsOrProvider?.default);
|
|
4006
4010
|
} else if (nodeUrl) {
|
|
@@ -4015,6 +4019,10 @@ var RpcChannel2 = class {
|
|
|
4015
4019
|
this.specVersion = specVersion;
|
|
4016
4020
|
this.waitMode = waitMode || false;
|
|
4017
4021
|
this.requestId = 0;
|
|
4022
|
+
this.transactionRetryIntervalFallback = transactionRetryIntervalFallback;
|
|
4023
|
+
}
|
|
4024
|
+
get transactionRetryIntervalDefault() {
|
|
4025
|
+
return this.transactionRetryIntervalFallback ?? 5e3;
|
|
4018
4026
|
}
|
|
4019
4027
|
setChainId(chainId) {
|
|
4020
4028
|
this.chainId = chainId;
|
|
@@ -4145,11 +4153,12 @@ var RpcChannel2 = class {
|
|
|
4145
4153
|
* - skipValidate (default false)<br/>
|
|
4146
4154
|
* - skipFeeCharge (default true)<br/>
|
|
4147
4155
|
*/
|
|
4148
|
-
simulateTransaction(invocations, {
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4156
|
+
simulateTransaction(invocations, simulateTransactionOptions = {}) {
|
|
4157
|
+
const {
|
|
4158
|
+
blockIdentifier = this.blockIdentifier,
|
|
4159
|
+
skipValidate = true,
|
|
4160
|
+
skipFeeCharge = true
|
|
4161
|
+
} = simulateTransactionOptions;
|
|
4153
4162
|
const block_id = new Block(blockIdentifier).identifier;
|
|
4154
4163
|
const simulationFlags = [];
|
|
4155
4164
|
if (skipValidate)
|
|
@@ -4167,7 +4176,7 @@ var RpcChannel2 = class {
|
|
|
4167
4176
|
let { retries } = this;
|
|
4168
4177
|
let onchain = false;
|
|
4169
4178
|
let isErrorState = false;
|
|
4170
|
-
const retryInterval = options?.retryInterval ??
|
|
4179
|
+
const retryInterval = options?.retryInterval ?? this.transactionRetryIntervalDefault;
|
|
4171
4180
|
const errorStates = options?.errorStates ?? [
|
|
4172
4181
|
RPCSPEC07.ETransactionStatus.REJECTED
|
|
4173
4182
|
// TODO: commented out to preserve the long-standing behavior of "reverted" not being treated as an error by default
|
|
@@ -4688,9 +4697,63 @@ var RpcProvider = class {
|
|
|
4688
4697
|
async getBlockWithTxs(blockIdentifier) {
|
|
4689
4698
|
return this.channel.getBlockWithTxs(blockIdentifier);
|
|
4690
4699
|
}
|
|
4700
|
+
/**
|
|
4701
|
+
* Pause the execution of the script until a specified block is created.
|
|
4702
|
+
* @param {BlockIdentifier} blockIdentifier bloc number (BigNumberisk) or 'pending' or 'latest'.
|
|
4703
|
+
* Use of 'latest" or of a block already created will generate no pause.
|
|
4704
|
+
* @param {number} [retryInterval] number of milliseconds between 2 requests to the node
|
|
4705
|
+
* @example
|
|
4706
|
+
* ```typescript
|
|
4707
|
+
* await myProvider.waitForBlock();
|
|
4708
|
+
* // wait the creation of the pending block
|
|
4709
|
+
* ```
|
|
4710
|
+
*/
|
|
4711
|
+
async waitForBlock(blockIdentifier = "pending", retryInterval = 5e3) {
|
|
4712
|
+
if (blockIdentifier === "latest" /* latest */)
|
|
4713
|
+
return;
|
|
4714
|
+
const currentBlock = await this.getBlockNumber();
|
|
4715
|
+
const targetBlock = blockIdentifier === "pending" /* pending */ ? currentBlock + 1 : Number(toHex(blockIdentifier));
|
|
4716
|
+
if (targetBlock <= currentBlock)
|
|
4717
|
+
return;
|
|
4718
|
+
const { retries } = this.channel;
|
|
4719
|
+
let retriesCount = retries;
|
|
4720
|
+
let isTargetBlock = false;
|
|
4721
|
+
while (!isTargetBlock) {
|
|
4722
|
+
const currBlock = await this.getBlockNumber();
|
|
4723
|
+
if (currBlock === targetBlock) {
|
|
4724
|
+
isTargetBlock = true;
|
|
4725
|
+
} else {
|
|
4726
|
+
await wait(retryInterval);
|
|
4727
|
+
}
|
|
4728
|
+
retriesCount -= 1;
|
|
4729
|
+
if (retriesCount <= 0) {
|
|
4730
|
+
throw new Error(`waitForBlock() timed-out after ${retries} tries.`);
|
|
4731
|
+
}
|
|
4732
|
+
}
|
|
4733
|
+
}
|
|
4691
4734
|
async getL1GasPrice(blockIdentifier) {
|
|
4692
4735
|
return this.channel.getBlockWithTxHashes(blockIdentifier).then(this.responseParser.parseL1GasPriceResponse);
|
|
4693
4736
|
}
|
|
4737
|
+
async getL1MessageHash(l2TxHash) {
|
|
4738
|
+
const transaction = await this.channel.getTransactionByHash(l2TxHash);
|
|
4739
|
+
assert(transaction.type === "L1_HANDLER", "This L2 transaction is not a L1 message.");
|
|
4740
|
+
const { calldata, contract_address, entry_point_selector, nonce } = transaction;
|
|
4741
|
+
const params = [
|
|
4742
|
+
calldata[0],
|
|
4743
|
+
contract_address,
|
|
4744
|
+
nonce,
|
|
4745
|
+
entry_point_selector,
|
|
4746
|
+
calldata.length - 1,
|
|
4747
|
+
...calldata.slice(1)
|
|
4748
|
+
];
|
|
4749
|
+
const myEncode = addHexPrefix(
|
|
4750
|
+
params.reduce(
|
|
4751
|
+
(res, par) => res + removeHexPrefix(toHex(par)).padStart(64, "0"),
|
|
4752
|
+
""
|
|
4753
|
+
)
|
|
4754
|
+
);
|
|
4755
|
+
return addHexPrefix((0, import_utils2.bytesToHex)((0, import_sha3.keccak_256)(hexToBytes(myEncode))));
|
|
4756
|
+
}
|
|
4694
4757
|
async getBlockWithReceipts(blockIdentifier) {
|
|
4695
4758
|
if (this.channel instanceof rpc_0_6_exports.RpcChannel)
|
|
4696
4759
|
throw new LibraryError("Unsupported method for RPC version");
|
|
@@ -4742,7 +4805,7 @@ var RpcProvider = class {
|
|
|
4742
4805
|
}
|
|
4743
4806
|
/**
|
|
4744
4807
|
* @param invocations AccountInvocations
|
|
4745
|
-
* @param
|
|
4808
|
+
* @param options blockIdentifier and flags to skip validation and fee charge<br/>
|
|
4746
4809
|
* - blockIdentifier<br/>
|
|
4747
4810
|
* - skipValidate (default false)<br/>
|
|
4748
4811
|
* - skipFeeCharge (default true)<br/>
|
|
@@ -4983,7 +5046,6 @@ function useEncoded(decoded) {
|
|
|
4983
5046
|
}
|
|
4984
5047
|
var StarknetIdContract = /* @__PURE__ */ ((StarknetIdContract2) => {
|
|
4985
5048
|
StarknetIdContract2["MAINNET"] = "0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678";
|
|
4986
|
-
StarknetIdContract2["TESTNET"] = "0x3bab268e932d2cecd1946f100ae67ce3dff9fd234119ea2f6da57d16d29fce";
|
|
4987
5049
|
StarknetIdContract2["TESTNET_SEPOLIA"] = "0x0707f09bc576bd7cfee59694846291047e965f4184fe13dac62c56759b3b6fa7";
|
|
4988
5050
|
return StarknetIdContract2;
|
|
4989
5051
|
})(StarknetIdContract || {});
|
|
@@ -4991,8 +5053,6 @@ function getStarknetIdContract(chainId) {
|
|
|
4991
5053
|
switch (chainId) {
|
|
4992
5054
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
4993
5055
|
return "0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678" /* MAINNET */;
|
|
4994
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
4995
|
-
return "0x3bab268e932d2cecd1946f100ae67ce3dff9fd234119ea2f6da57d16d29fce" /* TESTNET */;
|
|
4996
5056
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
4997
5057
|
return "0x0707f09bc576bd7cfee59694846291047e965f4184fe13dac62c56759b3b6fa7" /* TESTNET_SEPOLIA */;
|
|
4998
5058
|
default:
|
|
@@ -5001,7 +5061,6 @@ function getStarknetIdContract(chainId) {
|
|
|
5001
5061
|
}
|
|
5002
5062
|
var StarknetIdIdentityContract = /* @__PURE__ */ ((StarknetIdIdentityContract2) => {
|
|
5003
5063
|
StarknetIdIdentityContract2["MAINNET"] = "0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af";
|
|
5004
|
-
StarknetIdIdentityContract2["TESTNET"] = "0x783a9097b26eae0586373b2ce0ed3529ddc44069d1e0fbc4f66d42b69d6850d";
|
|
5005
5064
|
StarknetIdIdentityContract2["TESTNET_SEPOLIA"] = "0x070DF8B4F5cb2879f8592849fA8f3134da39d25326B8558cc9C8FE8D47EA3A90";
|
|
5006
5065
|
return StarknetIdIdentityContract2;
|
|
5007
5066
|
})(StarknetIdIdentityContract || {});
|
|
@@ -5009,8 +5068,6 @@ function getStarknetIdIdentityContract(chainId) {
|
|
|
5009
5068
|
switch (chainId) {
|
|
5010
5069
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
5011
5070
|
return "0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af" /* MAINNET */;
|
|
5012
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
5013
|
-
return "0x783a9097b26eae0586373b2ce0ed3529ddc44069d1e0fbc4f66d42b69d6850d" /* TESTNET */;
|
|
5014
5071
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
5015
5072
|
return "0x070DF8B4F5cb2879f8592849fA8f3134da39d25326B8558cc9C8FE8D47EA3A90" /* TESTNET_SEPOLIA */;
|
|
5016
5073
|
default:
|
|
@@ -5022,8 +5079,6 @@ function getStarknetIdMulticallContract(chainId) {
|
|
|
5022
5079
|
switch (chainId) {
|
|
5023
5080
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
5024
5081
|
return StarknetIdMulticallContract;
|
|
5025
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
5026
|
-
return StarknetIdMulticallContract;
|
|
5027
5082
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
5028
5083
|
return StarknetIdMulticallContract;
|
|
5029
5084
|
default:
|
|
@@ -5032,7 +5087,6 @@ function getStarknetIdMulticallContract(chainId) {
|
|
|
5032
5087
|
}
|
|
5033
5088
|
var StarknetIdVerifierContract = /* @__PURE__ */ ((StarknetIdVerifierContract2) => {
|
|
5034
5089
|
StarknetIdVerifierContract2["MAINNET"] = "0x07d14dfd8ee95b41fce179170d88ba1f0d5a512e13aeb232f19cfeec0a88f8bf";
|
|
5035
|
-
StarknetIdVerifierContract2["TESTNET"] = "0x057c942544063c3aea6ea6c37009cc9d1beacd750cb6801549a129c7265f0f11";
|
|
5036
5090
|
StarknetIdVerifierContract2["TESTNET_SEPOLIA"] = "0x0182EcE8173C216A395f4828e1523541b7e3600bf190CB252E1a1A0cE219d184";
|
|
5037
5091
|
return StarknetIdVerifierContract2;
|
|
5038
5092
|
})(StarknetIdVerifierContract || {});
|
|
@@ -5040,8 +5094,6 @@ function getStarknetIdVerifierContract(chainId) {
|
|
|
5040
5094
|
switch (chainId) {
|
|
5041
5095
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
5042
5096
|
return "0x07d14dfd8ee95b41fce179170d88ba1f0d5a512e13aeb232f19cfeec0a88f8bf" /* MAINNET */;
|
|
5043
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
5044
|
-
return "0x057c942544063c3aea6ea6c37009cc9d1beacd750cb6801549a129c7265f0f11" /* TESTNET */;
|
|
5045
5097
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
5046
5098
|
return "0x0182EcE8173C216A395f4828e1523541b7e3600bf190CB252E1a1A0cE219d184" /* TESTNET_SEPOLIA */;
|
|
5047
5099
|
default:
|
|
@@ -5050,7 +5102,6 @@ function getStarknetIdVerifierContract(chainId) {
|
|
|
5050
5102
|
}
|
|
5051
5103
|
var StarknetIdPfpContract = /* @__PURE__ */ ((StarknetIdPfpContract2) => {
|
|
5052
5104
|
StarknetIdPfpContract2["MAINNET"] = "0x070aaa20ec4a46da57c932d9fd89ca5e6bb9ca3188d3df361a32306aff7d59c7";
|
|
5053
|
-
StarknetIdPfpContract2["TESTNET"] = "0x03cac3228b434259734ee0e4ff445f642206ea11adace7e4f45edd2596748698";
|
|
5054
5105
|
StarknetIdPfpContract2["TESTNET_SEPOLIA"] = "0x058061bb6bdc501eE215172c9f87d557C1E0f466dC498cA81b18f998Bf1362b2";
|
|
5055
5106
|
return StarknetIdPfpContract2;
|
|
5056
5107
|
})(StarknetIdPfpContract || {});
|
|
@@ -5058,8 +5109,6 @@ function getStarknetIdPfpContract(chainId) {
|
|
|
5058
5109
|
switch (chainId) {
|
|
5059
5110
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
5060
5111
|
return "0x070aaa20ec4a46da57c932d9fd89ca5e6bb9ca3188d3df361a32306aff7d59c7" /* MAINNET */;
|
|
5061
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
5062
|
-
return "0x03cac3228b434259734ee0e4ff445f642206ea11adace7e4f45edd2596748698" /* TESTNET */;
|
|
5063
5112
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
5064
5113
|
return "0x058061bb6bdc501eE215172c9f87d557C1E0f466dC498cA81b18f998Bf1362b2" /* TESTNET_SEPOLIA */;
|
|
5065
5114
|
default:
|
|
@@ -5070,7 +5119,6 @@ function getStarknetIdPfpContract(chainId) {
|
|
|
5070
5119
|
}
|
|
5071
5120
|
var StarknetIdPopContract = /* @__PURE__ */ ((StarknetIdPopContract2) => {
|
|
5072
5121
|
StarknetIdPopContract2["MAINNET"] = "0x0293eb2ba9862f762bd3036586d5755a782bd22e6f5028320f1d0405fd47bff4";
|
|
5073
|
-
StarknetIdPopContract2["TESTNET"] = "0x03528caf090179e337931ee669a5b0214041e1bae30d460ff07d2cea2c7a9106";
|
|
5074
5122
|
StarknetIdPopContract2["TESTNET_SEPOLIA"] = "0x0023FE3b845ed5665a9eb3792bbB17347B490EE4090f855C1298d03BB5F49B49";
|
|
5075
5123
|
return StarknetIdPopContract2;
|
|
5076
5124
|
})(StarknetIdPopContract || {});
|
|
@@ -5078,8 +5126,6 @@ function getStarknetIdPopContract(chainId) {
|
|
|
5078
5126
|
switch (chainId) {
|
|
5079
5127
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
5080
5128
|
return "0x0293eb2ba9862f762bd3036586d5755a782bd22e6f5028320f1d0405fd47bff4" /* MAINNET */;
|
|
5081
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
5082
|
-
return "0x03528caf090179e337931ee669a5b0214041e1bae30d460ff07d2cea2c7a9106" /* TESTNET */;
|
|
5083
5129
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
5084
5130
|
return "0x0023FE3b845ed5665a9eb3792bbB17347B490EE4090f855C1298d03BB5F49B49" /* TESTNET_SEPOLIA */;
|
|
5085
5131
|
default:
|
|
@@ -5144,13 +5190,7 @@ var StarknetId = class _StarknetId {
|
|
|
5144
5190
|
const chainId = await provider.getChainId();
|
|
5145
5191
|
const contract = StarknetIdContract2 ?? getStarknetIdContract(chainId);
|
|
5146
5192
|
try {
|
|
5147
|
-
const hexDomain = await
|
|
5148
|
-
contractAddress: contract,
|
|
5149
|
-
entrypoint: "address_to_domain",
|
|
5150
|
-
calldata: CallData.compile({
|
|
5151
|
-
address
|
|
5152
|
-
})
|
|
5153
|
-
});
|
|
5193
|
+
const hexDomain = await this.executeStarkName(provider, address, contract);
|
|
5154
5194
|
const decimalDomain = hexDomain.map((element) => BigInt(element)).slice(1);
|
|
5155
5195
|
const stringDomain = useDecoded(decimalDomain);
|
|
5156
5196
|
if (!stringDomain) {
|
|
@@ -5164,6 +5204,26 @@ var StarknetId = class _StarknetId {
|
|
|
5164
5204
|
throw Error("Could not get stark name");
|
|
5165
5205
|
}
|
|
5166
5206
|
}
|
|
5207
|
+
static async executeStarkName(provider, address, contract) {
|
|
5208
|
+
try {
|
|
5209
|
+
return await provider.callContract({
|
|
5210
|
+
contractAddress: contract,
|
|
5211
|
+
entrypoint: "address_to_domain",
|
|
5212
|
+
calldata: CallData.compile({
|
|
5213
|
+
address,
|
|
5214
|
+
hint: []
|
|
5215
|
+
})
|
|
5216
|
+
});
|
|
5217
|
+
} catch (initialError) {
|
|
5218
|
+
return await provider.callContract({
|
|
5219
|
+
contractAddress: contract,
|
|
5220
|
+
entrypoint: "address_to_domain",
|
|
5221
|
+
calldata: CallData.compile({
|
|
5222
|
+
address
|
|
5223
|
+
})
|
|
5224
|
+
});
|
|
5225
|
+
}
|
|
5226
|
+
}
|
|
5167
5227
|
static async getAddressFromStarkName(provider, name, StarknetIdContract2) {
|
|
5168
5228
|
const chainId = await provider.getChainId();
|
|
5169
5229
|
const contract = StarknetIdContract2 ?? getStarknetIdContract(chainId);
|
|
@@ -5188,100 +5248,111 @@ var StarknetId = class _StarknetId {
|
|
|
5188
5248
|
const popContract = StarknetIdPopContract2 ?? getStarknetIdPopContract(chainId);
|
|
5189
5249
|
const multicallAddress = StarknetIdMulticallContract2 ?? getStarknetIdMulticallContract(chainId);
|
|
5190
5250
|
try {
|
|
5191
|
-
const
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
to: dynamicFelt(contract),
|
|
5205
|
-
selector: dynamicFelt(getSelectorFromName("domain_to_id")),
|
|
5206
|
-
calldata: [dynamicCallData(void 0, void 0, [0, 0])]
|
|
5207
|
-
},
|
|
5208
|
-
{
|
|
5209
|
-
execution: execution({}),
|
|
5210
|
-
to: dynamicFelt(identityContract),
|
|
5211
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5212
|
-
calldata: [
|
|
5213
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5214
|
-
dynamicCallData(encodeShortString("twitter")),
|
|
5215
|
-
dynamicCallData(verifierContract),
|
|
5216
|
-
dynamicCallData("0")
|
|
5217
|
-
]
|
|
5218
|
-
},
|
|
5219
|
-
{
|
|
5220
|
-
execution: execution({}),
|
|
5221
|
-
to: dynamicFelt(identityContract),
|
|
5222
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5223
|
-
calldata: [
|
|
5224
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5225
|
-
dynamicCallData(encodeShortString("github")),
|
|
5226
|
-
dynamicCallData(verifierContract),
|
|
5227
|
-
dynamicCallData("0")
|
|
5228
|
-
]
|
|
5229
|
-
},
|
|
5230
|
-
{
|
|
5231
|
-
execution: execution({}),
|
|
5232
|
-
to: dynamicFelt(identityContract),
|
|
5233
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5234
|
-
calldata: [
|
|
5235
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5236
|
-
dynamicCallData(encodeShortString("discord")),
|
|
5237
|
-
dynamicCallData(verifierContract),
|
|
5238
|
-
dynamicCallData("0")
|
|
5239
|
-
]
|
|
5240
|
-
},
|
|
5241
|
-
{
|
|
5242
|
-
execution: execution({}),
|
|
5243
|
-
to: dynamicFelt(identityContract),
|
|
5244
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5245
|
-
calldata: [
|
|
5246
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5247
|
-
dynamicCallData(encodeShortString("proof_of_personhood")),
|
|
5248
|
-
dynamicCallData(popContract),
|
|
5249
|
-
dynamicCallData("0")
|
|
5250
|
-
]
|
|
5251
|
-
},
|
|
5252
|
-
// PFP
|
|
5253
|
-
{
|
|
5254
|
-
execution: execution({}),
|
|
5255
|
-
to: dynamicFelt(identityContract),
|
|
5256
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5257
|
-
calldata: [
|
|
5258
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5259
|
-
dynamicCallData(encodeShortString("nft_pp_contract")),
|
|
5260
|
-
dynamicCallData(pfpContract),
|
|
5261
|
-
dynamicCallData("0")
|
|
5262
|
-
]
|
|
5263
|
-
},
|
|
5264
|
-
{
|
|
5265
|
-
execution: execution({}),
|
|
5266
|
-
to: dynamicFelt(identityContract),
|
|
5267
|
-
selector: dynamicFelt(getSelectorFromName("get_extended_verifier_data")),
|
|
5268
|
-
calldata: [
|
|
5269
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5270
|
-
dynamicCallData(encodeShortString("nft_pp_id")),
|
|
5271
|
-
dynamicCallData("2"),
|
|
5272
|
-
dynamicCallData(pfpContract),
|
|
5273
|
-
dynamicCallData("0")
|
|
5274
|
-
]
|
|
5275
|
-
},
|
|
5276
|
-
{
|
|
5277
|
-
execution: execution(void 0, void 0, [6, 0, 0]),
|
|
5278
|
-
to: dynamicFelt(void 0, [6, 0]),
|
|
5279
|
-
selector: dynamicFelt(getSelectorFromName("tokenURI")),
|
|
5280
|
-
calldata: [dynamicCallData(void 0, [7, 1]), dynamicCallData(void 0, [7, 2])]
|
|
5281
|
-
}
|
|
5282
|
-
]
|
|
5283
|
-
})
|
|
5251
|
+
const initialCalldata = [];
|
|
5252
|
+
const fallbackCalldata = [];
|
|
5253
|
+
initialCalldata.push({
|
|
5254
|
+
execution: execution({}),
|
|
5255
|
+
to: dynamicCallData(contract),
|
|
5256
|
+
selector: dynamicCallData(getSelectorFromName("address_to_domain")),
|
|
5257
|
+
calldata: [dynamicCallData(address), dynamicCallData("0")]
|
|
5258
|
+
});
|
|
5259
|
+
fallbackCalldata.push({
|
|
5260
|
+
execution: execution({}),
|
|
5261
|
+
to: dynamicCallData(contract),
|
|
5262
|
+
selector: dynamicFelt(getSelectorFromName("address_to_domain")),
|
|
5263
|
+
calldata: [dynamicCallData(address)]
|
|
5284
5264
|
});
|
|
5265
|
+
const calls = [
|
|
5266
|
+
{
|
|
5267
|
+
execution: execution({}),
|
|
5268
|
+
to: dynamicFelt(contract),
|
|
5269
|
+
selector: dynamicFelt(getSelectorFromName("domain_to_id")),
|
|
5270
|
+
calldata: [dynamicCallData(void 0, void 0, [0, 0])]
|
|
5271
|
+
},
|
|
5272
|
+
{
|
|
5273
|
+
execution: execution({}),
|
|
5274
|
+
to: dynamicFelt(identityContract),
|
|
5275
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5276
|
+
calldata: [
|
|
5277
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5278
|
+
dynamicCallData(encodeShortString("twitter")),
|
|
5279
|
+
dynamicCallData(verifierContract),
|
|
5280
|
+
dynamicCallData("0")
|
|
5281
|
+
]
|
|
5282
|
+
},
|
|
5283
|
+
{
|
|
5284
|
+
execution: execution({}),
|
|
5285
|
+
to: dynamicFelt(identityContract),
|
|
5286
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5287
|
+
calldata: [
|
|
5288
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5289
|
+
dynamicCallData(encodeShortString("github")),
|
|
5290
|
+
dynamicCallData(verifierContract),
|
|
5291
|
+
dynamicCallData("0")
|
|
5292
|
+
]
|
|
5293
|
+
},
|
|
5294
|
+
{
|
|
5295
|
+
execution: execution({}),
|
|
5296
|
+
to: dynamicFelt(identityContract),
|
|
5297
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5298
|
+
calldata: [
|
|
5299
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5300
|
+
dynamicCallData(encodeShortString("discord")),
|
|
5301
|
+
dynamicCallData(verifierContract),
|
|
5302
|
+
dynamicCallData("0")
|
|
5303
|
+
]
|
|
5304
|
+
},
|
|
5305
|
+
{
|
|
5306
|
+
execution: execution({}),
|
|
5307
|
+
to: dynamicFelt(identityContract),
|
|
5308
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5309
|
+
calldata: [
|
|
5310
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5311
|
+
dynamicCallData(encodeShortString("proof_of_personhood")),
|
|
5312
|
+
dynamicCallData(popContract),
|
|
5313
|
+
dynamicCallData("0")
|
|
5314
|
+
]
|
|
5315
|
+
},
|
|
5316
|
+
// PFP
|
|
5317
|
+
{
|
|
5318
|
+
execution: execution({}),
|
|
5319
|
+
to: dynamicFelt(identityContract),
|
|
5320
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5321
|
+
calldata: [
|
|
5322
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5323
|
+
dynamicCallData(encodeShortString("nft_pp_contract")),
|
|
5324
|
+
dynamicCallData(pfpContract),
|
|
5325
|
+
dynamicCallData("0")
|
|
5326
|
+
]
|
|
5327
|
+
},
|
|
5328
|
+
{
|
|
5329
|
+
execution: execution({}),
|
|
5330
|
+
to: dynamicFelt(identityContract),
|
|
5331
|
+
selector: dynamicFelt(getSelectorFromName("get_extended_verifier_data")),
|
|
5332
|
+
calldata: [
|
|
5333
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5334
|
+
dynamicCallData(encodeShortString("nft_pp_id")),
|
|
5335
|
+
dynamicCallData("2"),
|
|
5336
|
+
dynamicCallData(pfpContract),
|
|
5337
|
+
dynamicCallData("0")
|
|
5338
|
+
]
|
|
5339
|
+
},
|
|
5340
|
+
{
|
|
5341
|
+
execution: execution(void 0, void 0, [6, 0, 0]),
|
|
5342
|
+
to: dynamicFelt(void 0, [6, 0]),
|
|
5343
|
+
selector: dynamicFelt(getSelectorFromName("tokenURI")),
|
|
5344
|
+
calldata: [dynamicCallData(void 0, [7, 1]), dynamicCallData(void 0, [7, 2])]
|
|
5345
|
+
}
|
|
5346
|
+
];
|
|
5347
|
+
initialCalldata.push(...calls);
|
|
5348
|
+
fallbackCalldata.push(...calls);
|
|
5349
|
+
const data = await this.executeStarkProfile(
|
|
5350
|
+
provider,
|
|
5351
|
+
multicallAddress,
|
|
5352
|
+
"aggregate",
|
|
5353
|
+
initialCalldata,
|
|
5354
|
+
fallbackCalldata
|
|
5355
|
+
);
|
|
5285
5356
|
if (Array.isArray(data)) {
|
|
5286
5357
|
const size = parseInt(data[0], 16);
|
|
5287
5358
|
const finalArray = [];
|
|
@@ -5321,6 +5392,25 @@ var StarknetId = class _StarknetId {
|
|
|
5321
5392
|
throw Error("Could not get user stark profile data from address");
|
|
5322
5393
|
}
|
|
5323
5394
|
}
|
|
5395
|
+
static async executeStarkProfile(provider, contract, functionName, initialCalldata, fallbackCalldata) {
|
|
5396
|
+
try {
|
|
5397
|
+
return await provider.callContract({
|
|
5398
|
+
contractAddress: contract,
|
|
5399
|
+
entrypoint: functionName,
|
|
5400
|
+
calldata: CallData.compile({
|
|
5401
|
+
calls: initialCalldata
|
|
5402
|
+
})
|
|
5403
|
+
});
|
|
5404
|
+
} catch (initialError) {
|
|
5405
|
+
return await provider.callContract({
|
|
5406
|
+
contractAddress: contract,
|
|
5407
|
+
entrypoint: functionName,
|
|
5408
|
+
calldata: CallData.compile({
|
|
5409
|
+
calls: fallbackCalldata
|
|
5410
|
+
})
|
|
5411
|
+
});
|
|
5412
|
+
}
|
|
5413
|
+
}
|
|
5324
5414
|
};
|
|
5325
5415
|
|
|
5326
5416
|
// src/provider/extensions/default.ts
|
|
@@ -6003,7 +6093,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6003
6093
|
}
|
|
6004
6094
|
}
|
|
6005
6095
|
/**
|
|
6006
|
-
* Retrieves the Cairo version from the network and sets `cairoVersion` if not already set in the constructor
|
|
6096
|
+
* Retrieves the Cairo version from the network and sets `cairoVersion` if not already set in the constructor.
|
|
6007
6097
|
* @param classHash if provided detects Cairo version from classHash, otherwise from the account address
|
|
6008
6098
|
*/
|
|
6009
6099
|
async getCairoVersion(classHash) {
|
|
@@ -6338,32 +6428,64 @@ var Account = class extends RpcProvider2 {
|
|
|
6338
6428
|
async hashMessage(typedData) {
|
|
6339
6429
|
return getMessageHash(typedData, this.address);
|
|
6340
6430
|
}
|
|
6341
|
-
async verifyMessageHash(hash, signature) {
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6431
|
+
async verifyMessageHash(hash, signature, signatureVerificationFunctionName, signatureVerificationResponse) {
|
|
6432
|
+
const knownSigVerificationFName = signatureVerificationFunctionName ? [signatureVerificationFunctionName] : ["isValidSignature", "is_valid_signature"];
|
|
6433
|
+
const knownSignatureResponse = signatureVerificationResponse || {
|
|
6434
|
+
okResponse: [
|
|
6435
|
+
// any non-nok response is true
|
|
6436
|
+
],
|
|
6437
|
+
nokResponse: [
|
|
6438
|
+
"0x0",
|
|
6439
|
+
// Devnet
|
|
6440
|
+
"0x00"
|
|
6441
|
+
// OpenZeppelin 0.7.0 to 0.9.0 invalid signature
|
|
6442
|
+
],
|
|
6443
|
+
error: [
|
|
6444
|
+
"argent/invalid-signature",
|
|
6445
|
+
// ArgentX 0.3.0 to 0.3.1
|
|
6446
|
+
"is invalid, with respect to the public key",
|
|
6447
|
+
// OpenZeppelin until 0.6.1, Braavos 0.0.11
|
|
6448
|
+
"INVALID_SIG"
|
|
6449
|
+
// Braavos 1.0.0
|
|
6450
|
+
]
|
|
6451
|
+
};
|
|
6452
|
+
let error;
|
|
6453
|
+
for (const SigVerificationFName of knownSigVerificationFName) {
|
|
6454
|
+
try {
|
|
6455
|
+
const resp = await this.callContract({
|
|
6456
|
+
contractAddress: this.address,
|
|
6457
|
+
entrypoint: SigVerificationFName,
|
|
6458
|
+
calldata: CallData.compile({
|
|
6459
|
+
hash: toBigInt(hash).toString(),
|
|
6460
|
+
signature: formatSignature(signature)
|
|
6461
|
+
})
|
|
6462
|
+
});
|
|
6463
|
+
if (knownSignatureResponse.nokResponse.includes(resp[0].toString())) {
|
|
6464
|
+
return false;
|
|
6465
|
+
}
|
|
6466
|
+
if (knownSignatureResponse.okResponse.length === 0 || knownSignatureResponse.okResponse.includes(resp[0].toString())) {
|
|
6467
|
+
return true;
|
|
6468
|
+
}
|
|
6469
|
+
throw Error("signatureVerificationResponse Error: response is not part of known responses");
|
|
6470
|
+
} catch (err) {
|
|
6471
|
+
if (knownSignatureResponse.error.some(
|
|
6472
|
+
(errMessage) => err.message.includes(errMessage)
|
|
6473
|
+
)) {
|
|
6474
|
+
return false;
|
|
6475
|
+
}
|
|
6476
|
+
error = err;
|
|
6360
6477
|
}
|
|
6361
|
-
throw Error(`Signature verification request is rejected by the network: ${err}`);
|
|
6362
6478
|
}
|
|
6479
|
+
throw Error(`Signature verification Error: ${error}`);
|
|
6363
6480
|
}
|
|
6364
|
-
async verifyMessage(typedData, signature) {
|
|
6481
|
+
async verifyMessage(typedData, signature, signatureVerificationFunctionName, signatureVerificationResponse) {
|
|
6365
6482
|
const hash = await this.hashMessage(typedData);
|
|
6366
|
-
return this.verifyMessageHash(
|
|
6483
|
+
return this.verifyMessageHash(
|
|
6484
|
+
hash,
|
|
6485
|
+
signature,
|
|
6486
|
+
signatureVerificationFunctionName,
|
|
6487
|
+
signatureVerificationResponse
|
|
6488
|
+
);
|
|
6367
6489
|
}
|
|
6368
6490
|
/*
|
|
6369
6491
|
* Support methods
|
|
@@ -7147,7 +7269,7 @@ var ContractFactory = class {
|
|
|
7147
7269
|
};
|
|
7148
7270
|
|
|
7149
7271
|
// src/utils/address.ts
|
|
7150
|
-
var
|
|
7272
|
+
var import_utils3 = require("@noble/curves/abstract/utils");
|
|
7151
7273
|
function addAddressPadding(address) {
|
|
7152
7274
|
return addHexPrefix(removeHexPrefix(toHex(address)).padStart(64, "0"));
|
|
7153
7275
|
}
|
|
@@ -7162,7 +7284,7 @@ function validateAndParseAddress(address) {
|
|
|
7162
7284
|
function getChecksumAddress(address) {
|
|
7163
7285
|
const chars = removeHexPrefix(validateAndParseAddress(address)).toLowerCase().split("");
|
|
7164
7286
|
const hex = removeHexPrefix(keccakBn(address));
|
|
7165
|
-
const hashed = (0,
|
|
7287
|
+
const hashed = (0, import_utils3.hexToBytes)(hex.padStart(64, "0"));
|
|
7166
7288
|
for (let i = 0; i < chars.length; i += 2) {
|
|
7167
7289
|
if (hashed[i >> 1] >> 4 >= 8) {
|
|
7168
7290
|
chars[i] = chars[i].toUpperCase();
|
|
@@ -7240,7 +7362,6 @@ var number = num_exports;
|
|
|
7240
7362
|
ReceiptTx,
|
|
7241
7363
|
RpcChannel,
|
|
7242
7364
|
RpcProvider,
|
|
7243
|
-
SIMULATION_FLAG,
|
|
7244
7365
|
Signer,
|
|
7245
7366
|
SignerInterface,
|
|
7246
7367
|
TransactionExecutionStatus,
|