@rareprotocol/rare-cli 1.1.0 → 1.2.1

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/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { h as UtilsMerkleProofParams, i as UtilsMerkleProofArtifact, d as BuildUtilsTreeParams, U as UtilsTreeArtifact, e as UtilsTreeProofParams, f as UtilsTreeProofArtifact, g as UtilsTreeProofVerifyParams } from './batch-listing-Cu5Hoqxs.js';
1
+ import { h as UtilsMerkleProofParams, i as UtilsMerkleProofArtifact, d as BuildUtilsTreeParams, U as UtilsTreeArtifact, e as UtilsTreeProofParams, f as UtilsTreeProofArtifact, g as UtilsTreeProofVerifyParams } from './batch-listing-C1CtPTD5.js';
2
2
  import 'viem';
3
- import './addresses-BE3luaB3.js';
3
+ import './addresses-CcGI_7v1.js';
4
4
 
5
5
  declare function buildUtilsTree(params: BuildUtilsTreeParams): UtilsTreeArtifact;
6
6
  declare function getUtilsTreeProof(params: UtilsTreeProofParams): UtilsTreeProofArtifact;
package/dist/utils.js CHANGED
@@ -415,10 +415,14 @@ function addressLeaf(address) {
415
415
  return hexBuffer(keccak2562(address));
416
416
  }
417
417
  function parseBytes32(value, field) {
418
- if (!isHex2(value) || value.length !== 66) {
418
+ if (!isHex2(value, { strict: true }) || value.length !== 66) {
419
419
  throw new Error(`${field} must be a 0x-prefixed bytes32 hex string`);
420
420
  }
421
- return value;
421
+ const normalized = value.toLowerCase();
422
+ if (!isHex2(normalized, { strict: true }) || normalized.length !== 66) {
423
+ throw new Error(`${field} must be a 0x-prefixed bytes32 hex string`);
424
+ }
425
+ return normalized;
422
426
  }
423
427
  function parseBytes32Array(values, field) {
424
428
  return values.map((value, index) => parseBytes32(value, `${field}[${index}]`));
@@ -494,14 +498,15 @@ function buildMerkleProofArtifact(artifact, contract, tokenId, buyer) {
494
498
  const { tree, root } = buildBatchListingTree(
495
499
  artifact.tokens.map((token) => ({ contract: token.contract, tokenId: token.tokenId }))
496
500
  );
497
- if (root !== artifact.root) {
501
+ const artifactRoot = parseBytes32(artifact.root, "artifact.root");
502
+ if (root !== artifactRoot) {
498
503
  throw new Error(
499
504
  `Recomputed NFT tree root (${root}) does not match artifact root (${artifact.root}). Artifact is corrupt or tree encoding has drifted.`
500
505
  );
501
506
  }
502
507
  const allowListProofFields = buildAllowListProofFields(artifact, buyer);
503
508
  return {
504
- root: artifact.root,
509
+ root: artifactRoot,
505
510
  contract: contractChecksum,
506
511
  tokenId: tokenIdBig.toString(),
507
512
  proof: getTokenProof(tree, contractChecksum, tokenIdBig),
@@ -522,7 +527,8 @@ function buildAllowListProofFields(artifact, buyer) {
522
527
  throw new Error(`Buyer ${buyerChecksum} is not in the allowlist`);
523
528
  }
524
529
  const { tree, root } = buildAllowListTree(artifact.allowList.addresses);
525
- if (root !== artifact.allowList.root) {
530
+ const artifactAllowListRoot = parseBytes32(artifact.allowList.root, "allowList.root");
531
+ if (root !== artifactAllowListRoot) {
526
532
  throw new Error(
527
533
  `Recomputed allowlist root (${root}) does not match artifact (${artifact.allowList.root})`
528
534
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rareprotocol/rare-cli",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "CLI tool for interacting with the RARE protocol smart contracts",
5
5
  "type": "module",
6
6
  "license": "MIT",