-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60596a4
commit b532f2f
Showing
11 changed files
with
184 additions
and
5 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,4 @@ | ||
npm-debug.log | ||
lib/ | ||
tmp/ | ||
./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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"name": "@helium/modular-governance-hooks", | ||
"private": false, | ||
"publishConfig": { | ||
"access": "public", | ||
"registry": "https://registry.npmjs.org/" | ||
}, | ||
"license": "Apache-2.0", | ||
"version": "0.0.1", | ||
"description": "React hooks for modular governance", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/helium/modular-governance" | ||
}, | ||
"main": "./lib/cjs/index.js", | ||
"module": "./lib/esm/src/index.js", | ||
"types": "./lib/types/src/index.d.ts", | ||
"sideEffects": false, | ||
"files": [ | ||
"lib" | ||
], | ||
"exports": { | ||
"import": "./lib/esm/src/index.js", | ||
"require": "./lib/cjs/index.js", | ||
"types": "./lib/types/src/index.d.ts" | ||
}, | ||
"scripts": { | ||
"format": "prettier --write \"src/**/*.{ts,tsx}\"", | ||
"precommit": "npx git-format-staged -f 'prettier --ignore-unknown --stdin --stdin-filepath \"{}\"' .", | ||
"clean": "npx shx mkdir -p lib && npx shx rm -rf lib", | ||
"package": "npx shx mkdir -p lib/cjs lib/esm", | ||
"prebuild": "npm run clean && npm run package" | ||
}, | ||
"dependencies": { | ||
"@coral-xyz/anchor": "^0.26.0", | ||
"@helium/account-fetch-cache": "^0.2.5", | ||
"@helium/account-fetch-cache-hooks": "^0.2.5", | ||
"@helium/helium-react-hooks": "^0.2.5", | ||
"@helium/modular-governance-idls": "^0.0.1", | ||
"@helium/organization-sdk": "^0.0.1", | ||
"@solana/web3.js": "^1.66.2" | ||
}, | ||
"devDependencies": { | ||
"git-format-staged": "^2.1.3", | ||
"ts-loader": "^9.2.3", | ||
"typescript": "^4.3.4", | ||
"yarn": "^1.22.18", | ||
"react": "^18" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.8 || ^17 || ^18", | ||
"react-dom": "^16.8 || ^17 || ^18" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"gitHead": "5a8bf0b7b88e5934ef8d774e686f7c95804fbb8d" | ||
} |
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,41 @@ | ||
import { PublicKey } from "@solana/web3.js"; | ||
import { | ||
useAnchorAccount, | ||
useAnchorAccounts, | ||
} from "@helium/helium-react-hooks"; | ||
import { Proposal } from "@helium/modular-governance-idls/lib/types/proposal"; | ||
import { Organization } from "@helium/modular-governance-idls/lib/types/organization"; | ||
import { StateController } from "@helium/modular-governance-idls/lib/types/state_controller"; | ||
import { proposalKey } from "@helium/organization-sdk"; | ||
import { useMemo } from "react"; | ||
|
||
export const useProposalConfig = (key: PublicKey | undefined) => | ||
useAnchorAccount<Proposal, "proposalConfigV0">(key, "proposalConfigV0"); | ||
|
||
export const useProposal = (key: PublicKey | undefined) => | ||
useAnchorAccount<Proposal, "proposalV0">(key, "proposalV0"); | ||
|
||
export const useOrganization = (key: PublicKey | undefined) => | ||
useAnchorAccount<Organization, "organizationV0">(key, "organizationV0"); | ||
|
||
export const useResolutionSettings = (key: PublicKey | undefined) => | ||
useAnchorAccount<StateController, "resolutionSettingsV0">( | ||
key, | ||
"resolutionSettingsV0" | ||
); | ||
|
||
export const useOrganizationProposals = ( | ||
organizationKey: PublicKey | undefined | ||
) => { | ||
const { info: organization } = useOrganization(organizationKey); | ||
|
||
const proposalKeys = useMemo( | ||
() => | ||
Array(organization?.numProposals) | ||
.fill(0) | ||
.map((_, index) => proposalKey(organizationKey, index)[0]) | ||
.reverse(), | ||
[organization?.numProposals] | ||
); | ||
return useAnchorAccounts<Proposal, "proposalV0">(proposalKeys, "proposalV0"); | ||
}; |
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,8 @@ | ||
{ | ||
"extends": "../../tsconfig.cjs.json", | ||
"include": ["src"], | ||
"compilerOptions": { | ||
"outDir": "lib/cjs", | ||
"jsx": "react" | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"extends": "../../tsconfig.esm.json", | ||
"include": ["src"], | ||
"compilerOptions": { | ||
"outDir": "lib/esm", | ||
"declarationDir": "lib/types", | ||
"jsx": "react" | ||
} | ||
} |
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,17 @@ | ||
{ | ||
"extends": "../../tsconfig.root.json", | ||
"references": [ | ||
{ | ||
"path": "../modular-governance-idls" | ||
}, | ||
{ | ||
"path": "../organization-sdk" | ||
}, | ||
{ | ||
"path": "./tsconfig.cjs.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.esm.json" | ||
} | ||
] | ||
} |
2 changes: 1 addition & 1 deletion
2
packages/modular-governance-idls/packages/modular-governance-idls/tsconfig.esm.tsbuildinfo
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -467,6 +467,15 @@ | |
resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6" | ||
integrity sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw== | ||
|
||
"@helium/account-fetch-cache-hooks@^0.2.5": | ||
version "0.2.5" | ||
resolved "https://registry.yarnpkg.com/@helium/account-fetch-cache-hooks/-/account-fetch-cache-hooks-0.2.5.tgz#5aac3d67bb270dafa62fa0130e3a690988ccb7ce" | ||
integrity sha512-g62sclkcM1oUGqlGYB4JMZhZVeDSE1oMsJ4W4CP4yGbsTnKxfCJv4/l7VaCOPQa3pvEUlc5J9MtcKJL5BDBbVw== | ||
dependencies: | ||
"@helium/account-fetch-cache" "^0.2.5" | ||
"@solana/web3.js" "^1.66.2" | ||
react-async-hook "^4.0.0" | ||
|
||
"@helium/account-fetch-cache@^0.2.5": | ||
version "0.2.5" | ||
resolved "https://registry.yarnpkg.com/@helium/account-fetch-cache/-/account-fetch-cache-0.2.5.tgz#518e945abd51bad1811ff0b4b5c80d62ebafdb6f" | ||
|
@@ -491,6 +500,19 @@ | |
"@solana/spl-token" "^0.3.6" | ||
"@solana/web3.js" "^1.43.4" | ||
|
||
"@helium/helium-react-hooks@^0.2.5": | ||
version "0.2.5" | ||
resolved "https://registry.yarnpkg.com/@helium/helium-react-hooks/-/helium-react-hooks-0.2.5.tgz#ad1119c1a05e6476265ee04b12390fc952a02e94" | ||
integrity sha512-nGQzs34HHoVn/xIzqPTbJVy0/gomEKPQQRDUjrFDf/wXHPYGyAARuVut1JZTEwknr4kF+PQs7uNbo0u9Jlr7SQ== | ||
dependencies: | ||
"@coral-xyz/anchor" "^0.26.0" | ||
"@helium/account-fetch-cache" "^0.2.5" | ||
"@helium/account-fetch-cache-hooks" "^0.2.5" | ||
"@solana/spl-token" "^0.3.6" | ||
"@solana/web3.js" "^1.66.2" | ||
bs58 "^5.0.0" | ||
react-async-hook "^4.0.0" | ||
|
||
"@helium/spl-utils@^0.2.6": | ||
version "0.2.6" | ||
resolved "https://registry.yarnpkg.com/@helium/spl-utils/-/spl-utils-0.2.6.tgz#20b136f13d9e1d58e7032b4c55b5cc0c1ad9f6dc" | ||
|
@@ -4215,7 +4237,7 @@ js-sha512@^0.8.0: | |
resolved "https://registry.yarnpkg.com/js-sha512/-/js-sha512-0.8.0.tgz#dd22db8d02756faccf19f218e3ed61ec8249f7d4" | ||
integrity sha512-PWsmefG6Jkodqt+ePTvBZCSMFgN7Clckjd0O7su3I0+BW2QWUTJNzjktHsztGLhncP2h8mcF9V9Y2Ha59pAViQ== | ||
|
||
js-tokens@^4.0.0: | ||
"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" | ||
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== | ||
|
@@ -4447,6 +4469,13 @@ [email protected], log-symbols@^4.1.0: | |
chalk "^4.1.0" | ||
is-unicode-supported "^0.1.0" | ||
|
||
loose-envify@^1.1.0: | ||
version "1.4.0" | ||
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" | ||
integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q== | ||
dependencies: | ||
js-tokens "^3.0.0 || ^4.0.0" | ||
|
||
loupe@^2.3.1: | ||
version "2.3.6" | ||
resolved "https://registry.yarnpkg.com/loupe/-/loupe-2.3.6.tgz#76e4af498103c532d1ecc9be102036a21f787b53" | ||
|
@@ -5561,6 +5590,18 @@ randombytes@^2.0.1, randombytes@^2.1.0: | |
dependencies: | ||
safe-buffer "^5.1.0" | ||
|
||
react-async-hook@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/react-async-hook/-/react-async-hook-4.0.0.tgz#1f0467586654e1f33b7433bd98c300a0c5f9b3d0" | ||
integrity sha512-97lgjFkOcHCTYSrsKBpsXg3iVWM0LnzedB749iP76sb3/8Ouu4nHIkCLEOrQWHVYqrYxjF05NN6GHoXWFkB3Kw== | ||
|
||
react@^18: | ||
version "18.2.0" | ||
resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5" | ||
integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ== | ||
dependencies: | ||
loose-envify "^1.1.0" | ||
|
||
read-cmd-shim@^3.0.0: | ||
version "3.0.1" | ||
resolved "https://registry.yarnpkg.com/read-cmd-shim/-/read-cmd-shim-3.0.1.tgz#868c235ec59d1de2db69e11aec885bc095aea087" | ||
|
@@ -6401,7 +6442,7 @@ typescript-collections@^1.3.3: | |
resolved "https://registry.yarnpkg.com/typescript-collections/-/typescript-collections-1.3.3.tgz#62d50d93c018c094d425eabee649f00ec5cc0fea" | ||
integrity sha512-7sI4e/bZijOzyURng88oOFZCISQPTHozfE2sUu5AviFYk5QV7fYGb6YiDl+vKjF/pICA354JImBImL9XJWUvdQ== | ||
|
||
"typescript@^3 || ^4", typescript@^4.3.5: | ||
"typescript@^3 || ^4", typescript@^4.3.4, typescript@^4.3.5: | ||
version "4.9.5" | ||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" | ||
integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== | ||
|