starknet 8.4.0 → 8.5.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/dist/index.js CHANGED
@@ -40,7 +40,10 @@ __export(index_exports, {
40
40
  BlockStatus: () => BlockStatus,
41
41
  BlockTag: () => BlockTag,
42
42
  CairoByteArray: () => CairoByteArray,
43
+ CairoBytes31: () => CairoBytes31,
43
44
  CairoCustomEnum: () => CairoCustomEnum,
45
+ CairoFelt: () => CairoFelt,
46
+ CairoFelt252: () => CairoFelt252,
44
47
  CairoFixedArray: () => CairoFixedArray,
45
48
  CairoInt128: () => CairoInt128,
46
49
  CairoInt16: () => CairoInt16,
@@ -54,6 +57,7 @@ __export(index_exports, {
54
57
  CairoUint128: () => CairoUint128,
55
58
  CairoUint16: () => CairoUint16,
56
59
  CairoUint256: () => CairoUint256,
60
+ CairoUint32: () => CairoUint32,
57
61
  CairoUint512: () => CairoUint512,
58
62
  CairoUint64: () => CairoUint64,
59
63
  CairoUint8: () => CairoUint8,
@@ -9210,8 +9214,181 @@ var StarknetId = class _StarknetId {
9210
9214
  }
9211
9215
  };
9212
9216
 
9217
+ // src/provider/extensions/brotherId.ts
9218
+ function isBrotherDomain(domain) {
9219
+ return domain.endsWith(".brother");
9220
+ }
9221
+ function encodeBrotherDomain(domain) {
9222
+ const brotherName = domain.endsWith(".brother") ? domain.replace(".brother", "") : domain;
9223
+ return useEncoded(brotherName);
9224
+ }
9225
+ function decodeBrotherDomain(encoded) {
9226
+ const decoded = useDecoded([encoded]);
9227
+ if (decoded.endsWith(".stark")) {
9228
+ return decoded.replace(".stark", ".brother");
9229
+ }
9230
+ return decoded ? `${decoded}.brother` : decoded;
9231
+ }
9232
+ function getBrotherIdContract(chainId) {
9233
+ switch (chainId) {
9234
+ case _StarknetChainId.SN_MAIN:
9235
+ return "0x0212f1c57700f5a3913dd11efba540196aad4cf67772f7090c62709dd804fa74";
9236
+ default:
9237
+ return "0x0212f1c57700f5a3913dd11efba540196aad4cf67772f7090c62709dd804fa74";
9238
+ }
9239
+ }
9240
+ var BrotherId = class _BrotherId {
9241
+ /**
9242
+ * Gets the primary Brother domain name for an address
9243
+ * @param address - The address to get the domain for
9244
+ * @param BrotherIdContract - Optional contract address
9245
+ * @returns The domain name with .brother suffix
9246
+ */
9247
+ async getBrotherName(address, BrotherIdContract) {
9248
+ return _BrotherId.getBrotherName(
9249
+ // After Mixin, this is ProviderInterface
9250
+ this,
9251
+ address,
9252
+ BrotherIdContract
9253
+ );
9254
+ }
9255
+ /**
9256
+ * Gets the address associated with a Brother domain name
9257
+ * @param name - The domain name (with or without .brother suffix)
9258
+ * @param BrotherIdContract - Optional contract address
9259
+ * @returns The resolver address for the domain
9260
+ */
9261
+ async getAddressFromBrotherName(name, BrotherIdContract) {
9262
+ return _BrotherId.getAddressFromBrotherName(
9263
+ // After Mixin, this is ProviderInterface
9264
+ this,
9265
+ name,
9266
+ BrotherIdContract
9267
+ );
9268
+ }
9269
+ /**
9270
+ * Gets the complete profile information for a Brother domain
9271
+ * @param address - The address to get the profile for
9272
+ * @param BrotherIdContract - Optional contract address
9273
+ * @returns The complete Brother profile information
9274
+ */
9275
+ async getBrotherProfile(address, BrotherIdContract) {
9276
+ return _BrotherId.getBrotherProfile(
9277
+ // After Mixin, this is ProviderInterface
9278
+ this,
9279
+ address,
9280
+ BrotherIdContract
9281
+ );
9282
+ }
9283
+ /**
9284
+ * Static implementation of getBrotherName
9285
+ * @param provider - The provider interface
9286
+ * @param address - The address to get the domain for
9287
+ * @param BrotherIdContract - Optional contract address
9288
+ * @returns The domain name with .brother suffix
9289
+ */
9290
+ static async getBrotherName(provider, address, BrotherIdContract) {
9291
+ const chainId = await provider.getChainId();
9292
+ const contract = BrotherIdContract ?? getBrotherIdContract(chainId);
9293
+ try {
9294
+ const primaryDomain = await provider.callContract({
9295
+ contractAddress: contract,
9296
+ entrypoint: "getPrimary",
9297
+ calldata: CallData.compile({
9298
+ user: address
9299
+ })
9300
+ });
9301
+ if (!primaryDomain[0] || primaryDomain[0] === "0x0") {
9302
+ throw Error("Brother name not found");
9303
+ }
9304
+ const encodedDomain = BigInt(primaryDomain[0]);
9305
+ return decodeBrotherDomain(encodedDomain);
9306
+ } catch (e) {
9307
+ if (e instanceof Error && e.message === "Brother name not found") {
9308
+ throw e;
9309
+ }
9310
+ throw Error("Could not get brother name");
9311
+ }
9312
+ }
9313
+ /**
9314
+ * Static implementation of getAddressFromBrotherName
9315
+ * @param provider - The provider interface
9316
+ * @param name - The domain name
9317
+ * @param BrotherIdContract - Optional contract address
9318
+ * @returns The resolver address
9319
+ */
9320
+ static async getAddressFromBrotherName(provider, name, BrotherIdContract) {
9321
+ const brotherName = name.endsWith(".brother") ? name : `${name}.brother`;
9322
+ if (!isBrotherDomain(brotherName)) {
9323
+ throw new Error("Invalid domain, must be a valid .brother domain");
9324
+ }
9325
+ const chainId = await provider.getChainId();
9326
+ const contract = BrotherIdContract ?? getBrotherIdContract(chainId);
9327
+ try {
9328
+ const domainDetails = await provider.callContract({
9329
+ contractAddress: contract,
9330
+ entrypoint: "get_details_by_domain",
9331
+ calldata: CallData.compile({
9332
+ domain: encodeBrotherDomain(brotherName)
9333
+ })
9334
+ });
9335
+ if (!domainDetails[0] || domainDetails[1] === "0x0") {
9336
+ throw Error("Could not get address from brother name");
9337
+ }
9338
+ return domainDetails[1];
9339
+ } catch {
9340
+ throw Error("Could not get address from brother name");
9341
+ }
9342
+ }
9343
+ /**
9344
+ * Static implementation of getBrotherProfile
9345
+ * @param provider - The provider interface
9346
+ * @param address - The address to get the profile for
9347
+ * @param BrotherIdContract - Optional contract address
9348
+ * @returns The complete Brother profile
9349
+ */
9350
+ static async getBrotherProfile(provider, address, BrotherIdContract) {
9351
+ const chainId = await provider.getChainId();
9352
+ const contract = BrotherIdContract ?? getBrotherIdContract(chainId);
9353
+ try {
9354
+ const primaryDomain = await provider.callContract({
9355
+ contractAddress: contract,
9356
+ entrypoint: "getPrimary",
9357
+ calldata: CallData.compile({
9358
+ user: address
9359
+ })
9360
+ });
9361
+ if (!primaryDomain[0] || primaryDomain[0] === "0x0") {
9362
+ throw Error("Brother profile not found");
9363
+ }
9364
+ const encodedDomain = BigInt(primaryDomain[0]);
9365
+ const decodedDomain = decodeBrotherDomain(encodedDomain);
9366
+ const domain = decodedDomain.replace(".brother", "");
9367
+ const domainDetails = await provider.callContract({
9368
+ contractAddress: contract,
9369
+ entrypoint: "get_details_by_domain",
9370
+ calldata: CallData.compile({
9371
+ domain: encodeBrotherDomain(domain)
9372
+ })
9373
+ });
9374
+ return {
9375
+ name: domain,
9376
+ resolver: domainDetails[1],
9377
+ tokenId: domainDetails[2],
9378
+ expiryDate: parseInt(domainDetails[3], 16),
9379
+ lastTransferTime: parseInt(domainDetails[4], 16)
9380
+ };
9381
+ } catch (e) {
9382
+ if (e instanceof Error && e.message === "Brother profile not found") {
9383
+ throw e;
9384
+ }
9385
+ throw Error("Could not get brother profile");
9386
+ }
9387
+ }
9388
+ };
9389
+
9213
9390
  // src/provider/extensions/default.ts
9214
- var RpcProvider2 = class extends (0, import_ts_mixer.Mixin)(RpcProvider, StarknetId) {
9391
+ var RpcProvider2 = class extends (0, import_ts_mixer.Mixin)(RpcProvider, StarknetId, BrotherId) {
9215
9392
  };
9216
9393
 
9217
9394
  // src/provider/interface.ts
@@ -12379,7 +12556,10 @@ function units(amount, simbol = "fri") {
12379
12556
  BlockStatus,
12380
12557
  BlockTag,
12381
12558
  CairoByteArray,
12559
+ CairoBytes31,
12382
12560
  CairoCustomEnum,
12561
+ CairoFelt,
12562
+ CairoFelt252,
12383
12563
  CairoFixedArray,
12384
12564
  CairoInt128,
12385
12565
  CairoInt16,
@@ -12393,6 +12573,7 @@ function units(amount, simbol = "fri") {
12393
12573
  CairoUint128,
12394
12574
  CairoUint16,
12395
12575
  CairoUint256,
12576
+ CairoUint32,
12396
12577
  CairoUint512,
12397
12578
  CairoUint64,
12398
12579
  CairoUint8,