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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
# [8.9.0](https://github.com/starknet-io/starknet.js/compare/v8.8.0...v8.9.0) (2025-11-13)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
- paymaster snip-29 in Contract class ([#1470](https://github.com/starknet-io/starknet.js/issues/1470)) ([a6b839e](https://github.com/starknet-io/starknet.js/commit/a6b839eec40c2d610e98edba6b838749c7e89053))
|
|
6
|
+
|
|
7
|
+
# [8.8.0](https://github.com/starknet-io/starknet.js/compare/v8.7.0...v8.8.0) (2025-11-12)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
- both sepolia and mainet on alchemy ([f119081](https://github.com/starknet-io/starknet.js/commit/f1190815ba032a0b4094e6c16c3b6cd4cca216e1))
|
|
12
|
+
- public node hotfix ([d35e39e](https://github.com/starknet-io/starknet.js/commit/d35e39eb600a30b46146630ec0bbc916db65d976))
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- starknet version, use starknt version to determin declare hash instead of spec version ([70a23ee](https://github.com/starknet-io/starknet.js/commit/70a23ee4f14d5f7a0d754bfcfc3312cd5585b951))
|
|
17
|
+
|
|
1
18
|
# [8.7.0](https://github.com/starknet-io/starknet.js/compare/v8.6.0...v8.7.0) (2025-11-07)
|
|
2
19
|
|
|
3
20
|
### Bug Fixes
|
package/dist/index.d.ts
CHANGED
|
@@ -3244,6 +3244,8 @@ type ExecuteOptions = Pick<CommonContractOptions, 'parseRequest'> & {
|
|
|
3244
3244
|
* Deployer contract salt
|
|
3245
3245
|
*/
|
|
3246
3246
|
salt?: string;
|
|
3247
|
+
paymasterDetails?: PaymasterDetails;
|
|
3248
|
+
maxFeeInGasToken?: BigNumberish;
|
|
3247
3249
|
/**
|
|
3248
3250
|
* Wait for transaction to be included in a block
|
|
3249
3251
|
* @default false
|
|
@@ -3917,7 +3919,7 @@ declare const DEFAULT_GLOBAL_CONFIG: {
|
|
|
3917
3919
|
blake: ((uint8Array: Uint8Array) => Uint8Array) | undefined;
|
|
3918
3920
|
};
|
|
3919
3921
|
declare const RPC_DEFAULT_NODES: {
|
|
3920
|
-
readonly SN_MAIN: readonly ["https://starknet-mainnet.g.alchemy.com/starknet/version/rpc"];
|
|
3922
|
+
readonly SN_MAIN: readonly ["https://starknet-mainnet.g.alchemy.com/starknet/version/rpc/"];
|
|
3921
3923
|
readonly SN_SEPOLIA: readonly ["https://starknet-sepolia.g.alchemy.com/starknet/version/rpc/"];
|
|
3922
3924
|
};
|
|
3923
3925
|
declare const PAYMASTER_RPC_NODES: {
|
|
@@ -4022,6 +4024,11 @@ declare class RpcChannel$1 {
|
|
|
4022
4024
|
blockIdentifier?: BlockIdentifier): Promise<RPCSPEC08.StorageProof>;
|
|
4023
4025
|
getCompiledCasm(classHash: BigNumberish): Promise<RPCSPEC08.CASM_COMPILED_CONTRACT_CLASS>;
|
|
4024
4026
|
getNonceForAddress(contractAddress: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<string>;
|
|
4027
|
+
/**
|
|
4028
|
+
* Helper method to get the starknet version from the block, default latest block
|
|
4029
|
+
* @returns Starknet version
|
|
4030
|
+
*/
|
|
4031
|
+
getStarknetVersion(blockIdentifier?: BlockIdentifier): Promise<string>;
|
|
4025
4032
|
/**
|
|
4026
4033
|
* Get the most recent accepted block hash and number
|
|
4027
4034
|
*/
|
|
@@ -4165,6 +4172,11 @@ declare class RpcChannel {
|
|
|
4165
4172
|
blockIdentifier?: BlockIdentifier): Promise<RPC.StorageProof>;
|
|
4166
4173
|
getCompiledCasm(classHash: BigNumberish): Promise<RPC.CASM_COMPILED_CONTRACT_CLASS>;
|
|
4167
4174
|
getNonceForAddress(contractAddress: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<string>;
|
|
4175
|
+
/**
|
|
4176
|
+
* Helper method to get the starknet version from the block, default latest block
|
|
4177
|
+
* @returns Starknet version
|
|
4178
|
+
*/
|
|
4179
|
+
getStarknetVersion(blockIdentifier?: BlockIdentifier): Promise<string>;
|
|
4168
4180
|
/**
|
|
4169
4181
|
* Get the most recent accepted block hash and number
|
|
4170
4182
|
*/
|
|
@@ -4708,6 +4720,7 @@ declare class RpcProvider$1 implements ProviderInterface {
|
|
|
4708
4720
|
readSpecVersion(): "0.8.1" | "0.9.0" | undefined;
|
|
4709
4721
|
getSpecVersion(): Promise<string>;
|
|
4710
4722
|
setUpSpecVersion(): Promise<"0.8.1" | "0.9.0">;
|
|
4723
|
+
getStarknetVersion(blockIdentifier?: BlockIdentifier): Promise<string>;
|
|
4711
4724
|
getNonceForAddress(contractAddress: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<string>;
|
|
4712
4725
|
getBlock(): Promise<PendingBlock>;
|
|
4713
4726
|
getBlock(blockIdentifier: 'pre_confirmed'): Promise<PendingBlock>;
|
|
@@ -5344,7 +5357,7 @@ declare abstract class ContractInterface {
|
|
|
5344
5357
|
*/
|
|
5345
5358
|
abstract estimate(method: string, args?: ArgsOrCalldata, options?: {
|
|
5346
5359
|
blockIdentifier?: BlockIdentifier;
|
|
5347
|
-
}): Promise<EstimateFeeResponseOverhead>;
|
|
5360
|
+
}): Promise<EstimateFeeResponseOverhead | PaymasterFeeEstimate>;
|
|
5348
5361
|
/**
|
|
5349
5362
|
* Populate transaction data for a contract method call
|
|
5350
5363
|
*
|
|
@@ -5472,7 +5485,7 @@ declare class Contract implements ContractInterface {
|
|
|
5472
5485
|
waitForTransaction: false;
|
|
5473
5486
|
}): Promise<InvokeFunctionResponse>;
|
|
5474
5487
|
invoke(method: string, args?: ArgsOrCalldata, options?: ExecuteOptions): Promise<InvokeFunctionResponse>;
|
|
5475
|
-
estimate(method: string, args?: ArgsOrCalldata, estimateDetails?:
|
|
5488
|
+
estimate(method: string, args?: ArgsOrCalldata, estimateDetails?: ExecuteOptions): Promise<EstimateFeeResponseOverhead | PaymasterFeeEstimate>;
|
|
5476
5489
|
populate(method: string, args?: RawArgs): Call;
|
|
5477
5490
|
parseEvents(receipt: GetTransactionReceiptResponse): ParsedEvents;
|
|
5478
5491
|
isCairo1(): boolean;
|
|
@@ -5983,7 +5996,7 @@ declare function computeCompiledClassHash(casm: CompiledSierraCasm,
|
|
|
5983
5996
|
/**
|
|
5984
5997
|
* Used to determine which hashing algorithm to use
|
|
5985
5998
|
*/
|
|
5986
|
-
|
|
5999
|
+
starknetVersion?: string): string;
|
|
5987
6000
|
|
|
5988
6001
|
/**
|
|
5989
6002
|
* Hashes Exports
|
|
@@ -9285,7 +9298,7 @@ declare function isSierra(contract: CairoContract | string): contract is SierraC
|
|
|
9285
9298
|
* // }
|
|
9286
9299
|
* ```
|
|
9287
9300
|
*/
|
|
9288
|
-
declare function extractContractHashes(payload: DeclareContractPayload,
|
|
9301
|
+
declare function extractContractHashes(payload: DeclareContractPayload, starknetVersion?: string): CompleteDeclareContractPayload;
|
|
9289
9302
|
/**
|
|
9290
9303
|
* Helper to redeclare response Cairo0 contract
|
|
9291
9304
|
*/
|
package/dist/index.global.js
CHANGED
|
@@ -1179,7 +1179,7 @@ var starknet = (() => {
|
|
|
1179
1179
|
blake: void 0
|
|
1180
1180
|
};
|
|
1181
1181
|
var RPC_DEFAULT_NODES = {
|
|
1182
|
-
SN_MAIN: [`https://starknet-mainnet.g.alchemy.com/starknet/version/rpc
|
|
1182
|
+
SN_MAIN: [`https://starknet-mainnet.g.alchemy.com/starknet/version/rpc/`],
|
|
1183
1183
|
SN_SEPOLIA: [`https://starknet-sepolia.g.alchemy.com/starknet/version/rpc/`]
|
|
1184
1184
|
};
|
|
1185
1185
|
var PAYMASTER_RPC_NODES = {
|
|
@@ -9938,8 +9938,8 @@ ${indent}}` : "}";
|
|
|
9938
9938
|
}
|
|
9939
9939
|
return computeLegacyContractClassHash(compiledContract);
|
|
9940
9940
|
}
|
|
9941
|
-
function computeCompiledClassHash(casm,
|
|
9942
|
-
if (
|
|
9941
|
+
function computeCompiledClassHash(casm, starknetVersion) {
|
|
9942
|
+
if (starknetVersion && compareVersions(starknetVersion, "0.14.1") >= 0) {
|
|
9943
9943
|
return computeCompiledClassHashBlake(casm);
|
|
9944
9944
|
}
|
|
9945
9945
|
return computeCompiledClassHashPoseidon(casm);
|
|
@@ -14324,11 +14324,11 @@ ${indent}}` : "}";
|
|
|
14324
14324
|
const compiledContract = isString(contract) ? parse2(contract) : contract;
|
|
14325
14325
|
return "sierra_program" in compiledContract;
|
|
14326
14326
|
}
|
|
14327
|
-
function extractContractHashes(payload,
|
|
14327
|
+
function extractContractHashes(payload, starknetVersion) {
|
|
14328
14328
|
const response = { ...payload };
|
|
14329
14329
|
if (isSierra(payload.contract)) {
|
|
14330
14330
|
if (!payload.compiledClassHash && payload.casm) {
|
|
14331
|
-
response.compiledClassHash = computeCompiledClassHash(payload.casm,
|
|
14331
|
+
response.compiledClassHash = computeCompiledClassHash(payload.casm, starknetVersion);
|
|
14332
14332
|
}
|
|
14333
14333
|
if (!response.compiledClassHash)
|
|
14334
14334
|
throw new Error(
|
|
@@ -15133,6 +15133,14 @@ ${indent}}` : "}";
|
|
|
15133
15133
|
block_id
|
|
15134
15134
|
});
|
|
15135
15135
|
}
|
|
15136
|
+
/**
|
|
15137
|
+
* Helper method to get the starknet version from the block, default latest block
|
|
15138
|
+
* @returns Starknet version
|
|
15139
|
+
*/
|
|
15140
|
+
async getStarknetVersion(blockIdentifier = this.blockIdentifier) {
|
|
15141
|
+
const block = await this.getBlockWithTxHashes(blockIdentifier);
|
|
15142
|
+
return block.starknet_version;
|
|
15143
|
+
}
|
|
15136
15144
|
/**
|
|
15137
15145
|
* Get the most recent accepted block hash and number
|
|
15138
15146
|
*/
|
|
@@ -15722,6 +15730,14 @@ ${indent}}` : "}";
|
|
|
15722
15730
|
block_id
|
|
15723
15731
|
});
|
|
15724
15732
|
}
|
|
15733
|
+
/**
|
|
15734
|
+
* Helper method to get the starknet version from the block, default latest block
|
|
15735
|
+
* @returns Starknet version
|
|
15736
|
+
*/
|
|
15737
|
+
async getStarknetVersion(blockIdentifier = this.blockIdentifier) {
|
|
15738
|
+
const block = await this.getBlockWithTxHashes(blockIdentifier);
|
|
15739
|
+
return block.starknet_version;
|
|
15740
|
+
}
|
|
15725
15741
|
/**
|
|
15726
15742
|
* Get the most recent accepted block hash and number
|
|
15727
15743
|
*/
|
|
@@ -17661,6 +17677,9 @@ ${indent}}` : "}";
|
|
|
17661
17677
|
setUpSpecVersion() {
|
|
17662
17678
|
return this.channel.setUpSpecVersion();
|
|
17663
17679
|
}
|
|
17680
|
+
async getStarknetVersion(blockIdentifier) {
|
|
17681
|
+
return this.channel.getStarknetVersion(blockIdentifier);
|
|
17682
|
+
}
|
|
17664
17683
|
async getNonceForAddress(contractAddress, blockIdentifier) {
|
|
17665
17684
|
return this.channel.getNonceForAddress(contractAddress, blockIdentifier);
|
|
17666
17685
|
}
|
|
@@ -17900,7 +17919,7 @@ ${indent}}` : "}";
|
|
|
17900
17919
|
if (!contractClassIdentifier.classHash && "contract" in contractClassIdentifier) {
|
|
17901
17920
|
const hashes = extractContractHashes(
|
|
17902
17921
|
contractClassIdentifier,
|
|
17903
|
-
await this.channel.
|
|
17922
|
+
await this.channel.getStarknetVersion()
|
|
17904
17923
|
);
|
|
17905
17924
|
classHash = hashes.classHash;
|
|
17906
17925
|
} else if (contractClassIdentifier.classHash) {
|
|
@@ -20491,7 +20510,7 @@ ${indent}}` : "}";
|
|
|
20491
20510
|
const invocations = [
|
|
20492
20511
|
{
|
|
20493
20512
|
type: ETransactionType2.DECLARE,
|
|
20494
|
-
payload: extractContractHashes(payload, await this.channel.
|
|
20513
|
+
payload: extractContractHashes(payload, await this.channel.getStarknetVersion())
|
|
20495
20514
|
}
|
|
20496
20515
|
];
|
|
20497
20516
|
const estimateBulk = await this.estimateFeeBulk(invocations, details);
|
|
@@ -20657,7 +20676,7 @@ ${indent}}` : "}";
|
|
|
20657
20676
|
async declareIfNot(payload, transactionsDetail = {}) {
|
|
20658
20677
|
const declareContractPayload = extractContractHashes(
|
|
20659
20678
|
payload,
|
|
20660
|
-
await this.channel.
|
|
20679
|
+
await this.channel.getStarknetVersion()
|
|
20661
20680
|
);
|
|
20662
20681
|
try {
|
|
20663
20682
|
await this.getClassByHash(declareContractPayload.classHash);
|
|
@@ -20673,7 +20692,7 @@ ${indent}}` : "}";
|
|
|
20673
20692
|
assert(isSierra(payload.contract), SYSTEM_MESSAGES.declareNonSierra);
|
|
20674
20693
|
const declareContractPayload = extractContractHashes(
|
|
20675
20694
|
payload,
|
|
20676
|
-
await this.channel.
|
|
20695
|
+
await this.channel.getStarknetVersion()
|
|
20677
20696
|
);
|
|
20678
20697
|
const detailsWithTip = await this.resolveDetailsWithTip(details);
|
|
20679
20698
|
const { resourceBounds: providedResourceBounds } = details;
|
|
@@ -20983,7 +21002,7 @@ ${indent}}` : "}";
|
|
|
20983
21002
|
async buildDeclarePayload(payload, details) {
|
|
20984
21003
|
const { classHash, contract, compiledClassHash } = extractContractHashes(
|
|
20985
21004
|
payload,
|
|
20986
|
-
await this.channel.
|
|
21005
|
+
await this.channel.getStarknetVersion()
|
|
20987
21006
|
);
|
|
20988
21007
|
const compressedCompiledContract = parseContract(contract);
|
|
20989
21008
|
assert(
|
|
@@ -21333,7 +21352,7 @@ ${indent}}` : "}";
|
|
|
21333
21352
|
async declare(payload) {
|
|
21334
21353
|
const declareContractPayload = extractContractHashes(
|
|
21335
21354
|
payload,
|
|
21336
|
-
await this.channel.
|
|
21355
|
+
await this.channel.getStarknetVersion()
|
|
21337
21356
|
);
|
|
21338
21357
|
const pContract = payload.contract;
|
|
21339
21358
|
const cairo1Contract = {
|
|
@@ -21675,7 +21694,7 @@ ${indent}}` : "}";
|
|
|
21675
21694
|
});
|
|
21676
21695
|
}
|
|
21677
21696
|
async invoke(method, args = [], options = {}) {
|
|
21678
|
-
const { parseRequest = true, signature, waitForTransaction, ...
|
|
21697
|
+
const { parseRequest = true, signature, waitForTransaction, ...restInvokeOptions } = options;
|
|
21679
21698
|
assert(this.address !== null, "contract is not connected to an address");
|
|
21680
21699
|
const calldata = getCompiledCalldata(args, () => {
|
|
21681
21700
|
if (parseRequest) {
|
|
@@ -21691,8 +21710,20 @@ ${indent}}` : "}";
|
|
|
21691
21710
|
entrypoint: method
|
|
21692
21711
|
};
|
|
21693
21712
|
if (isAccount(this.providerOrAccount)) {
|
|
21713
|
+
if (restInvokeOptions.paymasterDetails) {
|
|
21714
|
+
const myCall = {
|
|
21715
|
+
contractAddress: this.address,
|
|
21716
|
+
entrypoint: method,
|
|
21717
|
+
calldata: args
|
|
21718
|
+
};
|
|
21719
|
+
return this.providerOrAccount.executePaymasterTransaction(
|
|
21720
|
+
[myCall],
|
|
21721
|
+
restInvokeOptions.paymasterDetails,
|
|
21722
|
+
restInvokeOptions.maxFeeInGasToken
|
|
21723
|
+
);
|
|
21724
|
+
}
|
|
21694
21725
|
const result = await this.providerOrAccount.execute(invocation, {
|
|
21695
|
-
...
|
|
21726
|
+
...restInvokeOptions
|
|
21696
21727
|
});
|
|
21697
21728
|
if (waitForTransaction) {
|
|
21698
21729
|
const result2 = await this.providerOrAccount.waitForTransaction(result.transaction_hash);
|
|
@@ -21703,7 +21734,7 @@ ${indent}}` : "}";
|
|
|
21703
21734
|
}
|
|
21704
21735
|
return result;
|
|
21705
21736
|
}
|
|
21706
|
-
if (!
|
|
21737
|
+
if (!restInvokeOptions.nonce)
|
|
21707
21738
|
throw new Error(`Manual nonce is required when invoking a function without an account`);
|
|
21708
21739
|
logger.warn(`Invoking ${method} without an account.`);
|
|
21709
21740
|
return this.providerOrAccount.invokeFunction(
|
|
@@ -21712,8 +21743,8 @@ ${indent}}` : "}";
|
|
|
21712
21743
|
signature
|
|
21713
21744
|
},
|
|
21714
21745
|
{
|
|
21715
|
-
...
|
|
21716
|
-
nonce:
|
|
21746
|
+
...restInvokeOptions,
|
|
21747
|
+
nonce: restInvokeOptions.nonce
|
|
21717
21748
|
}
|
|
21718
21749
|
);
|
|
21719
21750
|
}
|
|
@@ -21724,6 +21755,17 @@ ${indent}}` : "}";
|
|
|
21724
21755
|
}
|
|
21725
21756
|
const invocation = this.populate(method, args);
|
|
21726
21757
|
if (isAccount(this.providerOrAccount)) {
|
|
21758
|
+
if (estimateDetails.paymasterDetails) {
|
|
21759
|
+
const myCall = {
|
|
21760
|
+
contractAddress: this.address,
|
|
21761
|
+
entrypoint: method,
|
|
21762
|
+
calldata: args
|
|
21763
|
+
};
|
|
21764
|
+
return this.providerOrAccount.estimatePaymasterTransactionFee(
|
|
21765
|
+
[myCall],
|
|
21766
|
+
estimateDetails.paymasterDetails
|
|
21767
|
+
);
|
|
21768
|
+
}
|
|
21727
21769
|
return this.providerOrAccount.estimateInvokeFee(invocation, estimateDetails);
|
|
21728
21770
|
}
|
|
21729
21771
|
throw Error("Contract must be connected to the account contract to estimate");
|