-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added back build-js task * Add protocol sdk and minting features (#322) * Moved premint sdk to protocol sdk * add protocol sdk and minting features --------- Co-authored-by: Dan Oved <[email protected]> --------- Co-authored-by: Iain Nash <[email protected]>
- Loading branch information
Showing
33 changed files
with
4,064 additions
and
337 deletions.
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,29 @@ | ||
name: JS | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
build_js: | ||
strategy: | ||
fail-fast: true | ||
|
||
name: Build js package | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install node deps and founry | ||
uses: ./.github/actions/setup_deps | ||
|
||
- name: Build js package | ||
run: | | ||
npx turbo run build | ||
- name: Test js package | ||
run: | | ||
npx turbo run test:js |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,163 @@ | ||
# Premint SDK | ||
|
||
Protocol SDK allows users to manage zora mints and collects. | ||
|
||
## Installing | ||
|
||
[viem](https://viem.sh/) is a peerDependency of protocol-sdk. If not already installed, it needs to be installed alongside the protocol sdk. | ||
|
||
- `npm install viem` | ||
- `npm install ` | ||
|
||
### Creating a mint from an on-chain contract: | ||
|
||
```ts | ||
import { MintAPI } from "@zoralabs/protocol-sdk"; | ||
import type { Address, WalletClient } from "viem"; | ||
|
||
async function mintNFT( | ||
walletClient: WalletClient, | ||
address: Address, | ||
tokenId: bigint, | ||
) { | ||
const mintAPI = new MintAPI(walletClient.chain); | ||
await mintAPI.mintNFT({ | ||
walletClient, | ||
address, | ||
tokenId, | ||
mintArguments: { | ||
quantityToMint: 23, | ||
mintComment: "Helo", | ||
}, | ||
}); | ||
} | ||
``` | ||
|
||
### Creating a premint: | ||
|
||
```ts | ||
import { PremintAPI } from "@zoralabs/protocol-sdk"; | ||
import type { Address, WalletClient } from "viem"; | ||
|
||
async function makePremint(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.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: | ||
|
||
```ts | ||
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: | ||
|
||
```ts | ||
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: | ||
|
||
```ts | ||
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 | ||
}); | ||
} | ||
|
||
``` |
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
Oops, something went wrong.