-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from vechainfoundation/pre-commit-hooks
Pre commit hooks
- Loading branch information
Showing
20 changed files
with
873 additions
and
205 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
extends: ["custom/library"], | ||
}; |
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,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx --no -- commitlint --edit "$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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx --no-install lint-staged |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = { extends: ["@commitlint/config-conventional"] }; |
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 |
---|---|---|
|
@@ -10,14 +10,34 @@ | |
"format": "prettier --write \"**/*.{ts,tsx,md}\"", | ||
"lint": "turbo run lint", | ||
"build": "turbo run build", | ||
"test": "turbo run test" | ||
"test": "turbo run test", | ||
"prepare": "husky install" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/config-conventional": "^18.0.0", | ||
"commitlint": "^18.0.0", | ||
"eslint": "^8.4.1", | ||
"eslint-config-custom": "workspace:*", | ||
"eslint-plugin-prefer-arrow": "1.2.3", | ||
"husky": "^8.0.0", | ||
"lint-staged": "^15.0.2", | ||
"prettier": "^2.5.1", | ||
"tsconfig": "workspace:*", | ||
"turbo": "latest" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"lint-staged": { | ||
"*.{js,jsx,ts,tsx,json,md}": [ | ||
"prettier --write", | ||
"git add" | ||
], | ||
"*.{js,jsx,ts,tsx}": [ | ||
"eslint" | ||
] | ||
}, | ||
"packageManager": "[email protected]" | ||
} | ||
} |
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,135 +1 @@ | ||
# React Vendor | ||
|
||
## Usage | ||
|
||
- Wrap a `ConnexVendorProvider` around your application: | ||
|
||
```typescript jsx | ||
export const SampleApp: React.FC = () => { | ||
|
||
// So that we can use the genesis ID | ||
const thor = new Connex.Thor({ | ||
node: "https://mainnet.vechain.org/", | ||
network: "main", | ||
}); | ||
|
||
return ( | ||
<ConnexVendorProvider | ||
defaultWallet={{ source: "sync2" }} | ||
genesisId={thor.genesis.id} | ||
> | ||
<Account /> | ||
</ConnexVendorProvider> | ||
); | ||
}; | ||
|
||
``` | ||
|
||
- Selecting a wallet source | ||
|
||
```typescript jsx | ||
// https://docs.walletconnect.com/cloud/explorer#setting-up-a-new-project | ||
|
||
const walletConnectProjectId = "yourProjectId"; | ||
const walletConnectMetadata = "yourMetadata"; | ||
|
||
const mobileWalletOptions: MobileWalletOptions = { | ||
projectId: "yourProjectId", | ||
metadata: { | ||
name: "My dApp", | ||
description: "My dApp description", | ||
url: window.location.origin, | ||
icons: [`${window.location.origin}/images/logo/my-dapp.png`], | ||
}, | ||
}; | ||
|
||
const SelectWallet: React.FC = (): JSX.Element => { | ||
const { setWallet, wallet } = useConnexVendor(); | ||
|
||
const handleOptionChange = (event: ChangeEvent<HTMLInputElement>) => { | ||
const { value } = event.target; | ||
|
||
switch (value) { | ||
case "sync2": | ||
case "sync": { | ||
setWallet({ source: value }); | ||
break; | ||
} | ||
case "veworld-extension": { | ||
// validate the extension is installed | ||
if (!window.vechain) return; | ||
setWallet({ source: value }); | ||
break; | ||
} | ||
case "veworld-mobile": { | ||
// pass in the options for VeWorld Mobile | ||
setWallet({ source: value, options: mobileWalletOptions }); | ||
break; | ||
} | ||
} | ||
}; | ||
|
||
/** | ||
* TODO: Create a component to select the wallet | ||
* - you should disable veworld extension option if `window.vechain` is not defined | ||
*/ | ||
|
||
return ( | ||
<div> | ||
<h2>Select a Wallet</h2> | ||
<form> | ||
{/*TODO: Create a component to select the wallet*/} | ||
</form> | ||
|
||
<p>Selected Wallet: {wallet.source}</p> | ||
</div> | ||
) | ||
; | ||
} | ||
; | ||
``` | ||
|
||
- Vendor Usage: | ||
|
||
```typescript jsx | ||
const IdentifyUser: React.FC = (): JSX.Element => { | ||
const { vendor } = useConnexVendor(); | ||
|
||
const [account, setAccount] = useState<string>(); | ||
|
||
const requestSignCertificate = useCallback( | ||
async (msg: Connex.Vendor.CertMessage): Promise<string> => { | ||
const response = await vendor.sign("cert", msg).request(); | ||
|
||
//TODO: Validate signature / signer | ||
|
||
return response.annex.signer; | ||
}, | ||
[vendor] | ||
); | ||
|
||
const identifyUser = useCallback((): void => { | ||
requestSignCertificate({ | ||
purpose: "identification", | ||
payload: { | ||
type: "text", | ||
content: "Hello, VeChain!", | ||
}, | ||
}) | ||
.then(setAccount) | ||
.catch((err) => { | ||
throw err; | ||
}); | ||
}, [requestSignCertificate]); | ||
|
||
return ( | ||
<> | ||
<button onClick={identifyUser} type="button"> | ||
Identify | ||
</button> | ||
|
||
{account ? <p>Account: {account}</p> : null} | ||
</> | ||
); | ||
}; | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,5 @@ | |
"skipLibCheck": true, | ||
"strict": true | ||
}, | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} | ||
"exclude": ["node_modules"] | ||
} |
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 |
---|---|---|
|
@@ -11,4 +11,4 @@ | |
"publishConfig": { | ||
"access": "public" | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
# `wallet-connect` | ||
# `wallet-connect` |
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.