starknet 6.16.0 → 6.18.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 CHANGED
@@ -1,3 +1,15 @@
1
+ # [6.18.0](https://github.com/starknet-io/starknet.js/compare/v6.17.0...v6.18.0) (2024-11-18)
2
+
3
+ ### Features
4
+
5
+ - WalletAccount non-breaking temp solution ([#1259](https://github.com/starknet-io/starknet.js/issues/1259)) ([84b267c](https://github.com/starknet-io/starknet.js/commit/84b267cd20122de2954fe9fd87b50503b19c1baa))
6
+
7
+ # [6.17.0](https://github.com/starknet-io/starknet.js/compare/v6.16.0...v6.17.0) (2024-10-24)
8
+
9
+ ### Features
10
+
11
+ - Cairo u96 implementation ([#1247](https://github.com/starknet-io/starknet.js/issues/1247)) ([06f0a80](https://github.com/starknet-io/starknet.js/commit/06f0a8013405ded4685d0a21c4f245a25e7d4827))
12
+
1
13
  # [6.16.0](https://github.com/starknet-io/starknet.js/compare/v6.15.0...v6.16.0) (2024-10-24)
2
14
 
3
15
  ### Features
package/dist/index.d.ts CHANGED
@@ -2498,6 +2498,7 @@ declare const Literal: {
2498
2498
  readonly ClassHash: "core::starknet::class_hash::ClassHash";
2499
2499
  readonly ContractAddress: "core::starknet::contract_address::ContractAddress";
2500
2500
  readonly Secp256k1Point: "core::starknet::secp256k1::Secp256k1Point";
2501
+ readonly U96: "core::internal::bounded_int::BoundedInt::<0, 79228162514264337593543950335>";
2501
2502
  };
2502
2503
  type Literal = ValuesType<typeof Literal>;
2503
2504
  declare const ETH_ADDRESS = "core::starknet::eth_address::EthAddress";
@@ -4200,7 +4201,11 @@ interface StarknetWalletProvider extends StarknetWindowObject {
4200
4201
  declare class WalletAccount extends Account implements AccountInterface {
4201
4202
  address: string;
4202
4203
  walletProvider: StarknetWalletProvider;
4204
+ /**
4205
+ * @deprecated Use static method WalletAccount.connect or WalletAccount.connectSilent instead. Constructor {@link WalletAccount.(format:2)}.
4206
+ */
4203
4207
  constructor(providerOrOptions: ProviderOptions | ProviderInterface, walletProvider: StarknetWalletProvider, cairoVersion?: CairoVersion);
4208
+ constructor(providerOrOptions: ProviderOptions | ProviderInterface, walletProvider: StarknetWalletProvider, cairoVersion?: CairoVersion, address?: string);
4204
4209
  /**
4205
4210
  * WALLET EVENTS
4206
4211
  */
@@ -4221,6 +4226,8 @@ declare class WalletAccount extends Account implements AccountInterface {
4221
4226
  declare(payload: DeclareContractPayload): Promise<RPCSPEC07.AddDeclareTransactionResult>;
4222
4227
  deploy(payload: UniversalDeployerContractPayload | UniversalDeployerContractPayload[]): Promise<MultiDeployContractResponse>;
4223
4228
  signMessage(typedData: TypedData): Promise<Signature$1>;
4229
+ static connect(provider: ProviderInterface, walletProvider: StarknetWalletProvider, cairoVersion?: CairoVersion, silentMode?: boolean): Promise<WalletAccount>;
4230
+ static connectSilent(provider: ProviderInterface, walletProvider: StarknetWalletProvider, cairoVersion?: CairoVersion): Promise<WalletAccount>;
4224
4231
  }
4225
4232
 
4226
4233
  declare module 'abi-wan-kanabi' {
@@ -7184,6 +7191,13 @@ declare const isTypeBytes31: (type: string) => type is "core::bytes_31::bytes31"
7184
7191
  * @returns - True if the given type is equal to 'core::byte_array::ByteArray', false otherwise.
7185
7192
  */
7186
7193
  declare const isTypeByteArray: (type: string) => type is "core::byte_array::ByteArray";
7194
+ /**
7195
+ * Checks if the given type is equal to the u96 type
7196
+ *
7197
+ * @param {string} type - The type to check.
7198
+ * @returns - True if the given type is equal to u96, false otherwise.
7199
+ */
7200
+ declare const isTypeU96: (type: string) => type is "core::internal::bounded_int::BoundedInt::<0, 79228162514264337593543950335>";
7187
7201
  declare const isTypeSecp256k1Point: (type: string) => type is "core::starknet::secp256k1::Secp256k1Point";
7188
7202
  declare const isCairo1Type: (type: string) => boolean;
7189
7203
  /**
@@ -7282,13 +7296,14 @@ declare const cairo_isTypeResult: typeof isTypeResult;
7282
7296
  declare const cairo_isTypeSecp256k1Point: typeof isTypeSecp256k1Point;
7283
7297
  declare const cairo_isTypeStruct: typeof isTypeStruct;
7284
7298
  declare const cairo_isTypeTuple: typeof isTypeTuple;
7299
+ declare const cairo_isTypeU96: typeof isTypeU96;
7285
7300
  declare const cairo_isTypeUint: typeof isTypeUint;
7286
7301
  declare const cairo_isTypeUint256: typeof isTypeUint256;
7287
7302
  declare const cairo_tuple: typeof tuple;
7288
7303
  declare const cairo_uint256: typeof uint256;
7289
7304
  declare const cairo_uint512: typeof uint512;
7290
7305
  declare namespace cairo {
7291
- export { cairo_felt as felt, cairo_getAbiContractVersion as getAbiContractVersion, cairo_getArrayType as getArrayType, cairo_isCairo1Abi as isCairo1Abi, cairo_isCairo1Type as isCairo1Type, cairo_isLen as isLen, cairo_isTypeArray as isTypeArray, cairo_isTypeBool as isTypeBool, cairo_isTypeByteArray as isTypeByteArray, cairo_isTypeBytes31 as isTypeBytes31, cairo_isTypeContractAddress as isTypeContractAddress, cairo_isTypeEnum as isTypeEnum, cairo_isTypeEthAddress as isTypeEthAddress, cairo_isTypeFelt as isTypeFelt, cairo_isTypeLiteral as isTypeLiteral, cairo_isTypeNamedTuple as isTypeNamedTuple, cairo_isTypeNonZero as isTypeNonZero, cairo_isTypeOption as isTypeOption, cairo_isTypeResult as isTypeResult, cairo_isTypeSecp256k1Point as isTypeSecp256k1Point, cairo_isTypeStruct as isTypeStruct, cairo_isTypeTuple as isTypeTuple, cairo_isTypeUint as isTypeUint, cairo_isTypeUint256 as isTypeUint256, cairo_tuple as tuple, cairo_uint256 as uint256, cairo_uint512 as uint512 };
7306
+ export { cairo_felt as felt, cairo_getAbiContractVersion as getAbiContractVersion, cairo_getArrayType as getArrayType, cairo_isCairo1Abi as isCairo1Abi, cairo_isCairo1Type as isCairo1Type, cairo_isLen as isLen, cairo_isTypeArray as isTypeArray, cairo_isTypeBool as isTypeBool, cairo_isTypeByteArray as isTypeByteArray, cairo_isTypeBytes31 as isTypeBytes31, cairo_isTypeContractAddress as isTypeContractAddress, cairo_isTypeEnum as isTypeEnum, cairo_isTypeEthAddress as isTypeEthAddress, cairo_isTypeFelt as isTypeFelt, cairo_isTypeLiteral as isTypeLiteral, cairo_isTypeNamedTuple as isTypeNamedTuple, cairo_isTypeNonZero as isTypeNonZero, cairo_isTypeOption as isTypeOption, cairo_isTypeResult as isTypeResult, cairo_isTypeSecp256k1Point as isTypeSecp256k1Point, cairo_isTypeStruct as isTypeStruct, cairo_isTypeTuple as isTypeTuple, cairo_isTypeU96 as isTypeU96, cairo_isTypeUint as isTypeUint, cairo_isTypeUint256 as isTypeUint256, cairo_tuple as tuple, cairo_uint256 as uint256, cairo_uint512 as uint512 };
7292
7307
  }
7293
7308
 
7294
7309
  /**
@@ -13982,7 +13982,8 @@ var starknet = (() => {
13982
13982
  var Literal = {
13983
13983
  ClassHash: "core::starknet::class_hash::ClassHash",
13984
13984
  ContractAddress: "core::starknet::contract_address::ContractAddress",
13985
- Secp256k1Point: "core::starknet::secp256k1::Secp256k1Point"
13985
+ Secp256k1Point: "core::starknet::secp256k1::Secp256k1Point",
13986
+ U96: "core::internal::bounded_int::BoundedInt::<0, 79228162514264337593543950335>"
13986
13987
  };
13987
13988
  var ETH_ADDRESS = "core::starknet::eth_address::EthAddress";
13988
13989
  var NON_ZERO_PREFIX = "core::zeroable::NonZero::";
@@ -16965,6 +16966,7 @@ var starknet = (() => {
16965
16966
  isTypeSecp256k1Point: () => isTypeSecp256k1Point,
16966
16967
  isTypeStruct: () => isTypeStruct,
16967
16968
  isTypeTuple: () => isTypeTuple,
16969
+ isTypeU96: () => isTypeU96,
16968
16970
  isTypeUint: () => isTypeUint,
16969
16971
  isTypeUint256: () => isTypeUint256,
16970
16972
  tuple: () => tuple,
@@ -17242,6 +17244,7 @@ var starknet = (() => {
17242
17244
  var isTypeEthAddress = (type) => type === ETH_ADDRESS;
17243
17245
  var isTypeBytes31 = (type) => type === "core::bytes_31::bytes31";
17244
17246
  var isTypeByteArray = (type) => type === "core::byte_array::ByteArray";
17247
+ var isTypeU96 = (type) => type === "core::internal::bounded_int::BoundedInt::<0, 79228162514264337593543950335>";
17245
17248
  var isTypeSecp256k1Point = (type) => type === Literal.Secp256k1Point;
17246
17249
  var isCairo1Type = (type) => type.includes("::");
17247
17250
  var getArrayType = (type) => {
@@ -17706,6 +17709,9 @@ var starknet = (() => {
17706
17709
  if (isTypeByteArray(abiType)) {
17707
17710
  return unorderedItem;
17708
17711
  }
17712
+ if (isTypeU96(abiType)) {
17713
+ return unorderedItem;
17714
+ }
17709
17715
  if (isTypeSecp256k1Point(abiType)) {
17710
17716
  return unorderedItem;
17711
17717
  }
@@ -18337,6 +18343,13 @@ var starknet = (() => {
18337
18343
  );
18338
18344
  break;
18339
18345
  }
18346
+ case Literal.U96: {
18347
+ assert(
18348
+ param >= 0n && param <= 2n ** 96n - 1n,
18349
+ `Validate: arg ${input.name} must be ${input.type} : a 96 bits number.`
18350
+ );
18351
+ break;
18352
+ }
18340
18353
  default:
18341
18354
  break;
18342
18355
  }
@@ -28293,11 +28306,11 @@ var starknet = (() => {
28293
28306
  }
28294
28307
 
28295
28308
  // src/wallet/account.ts
28296
- var WalletAccount = class extends Account {
28309
+ var WalletAccount = class _WalletAccount extends Account {
28297
28310
  address = "";
28298
28311
  walletProvider;
28299
- constructor(providerOrOptions, walletProvider, cairoVersion) {
28300
- super(providerOrOptions, "", "", cairoVersion);
28312
+ constructor(providerOrOptions, walletProvider, cairoVersion, address = "") {
28313
+ super(providerOrOptions, address, "", cairoVersion);
28301
28314
  this.walletProvider = walletProvider;
28302
28315
  this.walletProvider.on("accountsChanged", (res) => {
28303
28316
  if (!res) return;
@@ -28307,14 +28320,14 @@ var starknet = (() => {
28307
28320
  if (!res) return;
28308
28321
  this.channel.setChainId(res);
28309
28322
  });
28310
- walletProvider.request({
28311
- type: "wallet_requestAccounts",
28312
- params: {
28313
- silent_mode: false
28314
- }
28315
- }).then((res) => {
28316
- this.address = res[0].toLowerCase();
28317
- });
28323
+ if (!address.length) {
28324
+ console.warn(
28325
+ "@deprecated Use static method WalletAccount.connect or WalletAccount.connectSilent instead. Constructor {@link WalletAccount.(format:2)}."
28326
+ );
28327
+ requestAccounts(this.walletProvider).then(([accountAddress]) => {
28328
+ this.address = accountAddress.toLowerCase();
28329
+ });
28330
+ }
28318
28331
  }
28319
28332
  /**
28320
28333
  * WALLET EVENTS
@@ -28387,6 +28400,13 @@ var starknet = (() => {
28387
28400
  signMessage(typedData) {
28388
28401
  return signMessage(this.walletProvider, typedData);
28389
28402
  }
28403
+ static async connect(provider, walletProvider, cairoVersion, silentMode = false) {
28404
+ const [accountAddress] = await requestAccounts(walletProvider, silentMode);
28405
+ return new _WalletAccount(provider, walletProvider, cairoVersion, accountAddress);
28406
+ }
28407
+ static async connectSilent(provider, walletProvider, cairoVersion) {
28408
+ return _WalletAccount.connect(provider, walletProvider, cairoVersion, true);
28409
+ }
28390
28410
  // TODO: MISSING ESTIMATES
28391
28411
  };
28392
28412