Skip to content

Commit 00e9cca

Browse files
ryanioclaude
andauthored
refactor: use Set for shared storefront addresses and checksum remapped address (#1864)
* refactor: use Set for shared storefront addresses and return checksummed addresses - Convert SHARED_STOREFRONT_ADDRESSES from array to Set for O(1) lookups - remapSharedStorefrontAddress now returns checksummed addresses via ethers.getAddress() - Gracefully handle invalid addresses by returning them unchanged - Remove uppercase address test since we don't need to handle 0X prefix Co-Authored-By: Claude Opus 4.5 <[email protected]> * fix: prettier formatting and bump version to 8.0.14 Co-Authored-By: Claude Opus 4.5 <[email protected]> * refactor: only checksum remapped shared storefront address Return original tokenAddress unchanged for non-shared storefront addresses. Only return checksummed address when remapping to lazy mint adapter. Co-Authored-By: Claude Opus 4.5 <[email protected]> --------- Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent 3a1936f commit 00e9cca

File tree

6 files changed

+20
-31
lines changed

6 files changed

+20
-31
lines changed

developerDocs/advanced-use-cases.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ const listing = await openseaSDK.createListing({
6060
});
6161
```
6262

63-
**Important**
63+
**Important**
64+
6465
> Private orders only restrict the taker address at the contract level. The order data remains public and discoverable via OpenSea APIs and on-chain indexers.
6566
6667
### Canceling Orders

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "opensea-js",
3-
"version": "8.0.13",
3+
"version": "8.0.14",
44
"description": "TypeScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs and our marketplace data",
55
"license": "MIT",
66
"author": "OpenSea Developers",

src/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ const SHARED_STOREFRONT_ADDRESS_MAINNET =
8080
"0x495f947276749ce646f68ac8c248420045cb7b5e";
8181
const SHARED_STOREFRONT_ADDRESS_POLYGON =
8282
"0x2953399124f0cbb46d2cbacd8a89cf0599974963";
83-
export const SHARED_STOREFRONT_ADDRESSES = [
83+
export const SHARED_STOREFRONT_ADDRESSES = new Set([
8484
SHARED_STOREFRONT_ADDRESS_MAINNET,
8585
SHARED_STOREFRONT_ADDRESS_POLYGON,
86-
].map((address) => address.toLowerCase());
86+
]);
8787
export const SHARED_STOREFRONT_LAZY_MINT_ADAPTER_CROSS_CHAIN_ADDRESS =
8888
"0xa604060890923ff400e8c6f5290461a83aedacec";

src/utils/protocol.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,12 @@ export const getAssetItemType = (tokenStandard: TokenStandard) => {
4747
* otherwise returns the original address unchanged
4848
*/
4949
export const remapSharedStorefrontAddress = (tokenAddress: string): string => {
50-
return SHARED_STOREFRONT_ADDRESSES.includes(tokenAddress.toLowerCase())
51-
? SHARED_STOREFRONT_LAZY_MINT_ADAPTER_CROSS_CHAIN_ADDRESS
52-
: tokenAddress;
50+
if (SHARED_STOREFRONT_ADDRESSES.has(tokenAddress.toLowerCase())) {
51+
return ethers.getAddress(
52+
SHARED_STOREFRONT_LAZY_MINT_ADAPTER_CROSS_CHAIN_ADDRESS,
53+
);
54+
}
55+
return tokenAddress;
5356
};
5457

5558
/**

test/sdk/misc.spec.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,18 @@ suite("SDK: misc", () => {
2222
assert.equal(typeof sdk.api.getOrders, "function");
2323
});
2424

25-
test("Checks that a non-shared storefront address is not remapped", async () => {
25+
test("Checks that a non-shared storefront address is returned unchanged", async () => {
2626
const address = BAYC_CONTRACT_ADDRESS;
2727
assert.equal(remapSharedStorefrontAddress(address), address);
2828
});
2929

30-
test("Checks that shared storefront addresses are remapped to lazy mint adapter address", async () => {
30+
test("Checks that shared storefront addresses are remapped to checksummed lazy mint adapter address", async () => {
3131
for (const address of SHARED_STOREFRONT_ADDRESSES) {
3232
assert.equal(
3333
remapSharedStorefrontAddress(address),
34-
SHARED_STOREFRONT_LAZY_MINT_ADAPTER_CROSS_CHAIN_ADDRESS,
35-
);
36-
}
37-
});
38-
39-
test("Checks that upper case shared storefront addresses are remapped to lazy mint adapter address", async () => {
40-
for (const address of SHARED_STOREFRONT_ADDRESSES) {
41-
assert.equal(
42-
remapSharedStorefrontAddress(address.toUpperCase()),
43-
SHARED_STOREFRONT_LAZY_MINT_ADAPTER_CROSS_CHAIN_ADDRESS,
34+
ethers.getAddress(
35+
SHARED_STOREFRONT_LAZY_MINT_ADAPTER_CROSS_CHAIN_ADDRESS,
36+
),
4437
);
4538
}
4639
});

test/utils/protocol.spec.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,13 @@ suite("Utils: protocol", () => {
112112
});
113113

114114
suite("remapSharedStorefrontAddress", () => {
115-
test("returns lazy mint adapter address for shared storefront address", () => {
115+
test("returns checksummed lazy mint adapter address for shared storefront address", () => {
116116
for (const sharedStorefrontAddress of SHARED_STOREFRONT_ADDRESSES) {
117117
const result = remapSharedStorefrontAddress(sharedStorefrontAddress);
118118
expect(result).to.equal(
119-
SHARED_STOREFRONT_LAZY_MINT_ADAPTER_CROSS_CHAIN_ADDRESS,
120-
);
121-
}
122-
});
123-
124-
test("returns lazy mint adapter address for uppercase shared storefront address", () => {
125-
for (const sharedStorefrontAddress of SHARED_STOREFRONT_ADDRESSES) {
126-
const upperCaseAddress = sharedStorefrontAddress.toUpperCase();
127-
const result = remapSharedStorefrontAddress(upperCaseAddress);
128-
expect(result).to.equal(
129-
SHARED_STOREFRONT_LAZY_MINT_ADAPTER_CROSS_CHAIN_ADDRESS,
119+
ethers.getAddress(
120+
SHARED_STOREFRONT_LAZY_MINT_ADAPTER_CROSS_CHAIN_ADDRESS,
121+
),
130122
);
131123
}
132124
});

0 commit comments

Comments
 (0)