Skip to content
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 42 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
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 Oct 17, 2023
2e8fca7
update premint api tests
iainnash Oct 18, 2023
30c4170
update tests and docs
iainnash Oct 18, 2023
95ee365
new preminter update
iainnash Oct 18, 2023
46a60cd
premint update example urls
iainnash Oct 18, 2023
22157fd
add changeset for pre-release
iainnash Oct 18, 2023
80d5b90
fix prepack
iainnash Oct 18, 2023
399c958
fix merge conflict
iainnash Oct 18, 2023
7934f25
prerelease
iainnash Oct 18, 2023
7d388e0
Version Packages (premint-api) (#277)
github-actions[bot] Oct 18, 2023
c405574
update premint api
iainnash Oct 18, 2023
8395b8e
changeset prerelease
iainnash Oct 18, 2023
7213e14
Merge remote-tracking branch 'origin/prerelease_premint_api_helper' i…
iainnash Oct 18, 2023
cf184b3
update package barrel
iainnash Oct 19, 2023
a4fb8b0
update
iainnash Oct 19, 2023
aa023d3
adding mjs build
iainnash Oct 20, 2023
aae756b
update changeset
iainnash Oct 20, 2023
e4776d6
wip moving to a new package
iainnash Oct 20, 2023
1863881
add premint
iainnash Oct 20, 2023
66d96a9
remove changesets updates
iainnash Oct 20, 2023
dcf5bbf
update premint api
iainnash Oct 20, 2023
f506fad
add readme
iainnash Oct 20, 2023
7135d11
update tsconfig
iainnash Oct 20, 2023
411baca
update configs
iainnash Oct 20, 2023
f4a997b
adding changeset
iainnash Oct 20, 2023
cc75b2d
update premint example
iainnash Oct 21, 2023
b5dd1f8
prerelease changeset
iainnash Oct 21, 2023
cff1cc4
Version Packages (premint-api) (#287)
github-actions[bot] Oct 21, 2023
6eaf7bb
update premint-sdk
iainnash Oct 21, 2023
9e93204
Version Packages (premint-api) (#292)
github-actions[bot] Oct 21, 2023
654998a
update api
iainnash Oct 22, 2023
c29e080
add prerelease changeset
iainnash Oct 23, 2023
6e1437a
Version Packages (premint-api) (#293)
github-actions[bot] Oct 24, 2023
1350e00
zora add api client
iainnash Oct 26, 2023
057c9ab
Merge remote-tracking branch 'origin/prerelease_premint_api_helper' i…
iainnash Oct 26, 2023
1d9df4d
update docs and api
iainnash Oct 26, 2023
0d34334
exit pre-release
iainnash Oct 27, 2023
4b8abba
remove pre-release changesets and add a new changeset for adding the …
iainnash Oct 27, 2023
1193564
update release data
iainnash Oct 27, 2023
9135d2e
test fixes
iainnash Oct 30, 2023
a70a355
merge
iainnash Oct 30, 2023
ab59268
revert changelog changes
iainnash Oct 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/soft-dots-live.md
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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice changeset!

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ dist/
.env
.env.*
!.env.example
!.env.anvil

package/wagmiGenerated.ts
package/chainConfigs.ts
Expand Down
28 changes: 12 additions & 16 deletions packages/1155-contracts/package.json
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": {
Expand Down Expand Up @@ -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"
}
}
4 changes: 2 additions & 2 deletions packages/1155-contracts/src/version/ContractVersionBase.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This file is automatically generated by code; do not manually update
// Last updated on 2023-10-18T17:43:11.859Z
// Last updated on 2023-10-30T19:58:54.830Z
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

Expand All @@ -10,6 +10,6 @@ import {IVersionedContract} from "../interfaces/IVersionedContract.sol";
contract ContractVersionBase is IVersionedContract {
/// @notice The version of the contract
function contractVersion() external pure override returns (string memory) {
return "2.1.0";
return "2.2.0";
}
}
7 changes: 2 additions & 5 deletions packages/1155-contracts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,5 @@
"outDir": "dist"
},
"exclude": ["node_modules/**", "dist/**"],
"include": [
"package/**/*.ts",
"script/*.ts"
],
}
"include": ["package/**/*.ts", "script/*.ts"]
}
2 changes: 1 addition & 1 deletion packages/1155-contracts/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export default defineConfig({
sourcemap: true,
clean: true,
dts: false,
format: ['cjs'],
format: ['cjs', 'esm'],
onSuccess: 'tsc --emitDeclarationOnly --declaration --declarationMap'
})
File renamed without changes.
22 changes: 22 additions & 0 deletions packages/premint-sdk/CHANGELOG.md
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]
131 changes: 131 additions & 0 deletions packages/premint-sdk/README.md
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
```
30 changes: 30 additions & 0 deletions packages/premint-sdk/package.json
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"
}
}
Loading