-
Notifications
You must be signed in to change notification settings - Fork 6
Sub vaults #339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Sub vaults #339
Changes from 20 commits
5a384b5
bd89745
d293448
dff7431
f5adb5a
7a0692b
3c09390
2e92cdd
661401a
39241b9
78a39c1
94d3b4b
047ee99
4abc61d
5b52db2
bceb1cd
e904379
e4b1cf8
42a9bd7
b873d54
e3c6dc2
01b26e7
d9a66b5
2032bee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| sh ./scripts/pre-push.sh | ||
|
|
||
| npm run lint | ||
| pnpm run check:docLinks | ||
| pnpm run lint | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| ## Added methods | ||
|
|
||
| - [sdk.vault.getSubVaults](https://docs.stakewise.io/sdk/api/vault/requests/getsubvaults) | ||
| - [sdk.vault.addSubVault](https://docs.stakewise.io/sdk/api/vault/transactions/addsubvault) | ||
| - [sdk.vault.rejectSubVault](https://docs.stakewise.io/sdk/api/vault/transactions/rejectsubvault) | ||
| - [sdk.vault.ejectSubVault](https://docs.stakewise.io/sdk/api/vault/transactions/ejectsubvault) | ||
| - [sdk.vault.updateState](https://docs.stakewise.io/sdk/api/vault/transactions/updatestate) | ||
|
|
||
| ## Modified methods | ||
|
|
||
| ### 1. [sdk.vault.getVault](https://docs.stakewise.io/sdk/api/vault/requests/getvault) | ||
|
|
||
| #### Add output field: | ||
| ```ts | ||
| type Output = { | ||
| canHarvest: boolean | ||
| exitingAssets: string | ||
| exitingTickets: string | ||
| ejectingSubVault: string | ||
| subVaultsRegistry: string | ||
| pendingMetaSubVault: string | ||
| } | ||
| ``` |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,8 +2,8 @@ import type { CodegenConfig } from '@graphql-codegen/cli' | |||||||||||||||
| import { Network } from './src/helpers/enums' | ||||||||||||||||
| import configs from './src/helpers/configs' | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| let network: Network = Network.Mainnet | ||||||||||||||||
| // TODO change | ||||||||||||||||
| let network: Network = Network.Hoodi | ||||||||||||||||
|
Comment on lines
+5
to
+6
|
||||||||||||||||
| // TODO change | |
| let network: Network = Network.Hoodi | |
| let network: Network = Network.Mainnet |
Copilot
AI
Apr 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the default codegen network from Mainnet to Hoodi (and leaving a TODO) can silently generate the wrong GraphQL types/operations when NETWORK is not set (e.g., local dev, CI scripts). Consider restoring Mainnet as the default and making Hoodi opt-in via env/config, or fail fast when NETWORK is missing to avoid accidental wrong builds.
| // TODO change | |
| let network: Network = Network.Hoodi | |
| let network: Network = Network.Mainnet | |
| if (process.env.NETWORK === 'hoodi') { | |
| network = Network.Hoodi | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "label": "Quick Start" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| import path from 'path' | ||
| import https from 'https' | ||
| import { fileURLToPath } from 'url' | ||
| import { execSync } from 'child_process' | ||
|
|
||
|
|
||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)) | ||
|
|
||
| // eslint-disable-next-line no-restricted-syntax | ||
| const docsUrl = 'https://docs.stakewise.io' | ||
|
|
||
| const srcDir = path.resolve(__dirname, '../src') | ||
|
|
||
| const fetchSitemap = () => { | ||
| const sitemapUrl = `${docsUrl}/sitemap.xml` | ||
|
|
||
| return new Promise((resolve, reject) => { | ||
| https | ||
| .get(sitemapUrl, (res) => { | ||
| let data = '' | ||
|
|
||
| res.on('data', (chunk) => data += chunk) | ||
| res.on('end', () => { | ||
| const matches = data.match(/<loc>([^<]+)/g) || [] | ||
|
|
||
| const urls = matches.map((match) => { | ||
| return match | ||
| .replace('<loc>', '') | ||
| .replace(/\/$/, '') | ||
| .toLowerCase() | ||
| }) | ||
|
|
||
| resolve(urls) | ||
| }) | ||
| }) | ||
| .on('error', reject) | ||
| }) | ||
| } | ||
|
|
||
| const getSdkApiSlugs = () => { | ||
| try { | ||
| const output = execSync( | ||
| `grep -r "^slug:" "${srcDir}" --include="*.md"`, | ||
| { encoding: 'utf-8' } | ||
| ) | ||
|
Comment on lines
+42
to
+45
|
||
|
|
||
| const slugs = output | ||
| .split('\n') | ||
| .filter(Boolean) | ||
| .map((line) => line.replace(/.*slug:\s*/, '').trim().replace(/\/$/, '').toLowerCase()) | ||
|
|
||
| const brokenSlugs = slugs.filter((slug) => !slug.startsWith('/')) | ||
|
|
||
| if (brokenSlugs.length) { | ||
| console.log('🚫 Slugs must start with /:') | ||
| brokenSlugs.forEach((slug) => console.log(`${slug}`)) | ||
| process.exit(1) | ||
| } | ||
|
|
||
| return slugs.filter((slug) => slug.startsWith('/sdk/api/')) | ||
| } | ||
| catch { | ||
| return [] | ||
| } | ||
| } | ||
|
|
||
| const getUrls = () => { | ||
| const rootDir = path.resolve(__dirname, '..') | ||
|
|
||
| try { | ||
| const output = execSync( | ||
| `grep -roh "https://docs\\.stakewise\\.io/[^\\"' )\\\`>]*" "${rootDir}" ` | ||
| + '--include="*.ts" --include="*.tsx" --include="*.md" --include="*.mdx" ' | ||
| + '--exclude-dir=node_modules', | ||
| { encoding: 'utf-8' } | ||
| ) | ||
|
Comment on lines
+71
to
+76
|
||
|
|
||
| return [ ...new Set( | ||
| output | ||
| .split('\n') | ||
| .map((url) => url.replace(/[.,;)]+$/, '')) | ||
| .filter((url) => url && url !== docsUrl && url !== `${docsUrl}/`) | ||
| )] | ||
| } | ||
| catch { | ||
| return [] | ||
| } | ||
| } | ||
|
|
||
| const checkDocLinks = async () => { | ||
| const urls = getUrls() | ||
|
|
||
| if (!urls.length) { | ||
| console.log('No docs links found.') | ||
|
|
||
| return | ||
| } | ||
|
|
||
| const slugs = getSdkApiSlugs() | ||
| const broken = [] | ||
|
|
||
| let sitemap = null | ||
|
|
||
| for (const url of urls) { | ||
| const urlPath = url.replace(docsUrl, '').replace(/[#?].*$/, '').replace(/\/$/, '').toLowerCase() | ||
|
|
||
| if (slugs.includes(urlPath)) { | ||
| continue | ||
| } | ||
|
|
||
| // Not found in local slugs — check against live sitemap | ||
| if (!sitemap) { | ||
| sitemap = await fetchSitemap() | ||
| } | ||
|
|
||
| if (!sitemap.includes(`${docsUrl}${urlPath}`)) { | ||
| broken.push(url) | ||
| } | ||
| } | ||
|
|
||
| if (broken.length) { | ||
| broken.forEach((url) => console.log(url)) | ||
| console.log(`\n🚫 Found ${broken.length} broken link(s)!`) | ||
| process.exit(1) | ||
| } | ||
|
|
||
| console.log('✅ All docs links are valid.') | ||
|
|
||
| // Warn if staged md files were changed | ||
| try { | ||
| const stagedMd = execSync('git diff --cached --name-only -- "src/**/*.md" "documentation/**/*.md"', { encoding: 'utf-8' }).trim() | ||
|
|
||
| if (stagedMd) { | ||
| const warn = (text) => console.log(`\x1b[33m${text}\x1b[0m`) | ||
|
|
||
| console.log() | ||
| warn('⚠️SDK docs were changed! ⚠️') | ||
| warn("Don't forget to run: pnpm sync:docs") | ||
| } | ||
| } | ||
| catch {} | ||
| } | ||
|
|
||
| checkDocLinks() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check:docLinksfetches the live docs sitemap over the network; running this in a pre-commit hook can be slow and may fail for contributors who are offline or behind restrictive networks. Consider moving it to CI (pre-push or workflow) or adding an opt-out (e.g., env flag) so local commits don’t become flaky.