starknet 8.7.0 → 8.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 -0
- package/dist/index.d.ts +18 -5
- package/dist/index.global.js +58 -16
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +58 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -494,7 +494,7 @@ var DEFAULT_GLOBAL_CONFIG = {
|
|
|
494
494
|
blake: void 0
|
|
495
495
|
};
|
|
496
496
|
var RPC_DEFAULT_NODES = {
|
|
497
|
-
SN_MAIN: [`https://starknet-mainnet.g.alchemy.com/starknet/version/rpc
|
|
497
|
+
SN_MAIN: [`https://starknet-mainnet.g.alchemy.com/starknet/version/rpc/`],
|
|
498
498
|
SN_SEPOLIA: [`https://starknet-sepolia.g.alchemy.com/starknet/version/rpc/`]
|
|
499
499
|
};
|
|
500
500
|
var PAYMASTER_RPC_NODES = {
|
|
@@ -5408,8 +5408,8 @@ function computeContractClassHash(contract) {
|
|
|
5408
5408
|
}
|
|
5409
5409
|
return computeLegacyContractClassHash(compiledContract);
|
|
5410
5410
|
}
|
|
5411
|
-
function computeCompiledClassHash(casm,
|
|
5412
|
-
if (
|
|
5411
|
+
function computeCompiledClassHash(casm, starknetVersion) {
|
|
5412
|
+
if (starknetVersion && compareVersions(starknetVersion, "0.14.1") >= 0) {
|
|
5413
5413
|
return computeCompiledClassHashBlake(casm);
|
|
5414
5414
|
}
|
|
5415
5415
|
return computeCompiledClassHashPoseidon(casm);
|
|
@@ -5619,11 +5619,11 @@ function isSierra(contract) {
|
|
|
5619
5619
|
const compiledContract = isString(contract) ? parse2(contract) : contract;
|
|
5620
5620
|
return "sierra_program" in compiledContract;
|
|
5621
5621
|
}
|
|
5622
|
-
function extractContractHashes(payload,
|
|
5622
|
+
function extractContractHashes(payload, starknetVersion) {
|
|
5623
5623
|
const response = { ...payload };
|
|
5624
5624
|
if (isSierra(payload.contract)) {
|
|
5625
5625
|
if (!payload.compiledClassHash && payload.casm) {
|
|
5626
|
-
response.compiledClassHash = computeCompiledClassHash(payload.casm,
|
|
5626
|
+
response.compiledClassHash = computeCompiledClassHash(payload.casm, starknetVersion);
|
|
5627
5627
|
}
|
|
5628
5628
|
if (!response.compiledClassHash)
|
|
5629
5629
|
throw new Error(
|
|
@@ -6095,6 +6095,14 @@ var RpcChannel = class {
|
|
|
6095
6095
|
block_id
|
|
6096
6096
|
});
|
|
6097
6097
|
}
|
|
6098
|
+
/**
|
|
6099
|
+
* Helper method to get the starknet version from the block, default latest block
|
|
6100
|
+
* @returns Starknet version
|
|
6101
|
+
*/
|
|
6102
|
+
async getStarknetVersion(blockIdentifier = this.blockIdentifier) {
|
|
6103
|
+
const block = await this.getBlockWithTxHashes(blockIdentifier);
|
|
6104
|
+
return block.starknet_version;
|
|
6105
|
+
}
|
|
6098
6106
|
/**
|
|
6099
6107
|
* Get the most recent accepted block hash and number
|
|
6100
6108
|
*/
|
|
@@ -6684,6 +6692,14 @@ var RpcChannel2 = class {
|
|
|
6684
6692
|
block_id
|
|
6685
6693
|
});
|
|
6686
6694
|
}
|
|
6695
|
+
/**
|
|
6696
|
+
* Helper method to get the starknet version from the block, default latest block
|
|
6697
|
+
* @returns Starknet version
|
|
6698
|
+
*/
|
|
6699
|
+
async getStarknetVersion(blockIdentifier = this.blockIdentifier) {
|
|
6700
|
+
const block = await this.getBlockWithTxHashes(blockIdentifier);
|
|
6701
|
+
return block.starknet_version;
|
|
6702
|
+
}
|
|
6687
6703
|
/**
|
|
6688
6704
|
* Get the most recent accepted block hash and number
|
|
6689
6705
|
*/
|
|
@@ -8623,6 +8639,9 @@ var RpcProvider = class {
|
|
|
8623
8639
|
setUpSpecVersion() {
|
|
8624
8640
|
return this.channel.setUpSpecVersion();
|
|
8625
8641
|
}
|
|
8642
|
+
async getStarknetVersion(blockIdentifier) {
|
|
8643
|
+
return this.channel.getStarknetVersion(blockIdentifier);
|
|
8644
|
+
}
|
|
8626
8645
|
async getNonceForAddress(contractAddress, blockIdentifier) {
|
|
8627
8646
|
return this.channel.getNonceForAddress(contractAddress, blockIdentifier);
|
|
8628
8647
|
}
|
|
@@ -8862,7 +8881,7 @@ var RpcProvider = class {
|
|
|
8862
8881
|
if (!contractClassIdentifier.classHash && "contract" in contractClassIdentifier) {
|
|
8863
8882
|
const hashes = extractContractHashes(
|
|
8864
8883
|
contractClassIdentifier,
|
|
8865
|
-
await this.channel.
|
|
8884
|
+
await this.channel.getStarknetVersion()
|
|
8866
8885
|
);
|
|
8867
8886
|
classHash = hashes.classHash;
|
|
8868
8887
|
} else if (contractClassIdentifier.classHash) {
|
|
@@ -11236,7 +11255,7 @@ var Account = class extends RpcProvider2 {
|
|
|
11236
11255
|
const invocations = [
|
|
11237
11256
|
{
|
|
11238
11257
|
type: api_exports.ETransactionType.DECLARE,
|
|
11239
|
-
payload: extractContractHashes(payload, await this.channel.
|
|
11258
|
+
payload: extractContractHashes(payload, await this.channel.getStarknetVersion())
|
|
11240
11259
|
}
|
|
11241
11260
|
];
|
|
11242
11261
|
const estimateBulk = await this.estimateFeeBulk(invocations, details);
|
|
@@ -11402,7 +11421,7 @@ var Account = class extends RpcProvider2 {
|
|
|
11402
11421
|
async declareIfNot(payload, transactionsDetail = {}) {
|
|
11403
11422
|
const declareContractPayload = extractContractHashes(
|
|
11404
11423
|
payload,
|
|
11405
|
-
await this.channel.
|
|
11424
|
+
await this.channel.getStarknetVersion()
|
|
11406
11425
|
);
|
|
11407
11426
|
try {
|
|
11408
11427
|
await this.getClassByHash(declareContractPayload.classHash);
|
|
@@ -11418,7 +11437,7 @@ var Account = class extends RpcProvider2 {
|
|
|
11418
11437
|
assert(isSierra(payload.contract), SYSTEM_MESSAGES.declareNonSierra);
|
|
11419
11438
|
const declareContractPayload = extractContractHashes(
|
|
11420
11439
|
payload,
|
|
11421
|
-
await this.channel.
|
|
11440
|
+
await this.channel.getStarknetVersion()
|
|
11422
11441
|
);
|
|
11423
11442
|
const detailsWithTip = await this.resolveDetailsWithTip(details);
|
|
11424
11443
|
const { resourceBounds: providedResourceBounds } = details;
|
|
@@ -11728,7 +11747,7 @@ var Account = class extends RpcProvider2 {
|
|
|
11728
11747
|
async buildDeclarePayload(payload, details) {
|
|
11729
11748
|
const { classHash, contract, compiledClassHash } = extractContractHashes(
|
|
11730
11749
|
payload,
|
|
11731
|
-
await this.channel.
|
|
11750
|
+
await this.channel.getStarknetVersion()
|
|
11732
11751
|
);
|
|
11733
11752
|
const compressedCompiledContract = parseContract(contract);
|
|
11734
11753
|
assert(
|
|
@@ -12078,7 +12097,7 @@ var WalletAccount = class _WalletAccount extends Account {
|
|
|
12078
12097
|
async declare(payload) {
|
|
12079
12098
|
const declareContractPayload = extractContractHashes(
|
|
12080
12099
|
payload,
|
|
12081
|
-
await this.channel.
|
|
12100
|
+
await this.channel.getStarknetVersion()
|
|
12082
12101
|
);
|
|
12083
12102
|
const pContract = payload.contract;
|
|
12084
12103
|
const cairo1Contract = {
|
|
@@ -12420,7 +12439,7 @@ var Contract = class _Contract {
|
|
|
12420
12439
|
});
|
|
12421
12440
|
}
|
|
12422
12441
|
async invoke(method, args = [], options = {}) {
|
|
12423
|
-
const { parseRequest = true, signature, waitForTransaction, ...
|
|
12442
|
+
const { parseRequest = true, signature, waitForTransaction, ...restInvokeOptions } = options;
|
|
12424
12443
|
assert(this.address !== null, "contract is not connected to an address");
|
|
12425
12444
|
const calldata = getCompiledCalldata(args, () => {
|
|
12426
12445
|
if (parseRequest) {
|
|
@@ -12436,8 +12455,20 @@ var Contract = class _Contract {
|
|
|
12436
12455
|
entrypoint: method
|
|
12437
12456
|
};
|
|
12438
12457
|
if (isAccount(this.providerOrAccount)) {
|
|
12458
|
+
if (restInvokeOptions.paymasterDetails) {
|
|
12459
|
+
const myCall = {
|
|
12460
|
+
contractAddress: this.address,
|
|
12461
|
+
entrypoint: method,
|
|
12462
|
+
calldata: args
|
|
12463
|
+
};
|
|
12464
|
+
return this.providerOrAccount.executePaymasterTransaction(
|
|
12465
|
+
[myCall],
|
|
12466
|
+
restInvokeOptions.paymasterDetails,
|
|
12467
|
+
restInvokeOptions.maxFeeInGasToken
|
|
12468
|
+
);
|
|
12469
|
+
}
|
|
12439
12470
|
const result = await this.providerOrAccount.execute(invocation, {
|
|
12440
|
-
...
|
|
12471
|
+
...restInvokeOptions
|
|
12441
12472
|
});
|
|
12442
12473
|
if (waitForTransaction) {
|
|
12443
12474
|
const result2 = await this.providerOrAccount.waitForTransaction(result.transaction_hash);
|
|
@@ -12448,7 +12479,7 @@ var Contract = class _Contract {
|
|
|
12448
12479
|
}
|
|
12449
12480
|
return result;
|
|
12450
12481
|
}
|
|
12451
|
-
if (!
|
|
12482
|
+
if (!restInvokeOptions.nonce)
|
|
12452
12483
|
throw new Error(`Manual nonce is required when invoking a function without an account`);
|
|
12453
12484
|
logger.warn(`Invoking ${method} without an account.`);
|
|
12454
12485
|
return this.providerOrAccount.invokeFunction(
|
|
@@ -12457,8 +12488,8 @@ var Contract = class _Contract {
|
|
|
12457
12488
|
signature
|
|
12458
12489
|
},
|
|
12459
12490
|
{
|
|
12460
|
-
...
|
|
12461
|
-
nonce:
|
|
12491
|
+
...restInvokeOptions,
|
|
12492
|
+
nonce: restInvokeOptions.nonce
|
|
12462
12493
|
}
|
|
12463
12494
|
);
|
|
12464
12495
|
}
|
|
@@ -12469,6 +12500,17 @@ var Contract = class _Contract {
|
|
|
12469
12500
|
}
|
|
12470
12501
|
const invocation = this.populate(method, args);
|
|
12471
12502
|
if (isAccount(this.providerOrAccount)) {
|
|
12503
|
+
if (estimateDetails.paymasterDetails) {
|
|
12504
|
+
const myCall = {
|
|
12505
|
+
contractAddress: this.address,
|
|
12506
|
+
entrypoint: method,
|
|
12507
|
+
calldata: args
|
|
12508
|
+
};
|
|
12509
|
+
return this.providerOrAccount.estimatePaymasterTransactionFee(
|
|
12510
|
+
[myCall],
|
|
12511
|
+
estimateDetails.paymasterDetails
|
|
12512
|
+
);
|
|
12513
|
+
}
|
|
12472
12514
|
return this.providerOrAccount.estimateInvokeFee(invocation, estimateDetails);
|
|
12473
12515
|
}
|
|
12474
12516
|
throw Error("Contract must be connected to the account contract to estimate");
|