Skip to content

Commit

Permalink
[SDK] Feature: Adds Multiwrap and LoyaltyCard Extensions (#5529)
Browse files Browse the repository at this point in the history
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 -->
  • Loading branch information
gregfromstl committed Nov 27, 2024
1 parent 9d3c8ac commit 7488102
Show file tree
Hide file tree
Showing 29 changed files with 2,809 additions and 9 deletions.
30 changes: 30 additions & 0 deletions .changeset/selfish-deers-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
"thirdweb": minor
---

Adds LoyaltyCard extensions and support for ERC721 deployment.

```ts
import { deployERC721Contract } from "thirdweb/deploys";

const loyaltyCardContractAddress = await deployERC721Contract({
chain: "your-chain-id", // replace with your chain ID
client: yourThirdwebClient, // replace with your Thirdweb client instance
account: yourAccount, // replace with your account details
type: "LoyaltyCard",
params: {
name: "MyLoyaltyCard",
symbol: "LOYAL",
description: "A loyalty card NFT contract",
image: "path/to/image.png", // replace with your image path
defaultAdmin: "0xYourAdminAddress", // replace with your admin address
royaltyRecipient: "0xYourRoyaltyRecipient", // replace with your royalty recipient address
royaltyBps: 500n, // 5% royalty
trustedForwarders: ["0xTrustedForwarderAddress"], // replace with your trusted forwarder addresses
saleRecipient: "0xYourSaleRecipient", // replace with your sale recipient address
platformFeeBps: 200n, // 2% platform fee
platformFeeRecipient: "0xYourPlatformFeeRecipient", // replace with your platform fee recipient address
},
});

```
14 changes: 8 additions & 6 deletions .github/workflows/issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ jobs:
repo: context.repo.repo,
pull_number: context.issue.number
});
const body = pr.data.body || '';
const branchName = pr.data.head.ref;
const issueRegex = new RegExp(`(${process.env.VALID_ISSUE_PREFIXES})-\\d+`, 'i');
if (!issueRegex.test(body)) {
const branchIssueRegex = new RegExp(`(${process.env.VALID_ISSUE_PREFIXES.toLowerCase()})-\\d+`, 'i');
if (!issueRegex.test(body) && !branchIssueRegex.test(branchName)) {
core.setFailed(
`No valid issue reference found. PR body must contain an issue ID with one of these prefixes: ${process.env.VALID_ISSUE_PREFIXES}`
`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}`
);
return;
}
const matches = body.match(issueRegex);
const matches = body.match(issueRegex) || branchName.match(branchIssueRegex);
console.log(`Found issue reference: ${matches[0]}`);
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ coverage:
target: 80%
flags:
- packages
ignore:
- "**/__generated__/**"


github_checks:
Expand Down
14 changes: 14 additions & 0 deletions packages/thirdweb/scripts/generate/abis/erc721/LoyaltyCard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
"constructor()",
"function cancel(uint256 tokenId)",
"function initialize(address _defaultAdmin, string _name, string _symbol, string _contractURI, address[] _trustedForwarders, address _saleRecipient, address _royaltyRecipient, uint128 _royaltyBps, uint128 _platformFeeBps, address _platformFeeRecipient)",
"function mintTo(address _to, string _uri) returns (uint256 tokenIdMinted)",
"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)",
"function nextTokenIdToMint() view returns (uint256)",
"function revoke(uint256 tokenId)",
"function supportsInterface(bytes4 interfaceId) view returns (bool)",
"function tokenURI(uint256 _tokenId) view returns (string)",
"function totalMinted() view returns (uint256)",
"event TokensMinted(address indexed mintedTo, uint256 indexed tokenIdMinted, string uri)",
"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)"
]
15 changes: 15 additions & 0 deletions packages/thirdweb/scripts/generate/abis/erc721/Multiwrap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[
"constructor(address _nativeTokenWrapper)",
"event TokensWrapped(address indexed wrapper, address indexed recipientOfWrappedToken, uint256 indexed tokenIdOfWrappedToken, (address assetContract, uint8 tokenType, uint256 tokenId, uint256 amount)[] wrappedContents)",
"event TokensUnwrapped(address indexed unwrapper, address indexed recipientOfWrappedContents, uint256 indexed tokenIdOfWrappedToken)",
"function contractType() pure returns (bytes32)",
"function contractVersion() pure returns (uint8)",
"function getWrappedContents(uint256 _tokenId) view returns ((address assetContract, uint8 tokenType, uint256 tokenId, uint256 amount)[] contents)",
"function initialize(address _defaultAdmin, string _name, string _symbol, string _contractURI, address[] _trustedForwarders, address _royaltyRecipient, uint256 _royaltyBps)",
"function nextTokenIdToMint() view returns (uint256)",
"function supportsInterface(bytes4 interfaceId) view returns (bool)",
"function tokenURI(uint256 _tokenId) view returns (string)",
"function unwrap(uint256 _tokenId, address _recipient)",
"function wrap((address assetContract, uint8 tokenType, uint256 tokenId, uint256 amount)[] _tokensToWrap, string _uriForWrappedToken, address _recipient) payable returns (uint256 tokenId)",
"receive() external payable"
]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7488102

Please sign in to comment.