starknet 6.0.0-beta.1 → 6.0.0-beta.3
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 +12 -0
- package/dist/index.d.ts +7 -5
- package/dist/index.global.js +94 -37
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +94 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -37
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# [6.0.0-beta.3](https://github.com/starknet-io/starknet.js/compare/v6.0.0-beta.2...v6.0.0-beta.3) (2023-12-07)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- **beta:** deploy account ([#880](https://github.com/starknet-io/starknet.js/issues/880)) ([00c58e3](https://github.com/starknet-io/starknet.js/commit/00c58e3c6d03b716b68c1b96b5a4adc1cff87dd0))
|
|
6
|
+
|
|
7
|
+
# [6.0.0-beta.2](https://github.com/starknet-io/starknet.js/compare/v6.0.0-beta.1...v6.0.0-beta.2) (2023-12-07)
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
- v3 wip with est ([b95c462](https://github.com/starknet-io/starknet.js/commit/b95c462df0bd59293b7b42b5474311a3bbbfab1d))
|
|
12
|
+
|
|
1
13
|
# [6.0.0-beta.1](https://github.com/starknet-io/starknet.js/compare/v5.24.4...v6.0.0-beta.1) (2023-12-06)
|
|
2
14
|
|
|
3
15
|
### Features
|
package/dist/index.d.ts
CHANGED
|
@@ -2979,6 +2979,8 @@ interface EstimateFeeDetails {
|
|
|
2979
2979
|
nonceDataAvailabilityMode?: EDataAvailabilityMode;
|
|
2980
2980
|
feeDataAvailabilityMode?: EDataAvailabilityMode;
|
|
2981
2981
|
version?: BigNumberish;
|
|
2982
|
+
resourceBounds?: ResourceBounds;
|
|
2983
|
+
skipValidate?: boolean;
|
|
2982
2984
|
}
|
|
2983
2985
|
interface DeployContractResponse {
|
|
2984
2986
|
contract_address: string;
|
|
@@ -4085,7 +4087,7 @@ declare abstract class AccountInterface extends ProviderInterface {
|
|
|
4085
4087
|
* @param details -
|
|
4086
4088
|
* - [nonce=getNonce]
|
|
4087
4089
|
* - [version=transactionVersion]
|
|
4088
|
-
* - [maxFee=
|
|
4090
|
+
* - [maxFee=getSuggestedFee]
|
|
4089
4091
|
* @returns
|
|
4090
4092
|
* - contract_address[]
|
|
4091
4093
|
* - transaction_hash
|
|
@@ -4103,7 +4105,7 @@ declare abstract class AccountInterface extends ProviderInterface {
|
|
|
4103
4105
|
* @param details -
|
|
4104
4106
|
* - [nonce=getNonce]
|
|
4105
4107
|
* - [version=transactionVersion]
|
|
4106
|
-
* - [maxFee=
|
|
4108
|
+
* - [maxFee=getSuggestedFee]
|
|
4107
4109
|
* @returns
|
|
4108
4110
|
* - contract_address
|
|
4109
4111
|
* - transaction_hash
|
|
@@ -4132,7 +4134,7 @@ declare abstract class AccountInterface extends ProviderInterface {
|
|
|
4132
4134
|
* @param details
|
|
4133
4135
|
* - [nonce=getNonce]
|
|
4134
4136
|
* - [version=transactionVersion]
|
|
4135
|
-
* - [maxFee=
|
|
4137
|
+
* - [maxFee=getSuggestedFee]
|
|
4136
4138
|
* @returns
|
|
4137
4139
|
* - declare
|
|
4138
4140
|
* - transaction_hash
|
|
@@ -4214,7 +4216,7 @@ declare abstract class AccountInterface extends ProviderInterface {
|
|
|
4214
4216
|
* @param {EstimateFeeDetails} details
|
|
4215
4217
|
* @returns suggestedMaxFee
|
|
4216
4218
|
*/
|
|
4217
|
-
abstract
|
|
4219
|
+
abstract getSuggestedFee(estimateFeeAction: EstimateFeeAction, details: EstimateFeeDetails): Promise<EstimateFee>;
|
|
4218
4220
|
/**
|
|
4219
4221
|
* Simulates an array of transaction and returns an array of transaction trace and estimated fee.
|
|
4220
4222
|
*
|
|
@@ -4266,7 +4268,7 @@ declare class Account extends RpcProvider implements AccountInterface {
|
|
|
4266
4268
|
hashMessage(typedData: TypedData): Promise<string>;
|
|
4267
4269
|
verifyMessageHash(hash: BigNumberish, signature: Signature): Promise<boolean>;
|
|
4268
4270
|
verifyMessage(typedData: TypedData, signature: Signature): Promise<boolean>;
|
|
4269
|
-
|
|
4271
|
+
getSuggestedFee({ type, payload }: EstimateFeeAction, details: EstimateFeeDetails): Promise<EstimateFee>;
|
|
4270
4272
|
/**
|
|
4271
4273
|
* will be renamed to buildDeclareContractTransaction
|
|
4272
4274
|
*/
|
package/dist/index.global.js
CHANGED
|
@@ -11222,7 +11222,7 @@ var starknet = (() => {
|
|
|
11222
11222
|
contract_address
|
|
11223
11223
|
});
|
|
11224
11224
|
}
|
|
11225
|
-
async getEstimateFee(invocations, { blockIdentifier = this.blockIdentifier, skipValidate =
|
|
11225
|
+
async getEstimateFee(invocations, { blockIdentifier = this.blockIdentifier, skipValidate = true }) {
|
|
11226
11226
|
const block_id = new Block(blockIdentifier).identifier;
|
|
11227
11227
|
let flags = {};
|
|
11228
11228
|
if (isVersion("0.6", await this.getSpecVersion())) {
|
|
@@ -11429,9 +11429,12 @@ var starknet = (() => {
|
|
|
11429
11429
|
resource_bounds: invocation.resourceBounds,
|
|
11430
11430
|
tip: toHex(invocation.tip),
|
|
11431
11431
|
paymaster_data: invocation.paymasterData.map((it) => toHex(it)),
|
|
11432
|
-
account_deployment_data: invocation.accountDeploymentData.map((it) => toHex(it)),
|
|
11433
11432
|
nonce_data_availability_mode: invocation.nonceDataAvailabilityMode,
|
|
11434
|
-
fee_data_availability_mode: invocation.feeDataAvailabilityMode
|
|
11433
|
+
fee_data_availability_mode: invocation.feeDataAvailabilityMode,
|
|
11434
|
+
// dont add account_deployment_data if invocation.type === TransactionType.DEPLOY_ACCOUNT
|
|
11435
|
+
...invocation.type === "DEPLOY_ACCOUNT" /* DEPLOY_ACCOUNT */ ? {} : {
|
|
11436
|
+
account_deployment_data: invocation.accountDeploymentData.map((it) => toHex(it))
|
|
11437
|
+
}
|
|
11435
11438
|
};
|
|
11436
11439
|
}
|
|
11437
11440
|
if (invocation.type === "INVOKE_FUNCTION" /* INVOKE */) {
|
|
@@ -12567,7 +12570,8 @@ var starknet = (() => {
|
|
|
12567
12570
|
const estimateFeeResponse = await super.getInvokeEstimateFee(
|
|
12568
12571
|
{ ...invocation },
|
|
12569
12572
|
{ ...v3Details(details), version, nonce },
|
|
12570
|
-
blockIdentifier
|
|
12573
|
+
blockIdentifier,
|
|
12574
|
+
details.skipValidate
|
|
12571
12575
|
);
|
|
12572
12576
|
return {
|
|
12573
12577
|
...estimateFeeResponse,
|
|
@@ -12599,7 +12603,8 @@ var starknet = (() => {
|
|
|
12599
12603
|
const estimateFeeResponse = await super.getDeclareEstimateFee(
|
|
12600
12604
|
declareContractTransaction,
|
|
12601
12605
|
{ ...v3Details(details), version, nonce },
|
|
12602
|
-
blockIdentifier
|
|
12606
|
+
blockIdentifier,
|
|
12607
|
+
details.skipValidate
|
|
12603
12608
|
);
|
|
12604
12609
|
return {
|
|
12605
12610
|
...estimateFeeResponse,
|
|
@@ -12637,7 +12642,8 @@ var starknet = (() => {
|
|
|
12637
12642
|
const estimateFeeResponse = await super.getDeployAccountEstimateFee(
|
|
12638
12643
|
{ ...payload },
|
|
12639
12644
|
{ ...v3Details(details), version, nonce },
|
|
12640
|
-
blockIdentifier
|
|
12645
|
+
blockIdentifier,
|
|
12646
|
+
details.skipValidate
|
|
12641
12647
|
);
|
|
12642
12648
|
return {
|
|
12643
12649
|
...estimateFeeResponse,
|
|
@@ -12663,7 +12669,8 @@ var starknet = (() => {
|
|
|
12663
12669
|
blockIdentifier
|
|
12664
12670
|
});
|
|
12665
12671
|
const EstimateFeeResponseBulk2 = await super.getEstimateFeeBulk(accountInvocations, {
|
|
12666
|
-
blockIdentifier
|
|
12672
|
+
blockIdentifier,
|
|
12673
|
+
skipValidate: details.skipValidate
|
|
12667
12674
|
});
|
|
12668
12675
|
return [].concat(EstimateFeeResponseBulk2).map((elem) => {
|
|
12669
12676
|
return {
|
|
@@ -12691,19 +12698,32 @@ var starknet = (() => {
|
|
|
12691
12698
|
// TODO: does this depend on cairo version ?
|
|
12692
12699
|
details.version
|
|
12693
12700
|
);
|
|
12694
|
-
|
|
12695
|
-
|
|
12696
|
-
|
|
12697
|
-
|
|
12698
|
-
|
|
12699
|
-
|
|
12700
|
-
|
|
12701
|
+
let suggestedMaxFee = 0;
|
|
12702
|
+
let resourceBounds = estimateFeeToBounds(ZERO);
|
|
12703
|
+
if (version === "0x3" /* V3 */) {
|
|
12704
|
+
resourceBounds = details.resourceBounds ?? (await this.getSuggestedFee(
|
|
12705
|
+
{ type: "INVOKE_FUNCTION" /* INVOKE */, payload: calls },
|
|
12706
|
+
{
|
|
12707
|
+
...details,
|
|
12708
|
+
version
|
|
12709
|
+
}
|
|
12710
|
+
)).resourceBounds;
|
|
12711
|
+
} else {
|
|
12712
|
+
suggestedMaxFee = details.maxFee ?? (await this.getSuggestedFee(
|
|
12713
|
+
{ type: "INVOKE_FUNCTION" /* INVOKE */, payload: calls },
|
|
12714
|
+
{
|
|
12715
|
+
...details,
|
|
12716
|
+
version
|
|
12717
|
+
}
|
|
12718
|
+
)).suggestedMaxFee;
|
|
12719
|
+
}
|
|
12701
12720
|
const chainId = await this.getChainId();
|
|
12702
12721
|
const signerDetails = {
|
|
12703
12722
|
...v3Details(details),
|
|
12723
|
+
resourceBounds,
|
|
12704
12724
|
walletAddress: this.address,
|
|
12705
12725
|
nonce,
|
|
12706
|
-
maxFee,
|
|
12726
|
+
maxFee: suggestedMaxFee,
|
|
12707
12727
|
version,
|
|
12708
12728
|
chainId,
|
|
12709
12729
|
cairoVersion: await this.getCairoVersion()
|
|
@@ -12714,8 +12734,9 @@ var starknet = (() => {
|
|
|
12714
12734
|
{ contractAddress: this.address, calldata, signature },
|
|
12715
12735
|
{
|
|
12716
12736
|
...v3Details(details),
|
|
12737
|
+
resourceBounds,
|
|
12717
12738
|
nonce,
|
|
12718
|
-
maxFee,
|
|
12739
|
+
maxFee: suggestedMaxFee,
|
|
12719
12740
|
version
|
|
12720
12741
|
}
|
|
12721
12742
|
);
|
|
@@ -12745,10 +12766,10 @@ var starknet = (() => {
|
|
|
12745
12766
|
!isSierra(payload.contract) ? "0x1" /* V1 */ : this.getPreferredVersion("0x2" /* V2 */, "0x3" /* V3 */),
|
|
12746
12767
|
providedVersion
|
|
12747
12768
|
);
|
|
12748
|
-
|
|
12749
|
-
|
|
12750
|
-
|
|
12751
|
-
|
|
12769
|
+
let suggestedMaxFee = 0;
|
|
12770
|
+
let resourceBounds = estimateFeeToBounds(ZERO);
|
|
12771
|
+
if (version === "0x3" /* V3 */) {
|
|
12772
|
+
resourceBounds = details.resourceBounds ?? (await this.getSuggestedFee(
|
|
12752
12773
|
{
|
|
12753
12774
|
type: "DECLARE" /* DECLARE */,
|
|
12754
12775
|
payload: declareContractPayload
|
|
@@ -12757,7 +12778,24 @@ var starknet = (() => {
|
|
|
12757
12778
|
...details,
|
|
12758
12779
|
version
|
|
12759
12780
|
}
|
|
12760
|
-
)
|
|
12781
|
+
)).resourceBounds;
|
|
12782
|
+
} else {
|
|
12783
|
+
suggestedMaxFee = maxFee ?? (await this.getSuggestedFee(
|
|
12784
|
+
{
|
|
12785
|
+
type: "DECLARE" /* DECLARE */,
|
|
12786
|
+
payload: declareContractPayload
|
|
12787
|
+
},
|
|
12788
|
+
{
|
|
12789
|
+
...details,
|
|
12790
|
+
version
|
|
12791
|
+
}
|
|
12792
|
+
)).suggestedMaxFee;
|
|
12793
|
+
}
|
|
12794
|
+
const declareDetails = {
|
|
12795
|
+
...v3Details(details),
|
|
12796
|
+
resourceBounds,
|
|
12797
|
+
maxFee: suggestedMaxFee,
|
|
12798
|
+
nonce: toBigInt(nonce ?? await this.getNonce()),
|
|
12761
12799
|
version,
|
|
12762
12800
|
chainId: await this.getChainId(),
|
|
12763
12801
|
walletAddress: this.address,
|
|
@@ -12839,18 +12877,35 @@ var starknet = (() => {
|
|
|
12839
12877
|
const chainId = await this.getChainId();
|
|
12840
12878
|
const compiledCalldata = CallData.compile(constructorCalldata);
|
|
12841
12879
|
const contractAddress = providedContractAddress ?? calculateContractAddressFromHash(addressSalt, classHash, compiledCalldata, 0);
|
|
12842
|
-
|
|
12843
|
-
|
|
12844
|
-
|
|
12845
|
-
|
|
12846
|
-
|
|
12847
|
-
|
|
12848
|
-
|
|
12849
|
-
|
|
12850
|
-
|
|
12851
|
-
|
|
12852
|
-
|
|
12853
|
-
|
|
12880
|
+
let suggestedMaxFee = 0;
|
|
12881
|
+
let resourceBounds = estimateFeeToBounds(ZERO);
|
|
12882
|
+
if (version === "0x3" /* V3 */) {
|
|
12883
|
+
resourceBounds = details.resourceBounds ?? (await this.getSuggestedFee(
|
|
12884
|
+
{
|
|
12885
|
+
type: "DEPLOY_ACCOUNT" /* DEPLOY_ACCOUNT */,
|
|
12886
|
+
payload: {
|
|
12887
|
+
classHash,
|
|
12888
|
+
constructorCalldata: compiledCalldata,
|
|
12889
|
+
addressSalt,
|
|
12890
|
+
contractAddress
|
|
12891
|
+
}
|
|
12892
|
+
},
|
|
12893
|
+
details
|
|
12894
|
+
)).resourceBounds;
|
|
12895
|
+
} else {
|
|
12896
|
+
suggestedMaxFee = details.maxFee ?? (await this.getSuggestedFee(
|
|
12897
|
+
{
|
|
12898
|
+
type: "DEPLOY_ACCOUNT" /* DEPLOY_ACCOUNT */,
|
|
12899
|
+
payload: {
|
|
12900
|
+
classHash,
|
|
12901
|
+
constructorCalldata: compiledCalldata,
|
|
12902
|
+
addressSalt,
|
|
12903
|
+
contractAddress
|
|
12904
|
+
}
|
|
12905
|
+
},
|
|
12906
|
+
details
|
|
12907
|
+
)).suggestedMaxFee;
|
|
12908
|
+
}
|
|
12854
12909
|
const signature = await this.signer.signDeployAccountTransaction({
|
|
12855
12910
|
...v3Details(details),
|
|
12856
12911
|
classHash,
|
|
@@ -12858,7 +12913,8 @@ var starknet = (() => {
|
|
|
12858
12913
|
contractAddress,
|
|
12859
12914
|
addressSalt,
|
|
12860
12915
|
chainId,
|
|
12861
|
-
|
|
12916
|
+
resourceBounds,
|
|
12917
|
+
maxFee: suggestedMaxFee,
|
|
12862
12918
|
version,
|
|
12863
12919
|
nonce
|
|
12864
12920
|
});
|
|
@@ -12867,7 +12923,8 @@ var starknet = (() => {
|
|
|
12867
12923
|
{
|
|
12868
12924
|
...v3Details(details),
|
|
12869
12925
|
nonce,
|
|
12870
|
-
|
|
12926
|
+
resourceBounds,
|
|
12927
|
+
maxFee: suggestedMaxFee,
|
|
12871
12928
|
version
|
|
12872
12929
|
}
|
|
12873
12930
|
);
|
|
@@ -12897,7 +12954,7 @@ var starknet = (() => {
|
|
|
12897
12954
|
const hash2 = await this.hashMessage(typedData);
|
|
12898
12955
|
return this.verifyMessageHash(hash2, signature);
|
|
12899
12956
|
}
|
|
12900
|
-
async
|
|
12957
|
+
async getSuggestedFee({ type, payload }, details) {
|
|
12901
12958
|
let feeEstimate;
|
|
12902
12959
|
switch (type) {
|
|
12903
12960
|
case "INVOKE_FUNCTION" /* INVOKE */:
|
|
@@ -12920,7 +12977,7 @@ var starknet = (() => {
|
|
|
12920
12977
|
};
|
|
12921
12978
|
break;
|
|
12922
12979
|
}
|
|
12923
|
-
return feeEstimate
|
|
12980
|
+
return feeEstimate;
|
|
12924
12981
|
}
|
|
12925
12982
|
/**
|
|
12926
12983
|
* will be renamed to buildDeclareContractTransaction
|