Skip to content

Commit

Permalink
feat: ✨ placeholder support for token snippets (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xMukesh committed Mar 13, 2022
1 parent 4e57c8d commit 87ab37e
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 52 deletions.
6 changes: 6 additions & 0 deletions scripts/readme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const nftCollectionSnippets = require('../snippets/nft-collection.json')
const tokenSnippets = require('../snippets/token.json')

var totalSnippets = Object.keys(nftCollectionSnippets).length + Object.keys(tokenSnippets).length

console.log(totalSnippets)
100 changes: 48 additions & 52 deletions snippets/token.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"tokenBalance": {
"Get the balance of a token": {
"prefix": "tokenBalance",
"body": [
"const balance = async () => {",
Expand All @@ -14,7 +14,7 @@
],
"description": "Get the balance of a token"
},
"tokenBalanceOf": {
"Get the balance of a token for a specific address": {
"prefix": "tokenBalanceOf",
"body": [
"const balanceOf = async (address) => {",
Expand All @@ -25,11 +25,11 @@
" }",
"};",
"",
"balanceOf(\"<SPENDER_ADDRESS>\");"
"balanceOf(\"${1:<SPENDER_ADDRESS>}\");"
],
"description": "Get the balance of a token for a specific address"
},
"tokenBurn": {
"Burn tokens owned by the owner": {
"prefix": "tokenBurn",
"body": [
"const burn = async (amount) => {",
Expand All @@ -40,11 +40,11 @@
" } ",
"};",
"",
"burn('<AMOUNT_TO_BURN>');"
"burn('${1:<AMOUNT_TO_BURN>}');"
],
"description": "Burn tokens owned by the owner"
},
"tokenBurnFrom": {
"Burn tokens owned by a specific address": {
"prefix": "tokenBurnFrom",
"body": [
"const burnFrom = async (from, amount) => {",
Expand All @@ -55,11 +55,11 @@
" }",
"};",
"",
"burnFrom(\"<SPENDER_ADDRESS>\", '<AMOUNT_TO_BURN>');"
"burnFrom(\"${1:<SPENDER_ADDRESS>}\", \"${2:<AMOUNT_TO_BURN>}\");"
],
"description": "Burn tokens owned by a specific address"
},
"tokenGet": {
"Get details about a token module": {
"prefix": "tokenGet",
"body": [
"const get = async () => {",
Expand All @@ -74,7 +74,7 @@
],
"description": "Get details about a token module"
},
"tokenGetAllHolderBalances": {
"Get all the balances of all holders": {
"prefix": "tokenGetAllHolderBalances",
"body": [
"const getAllHolderBalances = async () => {",
Expand All @@ -89,7 +89,7 @@
],
"description": "Get all the balances of all holders"
},
"tokenGetDelegation": {
"Get the delegation of a token": {
"prefix": "tokenGetDelegation",
"body": [
"const getDelegation = async () => { ",
Expand All @@ -104,7 +104,7 @@
],
"description": "Get the delegation of a token"
},
"tokenGetDelegationOf": {
"Get the delegation of a token for a specific address": {
"prefix": "tokenGetDelegationOf",
"body": [
"const getDelegationOf = async (account) => { ",
Expand All @@ -115,12 +115,12 @@
" }",
" };",
" ",
"getDelegationOf(\"<SPENDER_ADDRESS>\");"
"getDelegationOf(\"${1:<SPENDER_ADDRESS>}\");"
],
"description": "Get the delegation of a token for a specific address"
},
"tokengetValue": {
"prefix": "tokengetValue",
"Get the value for the specified amount of a token": {
"prefix": "tokenGetValue",
"body": [
"const getValue = async (value) => {",
" try {",
Expand All @@ -130,11 +130,11 @@
" }",
"};",
"",
"getValue('<VALUE>');"
"getValue('${1:<VALUE>}');"
],
"description": "Get the value for the specified amount of a token"
},
"getVoteBalance": {
"Get information of the vote balance for yourself": {
"prefix": "getVoteBalance",
"body": [
"const getVoteBalance = async () => {",
Expand All @@ -149,7 +149,7 @@
],
"description": "Get information of the vote balance for yourself"
},
"getVoteBalanceOf": {
"Get information about the vote balance for the specified address": {
"prefix": "getVoteBalanceOf",
"body": [
"const getVoteBalanceOf = async (account) => { ",
Expand All @@ -160,12 +160,12 @@
" }",
"};",
"",
"getVoteBalanceOf(\"<SPENDER_ADDRESS>\");"
"getVoteBalanceOf(\"${1:<SPENDER_ADDRESS>}\");"
],
"description": "Get information about the vote balance for the specified address"
},
"mintToken": {
"prefix": "mintToken",
"Mint specific amount of tokens": {
"prefix": "tokenMint",
"body": [
"const mint = async (amount) => { ",
" try { ",
Expand All @@ -175,11 +175,11 @@
" }",
"};",
"",
"mint('<AMOUNT_TO_MINT>');"
"mint('${1:<AMOUNT_TO_MINT>}');"
],
"description": "Mint specific amount of tokens"
},
"tokenMintBatchTo": {
"Mint specific amount of tokens to multiple addresses in a batch": {
"prefix": "tokenMintBatchTo",
"body": [
"const mintBatchTo = async (batchTo) => { ",
Expand All @@ -192,21 +192,20 @@
"",
"const example = [",
" {",
" address: \"<SPENDER_ADDRESS>\",",
" amount: ethers.utils.parseEther(\"1\")",
" address: \"${1:<SPENDER_ADDRESS>}\",",
" amount: ethers.utils.parseEther(\"${2:1}\")",
" },",
" {",
" address: \"<SPENDER_ADDRESS_2>\",",
" amount: ethers.utils.parseEther(\"5\")",
" address: \"${3:<SPENDER_ADDRESS_2>}\",",
" amount: ethers.utils.parseEther(\"${4:5}\")",
" }",
"]",
"",
"",
"mintBatchTo(example);"
],
"description": "Mint specific amount of tokens to multiple addresses in a batch"
},
"tokenMintTo": {
"Mint specific amount of tokens to a specific address": {
"prefix": "tokenMintTo",
"body": [
"const mintTo = async (to, amount) => { ",
Expand All @@ -216,12 +215,12 @@
" console.log('Failed to mint to. Error: ', error);",
" }",
"};",
"",
"mintTo(\"<SPENDER_ADDRESS>\", ethers.utils.parseEther(\"1\"));"
"// mint a specified amount to a specific address",
"mintTo(\"${1:<SPENDER_ADDRESS>}\", ethers.utils.parseEther(\"${2:1}\"));"
],
"description": "Mint specific amount of tokens to a specific address"
},
"tokenTotalSupply": {
"Get the total supply of a token module": {
"prefix": "tokenTotalSupply",
"body": [
"const totalSupply = async () => { ",
Expand All @@ -236,7 +235,7 @@
],
"description": "Get the total supply of a token module"
},
"tokenTransfer": {
"Transfer specific amount of tokens to a specific address": {
"prefix": "tokenTransfer",
"body": [
"const transfer = async (to, amount) => { ",
Expand All @@ -246,12 +245,12 @@
" console.log('Failed to transfer. Error: ', error);",
" }",
"};",
"",
"transfer(\"<SPENDER_ADDRESS>\", '<AMOUNT_TO_TRANSFER>');"
" ",
"transfer(\"${1:<SPENDER_ADDRESS>}\", \"${2:<AMOUNT_TO_TRANSFER>}\");"
],
"description": "Transfer specific amount of tokens to a specific address"
},
"tokenTransferBatch": {
"Transfer specific amounts of tokens to multiple addresses in a batch": {
"prefix": "tokenTransferBatch",
"body": [
"const transferBatch = async (batch) => { ",
Expand All @@ -264,21 +263,20 @@
"",
"const example = [",
" {",
" address: \"<SPENDER_ADDRESS>\",",
" amount: ethers.utils.parseEther(\"2\")",
" address: \"${1:<SPENDER_ADDRESS>}\",",
" amount: ethers.utils.parseEther(\"${2:2}\")",
" },",
" {",
" address: \"<SPENDER_ADDRESS_2>\",",
" amount: ethers.utils.parseEt(\"1\")",
" address: \"${3:<SPENDER_ADDRESS_2>}\",",
" amount: ethers.utils.parseEt(\"${4:1}\")",
" }",
"]",
"",
"",
" ",
"transferBatch(example);"
],
"description": "Transfer specific amounts of tokens to multiple addresses in a batch"
},
"tokenTransferFrom": {
"Transfer specific amount of tokens from an address to another address": {
"prefix": "tokenTransferFrom",
"body": [
"const transferFrom = async (from, to, amount) => { ",
Expand All @@ -289,11 +287,11 @@
" }",
"};",
"",
"transferFrom(\"<SPENDER_ADDRESS>\", \"<SPENDER_ADDRESS_2>\", '<AMOUNT_TO_TRANSFER>');"
"transferFrom(\"${1:<SPENDER_ADDRESS>}\", \"${2:<SPENDER_ADDRESS_2>}\", \"${3:<AMOUNT_TO_TRANSFER>}\");"
],
"description": "Transfer specific amount of tokens from an address to another address"
},
"tokenTransferFromBatch": {
"Transfer specific amounts of tokens from multiple addresses to another addresses in a batch": {
"prefix": "tokenTransferFromBatch",
"body": [
"const transferFromBatch = async (batch) => { ",
Expand All @@ -306,19 +304,17 @@
"",
"const example = [",
" {",
" address: \"<TO_ADDRESS>\",",
" amount: ethers.utils.parseEther(\"1\"),",
" fromAddress: \"<FROM_ADDRESS>\"",
" address: \"${1:<TO_ADDRESS>}\",",
" amount: ethers.utils.parseEther(\"${2:1}\"),",
" fromAddress: \"${3:<FROM_ADDRESS>}\"",
" },",
" {",
" address: \"<TO_ADDRESS>\",",
" amount: ethers.utils.parseEther(\"1\"),",
" fromAddress: \"<FROM_ADDRESS>\"",
" address: \"${4:<TO_ADDRESS>}\",",
" amount: ethers.utils.parseEther(\"${5:1}\"),",
" fromAddress: \"${6:<FROM_ADDRESS>}\"",
" }",
"]",
"",
"",
"",
"transferFromBatch(example);"
],
"description": "Transfer specific amounts of tokens from multiple addresses to another addresses in a batch"
Expand Down

0 comments on commit 87ab37e

Please sign in to comment.