Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ add vote collection snippets (#4)
* ✨ feat: add module collection snippets * feat: ✨ add vote collection snippets Co-authored-by: Avneesh Agarwal <avneeshagarwal0612@gmail.com>
- Loading branch information
1 parent
22ea2bd
commit 6fee031
Showing
5 changed files
with
196 additions
and
15 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 |
---|---|---|
@@ -1,18 +1,11 @@ | ||
# [0.2.0](https://github.com/avneesh0612/thirdweb-snippets/compare/v0.1.0...v0.2.0) (2022-03-13) | ||
|
||
|
||
### Features | ||
|
||
* :sparkles: placeholder support for token snippets ([#2](https://github.com/avneesh0612/thirdweb-snippets/issues/2)) ([87ab37e](https://github.com/avneesh0612/thirdweb-snippets/commit/87ab37e8004d68944365625d7d44a26660c98c8f)) | ||
|
||
|
||
- :sparkles: placeholder support for token snippets ([#2](https://github.com/avneesh0612/thirdweb-snippets/issues/2)) ([87ab37e](https://github.com/avneesh0612/thirdweb-snippets/commit/87ab37e8004d68944365625d7d44a26660c98c8f)) | ||
|
||
# [0.1.0](https://github.com/avneesh0612/thirdweb-snippets/compare/fda702381fe0aaab3a6df6279d922379a66cd3b6...v0.1.0) (2022-03-13) | ||
|
||
|
||
### Features | ||
|
||
* :sparkles: placeholder support for nft snippets ([#1](https://github.com/avneesh0612/thirdweb-snippets/issues/1)) ([fda7023](https://github.com/avneesh0612/thirdweb-snippets/commit/fda702381fe0aaab3a6df6279d922379a66cd3b6)) | ||
|
||
|
||
|
||
- :sparkles: placeholder support for nft snippets ([#1](https://github.com/avneesh0612/thirdweb-snippets/issues/1)) ([fda7023](https://github.com/avneesh0612/thirdweb-snippets/commit/fda702381fe0aaab3a6df6279d922379a66cd3b6)) |
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 |
---|---|---|
|
@@ -44,4 +44,4 @@ | |
"devDependencies": { | ||
"prettier": "^2.5.1" | ||
} | ||
} | ||
} |
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,6 +1,7 @@ | ||
const nftCollectionSnippets = require('../snippets/nft-collection.json') | ||
const tokenSnippets = require('../snippets/token.json') | ||
const nftCollectionSnippets = require("../snippets/nft-collection.json"); | ||
const tokenSnippets = require("../snippets/token.json"); | ||
|
||
var totalSnippets = Object.keys(nftCollectionSnippets).length + Object.keys(tokenSnippets).length | ||
var totalSnippets = | ||
Object.keys(nftCollectionSnippets).length + Object.keys(tokenSnippets).length; | ||
|
||
console.log(totalSnippets) | ||
console.log(totalSnippets); |
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 |
---|---|---|
|
@@ -585,4 +585,4 @@ | |
], | ||
"description": "Unwrap a NFT" | ||
} | ||
} | ||
} |
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,187 @@ | ||
{ | ||
"Initialize the Vote module": { | ||
"prefix": "initVote", | ||
"body": [ | ||
"const voteAddress = \"${1:module_addr}\";", | ||
"", | ||
"const vote = sdk.getVoteModule(voteAddress);" | ||
], | ||
"description": "Initialize the Vote module" | ||
}, | ||
"Get the balance of the project wallet in the native token of the chain": { | ||
"prefix": "getBalanceChain", | ||
"body": [ | ||
"const getBalance = async () => {", | ||
" try {", | ||
" await vote.balance();", | ||
" } catch (error) {", | ||
" console.log(error);", | ||
" }", | ||
"};", | ||
"", | ||
"getBalance();" | ||
], | ||
"description": "Get the balance of the project wallet in the native token of the chain" | ||
}, | ||
"Get the balance of the project wallet in a particular ERC20 token contract": { | ||
"prefix": "getBalanceERC20", | ||
"body": [ | ||
"const getBalanceOfToken = async (tokenAddress) => {", | ||
" try {", | ||
" await vote.balanceOfToken(tokenAddress);", | ||
" } catch (error) {", | ||
" console.log(error);", | ||
" }", | ||
"};", | ||
"", | ||
"getBalanceOfToken('${1:token_addr}')" | ||
], | ||
"description": "Get the balance of the project wallet in a particular ERC20 token contract" | ||
}, | ||
"Can execute a proposal": { | ||
"prefix": "canExecute", | ||
"body": [ | ||
"const canExecuteProposal = async (proposalId) => {", | ||
" try {", | ||
" await vote.canExecute(proposalId);", | ||
" } catch (error) {", | ||
" console.log(error);", | ||
" }", | ||
"};", | ||
"", | ||
"canExecuteProposal('${1:proposal_id}')" | ||
], | ||
"description": "Can execute a proposal" | ||
}, | ||
"Execute a Proposal": { | ||
"prefix": "executeProposal", | ||
"body": [ | ||
"const executeProposal = async (proposalId) => {", | ||
" try {", | ||
" await vote.execute(proposalId);", | ||
" } catch (error) {", | ||
" console.log(error);", | ||
" }", | ||
"};", | ||
"", | ||
"executeProposal('${1:proposal_id}');" | ||
], | ||
"description": "Execute a Proposal" | ||
}, | ||
"Get proposal by Proposal Id": { | ||
"prefix": "getProposal", | ||
"body": [ | ||
"const getProposal = async (proposalId) => {", | ||
" try {", | ||
" await vote.get(proposalId);", | ||
" } catch (error) {", | ||
" console.log(error);", | ||
" }", | ||
"};", | ||
"", | ||
"getProposal('${1:proposal_id}');" | ||
], | ||
"description": "Get proposal by Proposal Id" | ||
}, | ||
"Get all the Proposals": { | ||
"prefix": "getProposals", | ||
"body": [ | ||
"const getAllProposals = async () => {", | ||
" try {", | ||
" await vote.getAll();", | ||
" } catch (error) {", | ||
" console.log(error);", | ||
" }", | ||
"};", | ||
"", | ||
"getAllProposals();" | ||
], | ||
"description": "Get all the Proposals" | ||
}, | ||
"Check if an account has voted for a proposal": { | ||
"prefix": "checkProposalAccStatus", | ||
"body": [ | ||
"const hasVotedForProposal = async (proposalId, walletAddress) => {", | ||
" try {", | ||
" await vote.hasVoted(proposalId, walletAddress);", | ||
" } catch (error) {", | ||
" console.log(error);", | ||
" }", | ||
"};", | ||
"", | ||
"hasVotedForProposal('${1:proposal_id}', '${1:wallet_addr}');" | ||
], | ||
"description": "Check if an account has voted for a proposal" | ||
}, | ||
"Create a Proposal": { | ||
"prefix": "createProposal", | ||
"body": [ | ||
"const createProposal = async (description, executions) => {", | ||
" try {", | ||
" await vote.propose(description, executions);", | ||
" } catch (error) {", | ||
" console.log(error);", | ||
" }", | ||
"};", | ||
"", | ||
"createProposal('${1:desc}', [", | ||
" toAddress: \"${1:wallet_addr}\",", | ||
" nativeTokenValue: 0,", | ||
" transactionData: tokenModule.contract.interface.encodeFunctionData(", | ||
" \"transfer\",", | ||
" [\"${1:from_wallet_addr}\", \"${1:amount}\"]", | ||
" )", | ||
"]);" | ||
], | ||
"description": "Create a Proposal" | ||
}, | ||
"Set metadata for the module": { | ||
"prefix": "setMetadataModule", | ||
"body": [ | ||
"const setModuleMetadata = async (metadata) => {", | ||
" try {", | ||
" await vote.setModuleMetadata(metadata);", | ||
" } catch (error) {", | ||
" console.log(error);", | ||
" }", | ||
"};", | ||
"", | ||
"setModuleMetadata({", | ||
" name: '${1:name}',", | ||
" description: '${1:desc}',", | ||
" image: '${1:image_link}'", | ||
"});" | ||
], | ||
"description": "Set metadata for the module" | ||
}, | ||
"Get the settings": { | ||
"prefix": "getSettings", | ||
"body": [ | ||
"const getSettings = async () => {", | ||
" try {", | ||
" await vote.settings();", | ||
" } catch (error) {", | ||
" console.log(error);", | ||
" }", | ||
"};", | ||
"", | ||
"getSettings();" | ||
], | ||
"description": "Get the settings" | ||
}, | ||
"Vote for a proposal": { | ||
"prefix": "voteProposal", | ||
"body": [ | ||
"const voteForProposal = async (proposalId, voteType, reason) => {", | ||
" try {", | ||
" await vote.vote(proposalId, vote, reason);", | ||
" } catch (error) {", | ||
" console.log(error);", | ||
" }", | ||
"};", | ||
"", | ||
"voteForProposal('${1:proposal_id}', '${1:vote_type}', '${1:reason}');" | ||
], | ||
"description": "Vote for a proposal" | ||
} | ||
} |