-
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.
refactor and clean up fungible asset template (#124)
- Loading branch information
Showing
21 changed files
with
254 additions
and
186 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
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
8 changes: 5 additions & 3 deletions
8
templates/fungible-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
4 changes: 3 additions & 1 deletion
4
templates/fungible-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
46 changes: 46 additions & 0 deletions
46
templates/fungible-asset-template/frontend/entry-functions/create_asset.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,46 @@ | ||
import { InputTransactionData } from "@aptos-labs/wallet-adapter-react"; | ||
// Internal utils | ||
import { | ||
APT_DECIMALS, | ||
convertAmountFromHumanReadableToOnChain, | ||
convertAmountFromOnChainToHumanReadable, | ||
} from "@/utils/helpers"; | ||
|
||
export type CreateAssetArguments = { | ||
maxSupply: number; // The total amount of the asset in full unit that can be minted. | ||
name: string; // The name of the asset | ||
symbol: string; // The symbol of the asset | ||
decimal: number; // How many 0's constitute one full unit of the asset. For example, APT has 8. | ||
iconURL: string; // The asset icon URL | ||
projectURL: string; // Your project URL (i.e https://mydomain.com) | ||
mintFeePerFA?: number; // The fee cost for the minter to pay to mint one full unit of an asset, denominated in APT. For example, if a user mints 10 assets in a single transaction, they are charged 10x the mint fee. | ||
mintForMyself?: number; // How many assets in full unit to mint right away and send to the signer address. | ||
maxMintPerAccount?: number; // The maximum amount in full unit that any single individual address can mint | ||
}; | ||
|
||
export const createAsset = (args: CreateAssetArguments): InputTransactionData => { | ||
const { maxSupply, name, symbol, decimal, iconURL, projectURL, mintFeePerFA, mintForMyself, maxMintPerAccount } = | ||
args; | ||
return { | ||
data: { | ||
function: `${import.meta.env.VITE_MODULE_ADDRESS}::launchpad::create_fa`, | ||
typeArguments: [], | ||
functionArguments: [ | ||
convertAmountFromHumanReadableToOnChain(maxSupply, decimal), | ||
name, | ||
symbol, | ||
decimal, | ||
iconURL, | ||
projectURL, | ||
mintFeePerFA | ||
? convertAmountFromOnChainToHumanReadable( | ||
convertAmountFromHumanReadableToOnChain(mintFeePerFA, APT_DECIMALS), | ||
decimal, | ||
) | ||
: 0, | ||
mintForMyself ? convertAmountFromHumanReadableToOnChain(mintForMyself, decimal) : 0, | ||
maxMintPerAccount ? convertAmountFromHumanReadableToOnChain(maxMintPerAccount, decimal) : 0, | ||
], | ||
}, | ||
}; | ||
}; |
20 changes: 20 additions & 0 deletions
20
templates/fungible-asset-template/frontend/entry-functions/mint_asset.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,20 @@ | ||
import { InputTransactionData } from "@aptos-labs/wallet-adapter-react"; | ||
// Internal utils | ||
import { convertAmountFromHumanReadableToOnChain } from "@/utils/helpers"; | ||
|
||
export type MintAssetArguments = { | ||
assetType: string; | ||
amount: number; | ||
decimals: number; | ||
}; | ||
|
||
export const mintAsset = (args: MintAssetArguments): InputTransactionData => { | ||
const { assetType, amount, decimals } = args; | ||
return { | ||
data: { | ||
function: `${import.meta.env.VITE_MODULE_ADDRESS}::launchpad::mint_fa`, | ||
typeArguments: [], | ||
functionArguments: [assetType, convertAmountFromHumanReadableToOnChain(amount, decimals)], | ||
}, | ||
}; | ||
}; |
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.