From 6e641085bc0d2f2e938a7c2d73f0d542aad0d592 Mon Sep 17 00:00:00 2001 From: leonlai257 Date: Mon, 11 Nov 2024 18:24:45 -0500 Subject: [PATCH] feat(snippets): added basic structure for a snippet extension with minimal snippets --- snippet-extension/.gitattributes | 2 ++ snippet-extension/.gitignore | 3 ++ snippet-extension/.vscode/launch.json | 17 +++++++++++ snippet-extension/.vscodeignore | 4 +++ snippet-extension/CHANGELOG.md | 9 ++++++ snippet-extension/README.md | 28 +++++++++++++++++++ snippet-extension/package.json | 24 ++++++++++++++++ .../snippets/meshsdk-txbuilder.json | 20 +++++++++++++ .../snippets/meshsdk-wallet-hooks.json | 16 +++++++++++ 9 files changed, 123 insertions(+) create mode 100644 snippet-extension/.gitattributes create mode 100644 snippet-extension/.gitignore create mode 100644 snippet-extension/.vscode/launch.json create mode 100644 snippet-extension/.vscodeignore create mode 100644 snippet-extension/CHANGELOG.md create mode 100644 snippet-extension/README.md create mode 100644 snippet-extension/package.json create mode 100644 snippet-extension/snippets/meshsdk-txbuilder.json create mode 100644 snippet-extension/snippets/meshsdk-wallet-hooks.json diff --git a/snippet-extension/.gitattributes b/snippet-extension/.gitattributes new file mode 100644 index 0000000..70e63ff --- /dev/null +++ b/snippet-extension/.gitattributes @@ -0,0 +1,2 @@ +# Set default behavior to automatically normalize line endings. +* text=auto diff --git a/snippet-extension/.gitignore b/snippet-extension/.gitignore new file mode 100644 index 0000000..cebabfc --- /dev/null +++ b/snippet-extension/.gitignore @@ -0,0 +1,3 @@ +node_modules +*.vsix +test.* \ No newline at end of file diff --git a/snippet-extension/.vscode/launch.json b/snippet-extension/.vscode/launch.json new file mode 100644 index 0000000..44a86ab --- /dev/null +++ b/snippet-extension/.vscode/launch.json @@ -0,0 +1,17 @@ +// A launch configuration that launches the extension inside a new window +// Use IntelliSense to learn about possible attributes. +// Hover to view descriptions of existing attributes. +// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Extension", + "type": "extensionHost", + "request": "launch", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}" + ] + } + ] +} diff --git a/snippet-extension/.vscodeignore b/snippet-extension/.vscodeignore new file mode 100644 index 0000000..f369b5e --- /dev/null +++ b/snippet-extension/.vscodeignore @@ -0,0 +1,4 @@ +.vscode/** +.vscode-test/** +.gitignore +vsc-extension-quickstart.md diff --git a/snippet-extension/CHANGELOG.md b/snippet-extension/CHANGELOG.md new file mode 100644 index 0000000..c2bfb55 --- /dev/null +++ b/snippet-extension/CHANGELOG.md @@ -0,0 +1,9 @@ +# Change Log + +All notable changes to the "cardano-dev-snippet" extension will be documented in this file. + +Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. + +## [Unreleased] + +- Initial release \ No newline at end of file diff --git a/snippet-extension/README.md b/snippet-extension/README.md new file mode 100644 index 0000000..79d9dfa --- /dev/null +++ b/snippet-extension/README.md @@ -0,0 +1,28 @@ +# cardano-dev-snippet + +## 🚧 Under Construction 🚧 + +## Introduction + +Snippets for Cardano Development + +## Contribution + +Add or modify the JSON files in the `snippets` folder. The file name should be the language identifier. For example, `mesh-react-hooks.json` for hooks in `@meshsdk/react`. + +## Publishing the Extension +Before publishing, make sure you have the Visual Studio Code Extension Manager installed: +```bash +npm install -g @vscode/vsce +``` + +To generate the `.vsix` file: +```bash +vsce package +``` +* You can install the extension from the `.vsix` file to test it locally. + +To publish the extension to VS Code Marketplace: +```bash +vsce publish +``` \ No newline at end of file diff --git a/snippet-extension/package.json b/snippet-extension/package.json new file mode 100644 index 0000000..0160b6d --- /dev/null +++ b/snippet-extension/package.json @@ -0,0 +1,24 @@ +{ + "name": "cardano-dev-snippet", + "displayName": "cardano-dev-snippet", + "description": "A snippet extension for cardano development", + "version": "0.0.1", + "engines": { + "vscode": "^0.10.5" + }, + "categories": [ + "Snippets" + ], + "contributes": { + "snippets": [ + { + "language": "typescript", + "path": "./snippets/meshsdk-txbuilder.json" + }, + { + "language": "typescript", + "path": "./snippets/meshsdk-wallet-hooks.json" + } + ] + } +} diff --git a/snippet-extension/snippets/meshsdk-txbuilder.json b/snippet-extension/snippets/meshsdk-txbuilder.json new file mode 100644 index 0000000..eacc813 --- /dev/null +++ b/snippet-extension/snippets/meshsdk-txbuilder.json @@ -0,0 +1,20 @@ +{ + "sendLovelace": { + "prefix": "sendLovelace", + "body": [ + "import { Transaction } from '@meshsdk/core';", + "const tx = new Transaction({ initiator: wallet }).sendLovelace('address','1000000');", + "const unsignedTx = await tx.build();", + "const signedTx = await wallet.signTx(unsignedTx);", + "const txHash = await wallet.submitTx(signedTx);" + ], + "description": "Using Mesh Tx Builder to build a transaction to send lovelace to the recipient's address" + }, + "useWalletList": { + "prefix": "walletList", + "body": [ + "const wallets = useWalletList();" + ], + "description": "useWalletList hook" + } +} diff --git a/snippet-extension/snippets/meshsdk-wallet-hooks.json b/snippet-extension/snippets/meshsdk-wallet-hooks.json new file mode 100644 index 0000000..6c6d954 --- /dev/null +++ b/snippet-extension/snippets/meshsdk-wallet-hooks.json @@ -0,0 +1,16 @@ +{ + "useWallet": { + "prefix": "useWallet", + "body": [ + "const { wallet, connected, name, connecting, connect, disconnect, error } = useWallet();" + ], + "description": "useWallet hook" + }, + "useWalletList": { + "prefix": "useWalletList", + "body": [ + "const wallets = useWalletList();" + ], + "description": "useWalletList hook" + } +}