-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Premint api helper #276
Merged
Merged
Premint api helper #276
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
c59ba4f
add premint api js
iainnash 2e8fca7
update premint api tests
iainnash 30c4170
update tests and docs
iainnash 95ee365
new preminter update
iainnash 46a60cd
premint update example urls
iainnash 22157fd
add changeset for pre-release
iainnash 80d5b90
fix prepack
iainnash 399c958
fix merge conflict
iainnash 7934f25
prerelease
iainnash 7d388e0
Version Packages (premint-api) (#277)
github-actions[bot] c405574
update premint api
iainnash 8395b8e
changeset prerelease
iainnash 7213e14
Merge remote-tracking branch 'origin/prerelease_premint_api_helper' i…
iainnash cf184b3
update package barrel
iainnash a4fb8b0
update
iainnash aa023d3
adding mjs build
iainnash aae756b
update changeset
iainnash e4776d6
wip moving to a new package
iainnash 1863881
add premint
iainnash 66d96a9
remove changesets updates
iainnash dcf5bbf
update premint api
iainnash f506fad
add readme
iainnash 7135d11
update tsconfig
iainnash 411baca
update configs
iainnash f4a997b
adding changeset
iainnash cc75b2d
update premint example
iainnash b5dd1f8
prerelease changeset
iainnash cff1cc4
Version Packages (premint-api) (#287)
github-actions[bot] 6eaf7bb
update premint-sdk
iainnash 9e93204
Version Packages (premint-api) (#292)
github-actions[bot] 654998a
update api
iainnash c29e080
add prerelease changeset
iainnash 6e1437a
Version Packages (premint-api) (#293)
github-actions[bot] 1350e00
zora add api client
iainnash 057c9ab
Merge remote-tracking branch 'origin/prerelease_premint_api_helper' i…
iainnash 1d9df4d
update docs and api
iainnash 0d34334
exit pre-release
iainnash 4b8abba
remove pre-release changesets and add a new changeset for adding the …
iainnash 1193564
update release data
iainnash 9135d2e
test fixes
iainnash a70a355
merge
iainnash ab59268
revert changelog changes
iainnash File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@zoralabs/premint-sdk": minor | ||
--- | ||
|
||
Added new premint api that abstracts out calls to the chain signature and submission logic around submitting a premint. This change also incorporates test helpers for premints and introduces docs and an api client for the zora api's premint module. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ dist/ | |
.env | ||
.env.* | ||
!.env.example | ||
!.env.anvil | ||
|
||
package/wagmiGenerated.ts | ||
package/chainConfigs.ts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"name": "@zoralabs/zora-1155-contracts", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"repository": "[email protected]:ourzora/zora-protocol.git", | ||
"author": "Iain <[email protected]>", | ||
"license": "MIT", | ||
"main": "./dist/index.cjs", | ||
"main": "./dist/index.js", | ||
iainnash marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"types": "./dist/package/index.d.ts", | ||
"type": "module", | ||
"scripts": { | ||
|
@@ -45,29 +45,25 @@ | |
], | ||
"dependencies": { | ||
"@openzeppelin/contracts": "4.9.2", | ||
"@wagmi/cli": "^1.0.1", | ||
"@zoralabs/openzeppelin-contracts-upgradeable": "4.8.4", | ||
"@zoralabs/protocol-rewards": "*", | ||
"abitype": "^0.8.7", | ||
"ds-test": "https://github.com/dapphub/ds-test#cd98eff28324bfac652e63a239a60632a761790b", | ||
"es-main": "^1.2.0", | ||
"forge-std": "https://github.com/foundry-rs/forge-std#705263c95892a906d7af65f0f73ce8a4a0c80b80", | ||
"glob": "^10.2.2", | ||
"prettier": "^2.8.8", | ||
"prettier-plugin-solidity": "^1.1.3", | ||
"solady": "^0.0.123", | ||
"solmate": "^6.1.0", | ||
"tsup": "^7.2.0", | ||
"tsx": "^3.13.0", | ||
"typescript": "^5.0.4", | ||
"viem": "^1.16.2", | ||
"vite": "^4.1.4", | ||
"vitest": "~0.30.1" | ||
"solmate": "^6.1.0" | ||
}, | ||
"devDependencies": { | ||
"@wagmi/cli": "^1.0.1", | ||
"tsx": "^3.13.0", | ||
"glob": "^10.2.2", | ||
"prettier": "^2.8.8", | ||
"es-main": "^1.2.0", | ||
"@turnkey/api-key-stamper": "^0.1.1", | ||
"prettier-plugin-solidity": "^1.1.3", | ||
"@turnkey/http": "^1.2.0", | ||
"@turnkey/viem": "^0.2.4", | ||
"@types/node": "^20.1.2" | ||
"@types/node": "^20.1.2", | ||
"tsup": "^7.2.0", | ||
"typescript": "^5.0.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# @zoralabs/premint-sdk | ||
|
||
## 0.0.2-premint-api.2 | ||
|
||
### Patch Changes | ||
|
||
- c29e080: Update retry and error reporting | ||
|
||
## 0.0.2-premint-api.1 | ||
|
||
### Patch Changes | ||
|
||
- 6eaf7bb: add retries | ||
|
||
## 0.0.2-premint-api.0 | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies [8395b8e] | ||
- Updated dependencies [aae756b] | ||
- Updated dependencies [cf184b3] | ||
- @zoralabs/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
# Premint SDK | ||
|
||
Premint SDK allows users to manage zora premints | ||
|
||
### Creating a premint: | ||
|
||
```js | ||
import {PremintAPI} from '@zoralabs/premint-sdk'; | ||
import type {Address, WalletClient} from 'viem'; | ||
|
||
async function makePremint(walletClient: WalletClient) { | ||
iainnash marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Create premint API object passing in the current wallet chain (only zora and zora testnet are supported currently). | ||
const premintAPI = new PremintAPI(walletClient.chain); | ||
|
||
// Create premint | ||
const premint = await premintAPI.createPremint({ | ||
// Extra step to check the signature on-chain before attempting to sign | ||
checkSignature: true, | ||
// Collection information that this premint NFT will exist in once minted. | ||
collection: { | ||
contractAdmin: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", | ||
contractName: "Testing Contract", | ||
contractURI: "ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e", | ||
}, | ||
// WalletClient doing the signature | ||
walletClient, | ||
// Token information, falls back to defaults set in DefaultMintArguments. | ||
token: { | ||
tokenURI: | ||
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u", | ||
}, | ||
}); | ||
|
||
console.log(`created ZORA premint, link: ${premint.url}`) | ||
return premint; | ||
} | ||
|
||
``` | ||
|
||
### Updating a premint: | ||
|
||
```js | ||
import {PremintAPI} from '@zoralabs/premint-sdk'; | ||
import type {Address, WalletClient} from 'viem'; | ||
|
||
async function updatePremint(walletClient: WalletClient) { | ||
// Create premint API object passing in the current wallet chain (only zora and zora testnet are supported currently). | ||
const premintAPI = new PremintAPI(walletClient.chain); | ||
|
||
// Create premint | ||
const premint = await premintAPI.updatePremint({ | ||
// Extra step to check the signature on-chain before attempting to sign | ||
collection: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", | ||
uid: 23, | ||
// WalletClient doing the signature | ||
walletClient, | ||
// Token information, falls back to defaults set in DefaultMintArguments. | ||
token: { | ||
tokenURI: | ||
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u", | ||
}, | ||
}); | ||
|
||
console.log(`updated ZORA premint, link: ${premint.url}`) | ||
return premint; | ||
} | ||
|
||
``` | ||
|
||
### Deleting a premint: | ||
|
||
```js | ||
import {PremintAPI} from '@zoralabs/premint-sdk'; | ||
import type {Address, WalletClient} from 'viem'; | ||
|
||
async function deletePremint(walletClient: WalletClient) { | ||
// Create premint API object passing in the current wallet chain (only zora and zora testnet are supported currently). | ||
const premintAPI = new PremintAPI(walletClient.chain); | ||
|
||
// Create premint | ||
const premint = await premintAPI.deletePremint({ | ||
// Extra step to check the signature on-chain before attempting to sign | ||
collection: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", | ||
uid: 23, | ||
// WalletClient doing the signature | ||
walletClient, | ||
}); | ||
|
||
console.log(`updated ZORA premint, link: ${premint.url}`) | ||
return premint; | ||
} | ||
|
||
``` | ||
|
||
### Executing a premint: | ||
|
||
```js | ||
import {PremintAPI} from '@zoralabs/premint-sdk'; | ||
import type {Address, WalletClient} from 'viem'; | ||
|
||
async function executePremint(walletClient: WalletClient, premintAddress: Address, premintUID: number) { | ||
const premintAPI = new PremintAPI(walletClient.chain); | ||
|
||
return await premintAPI.executePremintWithWallet({ | ||
data: premintAPI.getPremintData(premintAddress, premintUID), | ||
walletClient, | ||
mintArguments: { | ||
quantityToMint: 1, | ||
} | ||
}); | ||
} | ||
|
||
``` | ||
|
||
### Deleting a premint: | ||
|
||
```js | ||
import {PremintAPI} from '@zoralabs/premint-sdk'; | ||
import type {Address, WalletClient} from 'viem'; | ||
|
||
async function deletePremint(walletClient: WalletClient, collection: Address, uid: number) { | ||
const premintAPI = new PremintAPI(walletClient.chain); | ||
|
||
return await premintAPI.deletePremint({ | ||
walletClient, | ||
uid, | ||
collection | ||
}); | ||
} | ||
|
||
iainnash marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "@zoralabs/premint-sdk", | ||
"version": "0.0.2-premint-api.2", | ||
"repository": "https://github.com/ourzora/zora-protocol", | ||
"license": "MIT", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"type": "module", | ||
"scripts": { | ||
"build": "tsup", | ||
"prepack": "yarn build", | ||
"test": "vitest src", | ||
"generate-types": "npx openapi-typescript https://api.zora.co/premint/openapi.json -o src/generated/premint-api-types.ts && npx openapi-typescript https://api.zora.co/discover/openapi.json -o src/generated/discover-api-types.ts", | ||
"anvil": "source .env.anvil && anvil --fork-url $FORK_RPC_URL --fork-block-number $FORK_BLOCK_NUMBER --chain-id 31337" | ||
}, | ||
"dependencies": { | ||
"@zoralabs/zora-1155-contracts": "*", | ||
"abitype": "^0.8.7", | ||
"vite": "4.5.0", | ||
"vitest": "0.34.6" | ||
}, | ||
"peerDependencies": { | ||
"viem": "^1.16.6" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.2.2", | ||
"vite": "4.5.0", | ||
"vitest": "0.34.6" | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice changeset!