Skip to content

Commit 7488102

Browse files
committed
[SDK] Feature: Adds Multiwrap and LoyaltyCard Extensions (#5529)
CNCT-2438 <!-- start pr-codex --> --- ## PR-Codex overview This PR introduces enhancements to the `thirdweb` library by adding support for a new `LoyaltyCard` extension, improving event handling, and updating the `github_checks` workflow to validate PR branches for issue references. ### Detailed summary - Added `ignore` pattern in `codecov.yml`. - Updated `issue.yml` to check PR body and branch name for valid issue references. - Implemented `LoyaltyCard` extension with deployment support and event handling. - Added new functions for `TokensMinted`, `TokensUnwrapped`, and `TokensWrapped` events. - Updated `Multiwrap` and `LoyaltyCard` ABIs. - Added tests for deploying `LoyaltyCard` and other ERC721 types. > The following files were skipped due to too many changes: `packages/thirdweb/src/extensions/erc721/__generated__/Multiwrap/write/unwrap.ts`, `packages/thirdweb/src/extensions/erc721/__generated__/Multiwrap/write/wrap.ts`, `packages/thirdweb/src/extensions/erc721/__generated__/LoyaltyCard/write/mintWithSignature.ts`, `packages/thirdweb/src/extensions/erc721/__generated__/Multiwrap/write/initialize.ts`, `packages/thirdweb/src/extensions/erc721/__generated__/LoyaltyCard/write/initialize.ts` > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 9d3c8ac commit 7488102

29 files changed

+2809
-9
lines changed

.changeset/selfish-deers-destroy.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
"thirdweb": minor
3+
---
4+
5+
Adds LoyaltyCard extensions and support for ERC721 deployment.
6+
7+
```ts
8+
import { deployERC721Contract } from "thirdweb/deploys";
9+
10+
const loyaltyCardContractAddress = await deployERC721Contract({
11+
chain: "your-chain-id", // replace with your chain ID
12+
client: yourThirdwebClient, // replace with your Thirdweb client instance
13+
account: yourAccount, // replace with your account details
14+
type: "LoyaltyCard",
15+
params: {
16+
name: "MyLoyaltyCard",
17+
symbol: "LOYAL",
18+
description: "A loyalty card NFT contract",
19+
image: "path/to/image.png", // replace with your image path
20+
defaultAdmin: "0xYourAdminAddress", // replace with your admin address
21+
royaltyRecipient: "0xYourRoyaltyRecipient", // replace with your royalty recipient address
22+
royaltyBps: 500n, // 5% royalty
23+
trustedForwarders: ["0xTrustedForwarderAddress"], // replace with your trusted forwarder addresses
24+
saleRecipient: "0xYourSaleRecipient", // replace with your sale recipient address
25+
platformFeeBps: 200n, // 2% platform fee
26+
platformFeeRecipient: "0xYourPlatformFeeRecipient", // replace with your platform fee recipient address
27+
},
28+
});
29+
30+
```

.github/workflows/issue.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,18 @@ jobs:
2121
repo: context.repo.repo,
2222
pull_number: context.issue.number
2323
});
24-
24+
2525
const body = pr.data.body || '';
26+
const branchName = pr.data.head.ref;
2627
const issueRegex = new RegExp(`(${process.env.VALID_ISSUE_PREFIXES})-\\d+`, 'i');
27-
28-
if (!issueRegex.test(body)) {
28+
const branchIssueRegex = new RegExp(`(${process.env.VALID_ISSUE_PREFIXES.toLowerCase()})-\\d+`, 'i');
29+
30+
if (!issueRegex.test(body) && !branchIssueRegex.test(branchName)) {
2931
core.setFailed(
30-
`No valid issue reference found. PR body must contain an issue ID with one of these prefixes: ${process.env.VALID_ISSUE_PREFIXES}`
32+
`No valid issue reference found. PR body or branch name must contain an issue ID with one of these prefixes: ${process.env.VALID_ISSUE_PREFIXES}`
3133
);
3234
return;
3335
}
34-
35-
const matches = body.match(issueRegex);
36+
37+
const matches = body.match(issueRegex) || branchName.match(branchIssueRegex);
3638
console.log(`Found issue reference: ${matches[0]}`);

codecov.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ coverage:
88
target: 80%
99
flags:
1010
- packages
11+
ignore:
12+
- "**/__generated__/**"
1113

1214

1315
github_checks:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[
2+
"constructor()",
3+
"function cancel(uint256 tokenId)",
4+
"function initialize(address _defaultAdmin, string _name, string _symbol, string _contractURI, address[] _trustedForwarders, address _saleRecipient, address _royaltyRecipient, uint128 _royaltyBps, uint128 _platformFeeBps, address _platformFeeRecipient)",
5+
"function mintTo(address _to, string _uri) returns (uint256 tokenIdMinted)",
6+
"function mintWithSignature((address to, address royaltyRecipient, uint256 royaltyBps, address primarySaleRecipient, uint256 quantity, uint256 pricePerToken, address currency, uint128 validityStartTimestamp, uint128 validityEndTimestamp, string uri) _req, bytes _signature) payable returns (address signer)",
7+
"function nextTokenIdToMint() view returns (uint256)",
8+
"function revoke(uint256 tokenId)",
9+
"function supportsInterface(bytes4 interfaceId) view returns (bool)",
10+
"function tokenURI(uint256 _tokenId) view returns (string)",
11+
"function totalMinted() view returns (uint256)",
12+
"event TokensMinted(address indexed mintedTo, uint256 indexed tokenIdMinted, string uri)",
13+
"event TokensMintedWithSignature(address indexed signer, address indexed mintedTo, uint256 indexed tokenIdMinted, (address to, address royaltyRecipient, uint256 royaltyBps, address primarySaleRecipient, uint256 quantity, uint256 pricePerToken, address currency, uint128 validityStartTimestamp, uint128 validityEndTimestamp, string uri) mintRequest)"
14+
]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[
2+
"constructor(address _nativeTokenWrapper)",
3+
"event TokensWrapped(address indexed wrapper, address indexed recipientOfWrappedToken, uint256 indexed tokenIdOfWrappedToken, (address assetContract, uint8 tokenType, uint256 tokenId, uint256 amount)[] wrappedContents)",
4+
"event TokensUnwrapped(address indexed unwrapper, address indexed recipientOfWrappedContents, uint256 indexed tokenIdOfWrappedToken)",
5+
"function contractType() pure returns (bytes32)",
6+
"function contractVersion() pure returns (uint8)",
7+
"function getWrappedContents(uint256 _tokenId) view returns ((address assetContract, uint8 tokenType, uint256 tokenId, uint256 amount)[] contents)",
8+
"function initialize(address _defaultAdmin, string _name, string _symbol, string _contractURI, address[] _trustedForwarders, address _royaltyRecipient, uint256 _royaltyBps)",
9+
"function nextTokenIdToMint() view returns (uint256)",
10+
"function supportsInterface(bytes4 interfaceId) view returns (bool)",
11+
"function tokenURI(uint256 _tokenId) view returns (string)",
12+
"function unwrap(uint256 _tokenId, address _recipient)",
13+
"function wrap((address assetContract, uint8 tokenType, uint256 tokenId, uint256 amount)[] _tokensToWrap, string _uriForWrappedToken, address _recipient) payable returns (uint256 tokenId)",
14+
"receive() external payable"
15+
]

packages/thirdweb/src/extensions/erc721/__generated__/LoyaltyCard/events/TokensMinted.ts

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/thirdweb/src/extensions/erc721/__generated__/LoyaltyCard/events/TokensMintedWithSignature.ts

Lines changed: 55 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/thirdweb/src/extensions/erc721/__generated__/LoyaltyCard/read/nextTokenIdToMint.ts

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)