-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up and refactor digital asset template (#121)
* clean up and refactor digital asset template * address comments
- Loading branch information
Showing
27 changed files
with
342 additions
and
320 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 |
---|---|---|
|
@@ -7,4 +7,5 @@ node_modules | |
|
||
package-lock.json | ||
|
||
templates/*/move/build | ||
templates/*/move/build | ||
templates/*/build |
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
7 changes: 4 additions & 3 deletions
7
templates/digital-asset-template/frontend/components/UploadSpinner.tsx
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
3 changes: 2 additions & 1 deletion
3
templates/digital-asset-template/frontend/components/WalletProvider.tsx
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
65 changes: 65 additions & 0 deletions
65
templates/digital-asset-template/frontend/entry-functions/create_collection.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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { AccountAddressInput } from "@aptos-labs/ts-sdk"; | ||
import { InputTransactionData } from "@aptos-labs/wallet-adapter-react"; | ||
|
||
import { APT_DECIMALS, dateToSeconds, convertAmountFromHumanReadableToOnChain } from "@/utils/helpers"; | ||
|
||
export type CreateCollectionArguments = { | ||
collectionDescription: string; // The collection description | ||
collectionName: string; // The collection name | ||
projectUri: string; // The project URI (i.e https://mydomain.com) | ||
maxSupply: number; // The amount of NFTs in a collection | ||
royaltyPercentage?: number; // The percentage of trading value that collection creator gets when an NFT is sold on marketplaces | ||
preMintAmount?: number; // amount of NFT to pre-mint for myself | ||
allowList?: Array<AccountAddressInput>; // addresses in the allow list | ||
allowListStartDate?: Date; // allow list start time (in seconds) | ||
allowListEndDate?: Date; // allow list end time (in seconds) | ||
allowListLimitPerAccount?: number; // mint limit per address in the allow list | ||
allowListFeePerNFT?: number; // mint fee per NFT for the allow list | ||
publicMintStartDate?: Date; // public mint start time (in seconds) | ||
publicMintEndDate?: Date; // public mint end time (in seconds) | ||
publicMintLimitPerAccount: number; // mint limit per address in the public mint | ||
publicMintFeePerNFT?: number; // mint fee per NFT for the public mint, on chain stored in smallest unit of APT (i.e. 1e8 oAPT = 1 APT) | ||
}; | ||
|
||
export const createCollection = (args: CreateCollectionArguments): InputTransactionData => { | ||
const { | ||
collectionDescription, | ||
collectionName, | ||
projectUri, | ||
maxSupply, | ||
royaltyPercentage, | ||
preMintAmount, | ||
allowList, | ||
allowListStartDate, | ||
allowListEndDate, | ||
allowListLimitPerAccount, | ||
allowListFeePerNFT, | ||
publicMintStartDate, | ||
publicMintEndDate, | ||
publicMintLimitPerAccount, | ||
publicMintFeePerNFT, | ||
} = args; | ||
return { | ||
data: { | ||
function: `${import.meta.env.VITE_MODULE_ADDRESS}::launchpad::create_collection`, | ||
typeArguments: [], | ||
functionArguments: [ | ||
collectionDescription, | ||
collectionName, | ||
projectUri, | ||
maxSupply, | ||
royaltyPercentage, | ||
preMintAmount, | ||
allowList, | ||
dateToSeconds(allowListStartDate), | ||
dateToSeconds(allowListEndDate), | ||
allowListLimitPerAccount, | ||
allowListFeePerNFT, | ||
publicMintStartDate ? dateToSeconds(publicMintStartDate) : dateToSeconds(new Date()), | ||
dateToSeconds(publicMintEndDate), | ||
publicMintLimitPerAccount, | ||
publicMintFeePerNFT ? convertAmountFromHumanReadableToOnChain(publicMintFeePerNFT, APT_DECIMALS) : 0, | ||
], | ||
}, | ||
}; | ||
}; |
17 changes: 17 additions & 0 deletions
17
templates/digital-asset-template/frontend/entry-functions/mint_nft.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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { InputTransactionData } from "@aptos-labs/wallet-adapter-react"; | ||
|
||
export type MintNftArguments = { | ||
collectionId: string; | ||
amount: number; | ||
}; | ||
|
||
export const mintNFT = (args: MintNftArguments): InputTransactionData => { | ||
const { collectionId, amount } = args; | ||
return { | ||
data: { | ||
function: `${import.meta.env.VITE_MODULE_ADDRESS}::launchpad::mint_nft`, | ||
typeArguments: [], | ||
functionArguments: [collectionId, amount], | ||
}, | ||
}; | ||
}; |
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
Oops, something went wrong.