sui.ski 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/deploy.yml +21 -0
- package/.github/workflows/publish-npm.yml +48 -0
- package/.obsidian/app.json +7 -0
- package/.obsidian/appearance.json +9 -0
- package/.obsidian/core-plugins-migration.json +14 -0
- package/.obsidian/core-plugins.json +13 -0
- package/.obsidian/daily-notes.json +5 -0
- package/.obsidian/editor.json +10 -0
- package/.obsidian/templates.json +5 -0
- package/.vault/Index.md +51 -0
- package/.vault/README.md +129 -0
- package/.vault/sdk-docs/Building-SDKs.md +361 -0
- package/.vault/sdk-docs/DApp-Kit-State.md +158 -0
- package/.vault/sdk-docs/Transaction-Executors.md +163 -0
- package/.vault/sdk-docs/Transaction-Plugins.md +216 -0
- package/.vault/templates/Daily Note Template.md +35 -0
- package/.vault/templates/Git Observation Template.md +39 -0
- package/.vault/templates/Progress Entry Template.md +40 -0
- package/AGENTS.md +52 -311
- package/CLAUDE.md +52 -292
- package/CODEBASE_GUIDE.md +4 -3
- package/PRD.md +10 -0
- package/README.md +24 -59
- package/README_MESSAGING_INTEGRATION.md +509 -0
- package/backend/Dockerfile +45 -0
- package/backend/README.md +299 -0
- package/backend/bun.lock +146 -0
- package/backend/docker-compose.yml +49 -0
- package/backend/package.json +23 -0
- package/backend/src/server.ts +527 -0
- package/backend/tsconfig.json +16 -0
- package/bun.lock +748 -0
- package/config.yaml +59 -0
- package/contracts/black_diamond/Move.lock +41 -0
- package/contracts/black_diamond/Move.toml +9 -0
- package/contracts/black_diamond/Published.toml +12 -0
- package/contracts/black_diamond/build/black_diamond/BuildInfo.yaml +25 -0
- package/contracts/black_diamond/sources/watchlist.move +57 -0
- package/contracts/bounty_escrow/Move.lock +41 -0
- package/contracts/bounty_escrow/Move.toml +8 -0
- package/contracts/bounty_escrow/Published.toml +9 -0
- package/contracts/bounty_escrow/build/bounty_escrow/BuildInfo.yaml +27 -0
- package/contracts/bounty_escrow/sources/escrow.move +389 -0
- package/contracts/bounty_escrow/sources/grace_registration.move +293 -0
- package/contracts/decay_auction/Move.lock +41 -0
- package/contracts/decay_auction/Move.toml +8 -0
- package/contracts/decay_auction/Published.toml +21 -0
- package/contracts/decay_auction/build/decay_auction/BuildInfo.yaml +27 -0
- package/contracts/decay_auction/sources/auction.move +204 -0
- package/contracts/flash_loan/sources/execution.move +41 -0
- package/contracts/jacket_factory/sources/auto_jacket.move +46 -0
- package/contracts/mvr/Move.lock +21 -0
- package/contracts/mvr/Move.toml +10 -0
- package/contracts/mvr/sources/registry.move +648 -0
- package/contracts/private/Move.lock +48 -0
- package/contracts/private/Move.toml +9 -0
- package/contracts/private/build/private/BuildInfo.yaml +78 -0
- package/contracts/private/sources/account.move +103 -0
- package/contracts/private/sources/constants.move +90 -0
- package/contracts/private/sources/errors.move +47 -0
- package/contracts/private/sources/events.move +60 -0
- package/contracts/private/sources/ext_data.move +79 -0
- package/contracts/private/sources/merkle_tree.move +151 -0
- package/contracts/private/sources/private.move +302 -0
- package/contracts/private/sources/proof.move +168 -0
- package/contracts/seal_messaging/Move.lock +56 -0
- package/contracts/seal_messaging/Move.toml +10 -0
- package/contracts/seal_messaging/build/seal_messaging/BuildInfo.yaml +78 -0
- package/contracts/seal_messaging/sources/access.move +22 -0
- package/contracts/sol_swap/Move.lock +23 -0
- package/contracts/sol_swap/Move.toml +8 -0
- package/contracts/sol_swap/build/sol_swap/BuildInfo.yaml +27 -0
- package/contracts/sol_swap/sources/pool.move +267 -0
- package/contracts/storm/Move.lock +23 -0
- package/contracts/storm/Move.toml +10 -0
- package/contracts/storm/build/storm/BuildInfo.yaml +27 -0
- package/contracts/storm/sources/registry.move +82 -0
- package/contracts/upgrade_cap_transfer/Move.lock +21 -0
- package/contracts/upgrade_cap_transfer/Move.toml +9 -0
- package/contracts/upgrade_cap_transfer/sources/transfer.move +24 -0
- package/contribute/.dev.vars.example +18 -0
- package/contribute/package.json +5 -0
- package/contribute/wrangler.toml +31 -0
- package/deploy-all.sh +16 -0
- package/docs/LIGETRON_INTEGRATION.md +279 -0
- package/docs/MESSAGING_SDK.md +403 -0
- package/docs/MVR_COMPATIBILITY.md +341 -0
- package/docs/MVR_IMPROVEMENTS.md +399 -0
- package/docs/SEAL_UPGRADE_GUIDE.md +358 -0
- package/docs/SUI_STACK_SYSTEM_DIAGRAM.md +797 -0
- package/docs/SUI_TRANSACTION_BUILDING.md +373 -0
- package/docs/Untitled.base +3 -0
- package/docs/WALLET_SESSION.md +330 -0
- package/lift/wrangler.toml +40 -0
- package/media-pack/README.md +37 -0
- package/media-pack/SuiIcon.svg +3 -0
- package/media-pack/ThunderIcon.png +0 -0
- package/media-pack/Thunderbun-ai.jpeg +0 -0
- package/media-pack/black_dotski.png +0 -0
- package/media-pack/black_dotskitxt.png +0 -0
- package/media-pack/blue_dotski.png +0 -0
- package/media-pack/blue_dotskilogo.png +0 -0
- package/media-pack/dotSKI.png +0 -0
- package/media-pack/green_dotski.png +0 -0
- package/media-pack/green_dotskilogo.png +0 -0
- package/media-pack/ski-banner-sm.webp +0 -0
- package/media-pack/ski-banner.png +0 -0
- package/media-pack/sui-ski-logo-lockup.svg +13 -0
- package/media-pack/sui-ski-logo-mark.svg +10 -0
- package/media-pack/sui-ski-logo-vertical.png +0 -0
- package/media-pack/sui-ski-logo-vertical.svg +11 -0
- package/media-pack/sui-sui-logo.png +0 -0
- package/media-pack/suiski.jpeg +0 -0
- package/media-pack/tradeport-logo-icon.png +0 -0
- package/media-pack/tradeport-logo-icon.svg +7 -0
- package/move/seal-vault/Move.lock +23 -0
- package/move/seal-vault/Move.toml +9 -0
- package/move/seal-vault/Published.toml +12 -0
- package/move/seal-vault/build/seal_vault/BuildInfo.yaml +27 -0
- package/move/seal-vault/sources/vault.move +10 -0
- package/move/seal-vault-mainnet/Move.lock +23 -0
- package/move/seal-vault-mainnet/Move.toml +9 -0
- package/move/seal-vault-mainnet/Published.toml +12 -0
- package/move/seal-vault-mainnet/build/seal_vault/BuildInfo.yaml +27 -0
- package/move/seal-vault-mainnet/sources/vault.move +10 -0
- package/package.json +9 -37
- package/playwright.config.ts +26 -0
- package/proxy/Dockerfile +19 -0
- package/proxy/README.md +85 -0
- package/proxy/api/health.ts +6 -0
- package/proxy/api/lookup.ts +60 -0
- package/proxy/api/reverse.ts +60 -0
- package/proxy/fly.toml +17 -0
- package/proxy/index.ts +191 -0
- package/proxy/package-lock.json +3763 -0
- package/proxy/package.json +21 -0
- package/proxy/protos/google/protobuf/timestamp.proto +8 -0
- package/proxy/protos/name_service.proto +35 -0
- package/proxy/render.yaml +16 -0
- package/proxy/src/index.ts +67 -0
- package/proxy/vercel.json +29 -0
- package/proxy/wrangler.jsonc +31 -0
- package/scripts/publish-npm.sh +74 -0
- package/src/handlers/grace-vault-agent.ts +328 -0
- package/src/handlers/landing.ts +443 -448
- package/src/handlers/messaging-sdk.ts +92 -0
- package/src/handlers/profile.css.ts +7113 -2151
- package/src/handlers/profile.ts +1280 -223
- package/src/handlers/register2.ts +147 -173
- package/src/handlers/ski-sign.ts +139 -89
- package/src/handlers/thunder.ts +6 -1
- package/src/handlers/x402-register.ts +1 -1
- package/src/index.ts +6 -2
- package/src/sdk/messaging.ts +47 -0
- package/src/types.ts +4 -2
- package/src/utils/grace-vault-transactions.ts +382 -0
- package/src/utils/ns-price.ts +1 -1
- package/src/utils/onchain-listing.ts +203 -0
- package/src/utils/premium.ts +2 -11
- package/src/utils/swap-transactions.ts +4 -4
- package/src/utils/thunder-js.ts +13 -25
- package/src/utils/vault.ts +32 -0
- package/src/utils/wallet-brand.ts +2 -0
- package/src/utils/wallet-kit-js.ts +1 -180
- package/src/utils/wallet-session-js.ts +4 -81
- package/src/utils/wallet-tx-js.ts +364 -940
- package/src/utils/wallet-ui-js.ts +205 -249
- package/vault/00 - Home.md +94 -0
- package/vault/Architecture/Handler System.md +52 -0
- package/vault/Architecture/Resolver System.md +48 -0
- package/vault/Architecture/Subdomain Routing.md +54 -0
- package/vault/Architecture/System Overview.md +94 -0
- package/vault/Architecture/Utility Layer.md +69 -0
- package/vault/Contracts/Contract Index.md +39 -0
- package/vault/Contracts/Deployed Contracts.md +61 -0
- package/vault/Daily/2026-02-08.md +68 -0
- package/vault/Features/Advanced Features.md +62 -0
- package/vault/Features/Content Delivery.md +41 -0
- package/vault/Features/Marketplace.md +52 -0
- package/vault/Features/Seal Messaging.md +61 -0
- package/vault/Features/SuiNS Integration.md +67 -0
- package/vault/Features/Token Economics.md +53 -0
- package/vault/Features/Wallet Infrastructure.md +62 -0
- package/vault/Features/X402 Payments.md +132 -0
- package/vault/Infrastructure/Configuration.md +80 -0
- package/vault/Infrastructure/DNS Setup.md +38 -0
- package/vault/Infrastructure/Deployment.md +59 -0
- package/vault/Progress/Backlog.md +70 -0
- package/vault/Progress/Changelog.md +94 -0
- package/vault/Progress/Current Sprint.md +45 -0
- package/vault/Reference/API Endpoints.md +46 -0
- package/vault/Reference/Dependencies.md +40 -0
- package/vault/Reference/Error Codes.md +57 -0
- package/vault/Reference/Token Decimals.md +64 -0
- package/vault/X402/X402 Architecture.md +217 -0
- package/vault/X402/X402 Coinbase Ecosystem.md +165 -0
- package/vault/X402/X402 Gap Analysis.md +135 -0
- package/vault/X402/X402 Sui-ski Implementation.md +161 -0
- package/workers/x402-multichain/package-lock.json +2785 -0
- package/workers/x402-multichain/package.json +21 -0
- package/wrangler.toml +4 -3
- package/src/handlers/authenticated-events.ts +0 -267
- package/src/utils/authenticated-events.ts +0 -280
- package/src/utils/mmr.ts +0 -181
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: Deploy
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ['*']
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
deploy:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
|
+
|
|
13
|
+
- uses: actions/setup-node@v4
|
|
14
|
+
with:
|
|
15
|
+
node-version: '22'
|
|
16
|
+
|
|
17
|
+
- run: npm install
|
|
18
|
+
|
|
19
|
+
- run: npx wrangler deploy
|
|
20
|
+
env:
|
|
21
|
+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
name: Publish npm Package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
if: github.actor != 'github-actions[bot]' && github.ref == 'refs/heads/master'
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
permissions:
|
|
13
|
+
contents: write
|
|
14
|
+
id-token: write
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
with:
|
|
18
|
+
fetch-depth: 0
|
|
19
|
+
|
|
20
|
+
- uses: actions/setup-node@v4
|
|
21
|
+
with:
|
|
22
|
+
node-version: 22
|
|
23
|
+
registry-url: https://registry.npmjs.org
|
|
24
|
+
|
|
25
|
+
- name: Configure git
|
|
26
|
+
run: |
|
|
27
|
+
git config user.name "github-actions[bot]"
|
|
28
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
29
|
+
|
|
30
|
+
- name: Bump package version
|
|
31
|
+
run: npm version patch --no-git-tag-version
|
|
32
|
+
|
|
33
|
+
- name: Read version
|
|
34
|
+
id: version
|
|
35
|
+
run: |
|
|
36
|
+
echo "value=$(npm pkg get version | tr -d '"')" >> "$GITHUB_OUTPUT"
|
|
37
|
+
|
|
38
|
+
- name: Publish to npm
|
|
39
|
+
run: npm publish --access public --provenance
|
|
40
|
+
env:
|
|
41
|
+
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
|
|
42
|
+
|
|
43
|
+
- name: Commit version bump and tag
|
|
44
|
+
run: |
|
|
45
|
+
git add package.json
|
|
46
|
+
git commit -m "chore(release): v${{ steps.version.outputs.value }} [skip ci]"
|
|
47
|
+
git tag "v${{ steps.version.outputs.value }}"
|
|
48
|
+
git push origin HEAD:master --follow-tags
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"trashOption": "system",
|
|
3
|
+
"alwaysUpdateLinks": true,
|
|
4
|
+
"newFileLocation": "folder",
|
|
5
|
+
"newFileFolderPath": ".vault",
|
|
6
|
+
"attachmentFolderPath": ".vault/assets",
|
|
7
|
+
"promptDelete": false,
|
|
8
|
+
"pdfExportSettings": {
|
|
9
|
+
"pageSize": "Letter",
|
|
10
|
+
"landscape": false,
|
|
11
|
+
"margin": "0",
|
|
12
|
+
"downscalePercent": 100
|
|
13
|
+
}
|
|
14
|
+
}
|
package/.vault/Index.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Development Index
|
|
2
|
+
|
|
3
|
+
## Quick Links
|
|
4
|
+
|
|
5
|
+
- [[README|Project Overview]]
|
|
6
|
+
- [[.vault/README|Vault Guide]]
|
|
7
|
+
- [[CODEBASE_GUIDE|Codebase Guide]]
|
|
8
|
+
- [[AGENTS|Agent Guidelines]]
|
|
9
|
+
|
|
10
|
+
## SDK Documentation
|
|
11
|
+
|
|
12
|
+
### Sui TypeScript SDK
|
|
13
|
+
- [[sdk-docs/DApp-Kit-State|DApp Kit State Management]] - Wallet connection state
|
|
14
|
+
- [[sdk-docs/Transaction-Executors|Transaction Executors]] - Serial & Parallel execution
|
|
15
|
+
- [[sdk-docs/Transaction-Plugins|Transaction Plugins]] - Plugin system & Intents
|
|
16
|
+
- [[sdk-docs/Building-SDKs|Building SDKs]] - Best practices for SDK development
|
|
17
|
+
|
|
18
|
+
## Daily Notes
|
|
19
|
+
|
|
20
|
+
```dataview
|
|
21
|
+
TABLE file.ctime as Created
|
|
22
|
+
FROM ".vault/daily-notes"
|
|
23
|
+
SORT file.name DESC
|
|
24
|
+
LIMIT 10
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Recent Progress
|
|
28
|
+
|
|
29
|
+
```dataview
|
|
30
|
+
TABLE status as Status, priority as Priority, file.mtime as Modified
|
|
31
|
+
FROM ".vault/progress"
|
|
32
|
+
SORT file.mtime DESC
|
|
33
|
+
LIMIT 10
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Recent Git Observations
|
|
37
|
+
|
|
38
|
+
```dataview
|
|
39
|
+
TABLE file.ctime as Created
|
|
40
|
+
FROM ".vault/git-observations"
|
|
41
|
+
SORT file.name DESC
|
|
42
|
+
LIMIT 10
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Active Tags
|
|
46
|
+
|
|
47
|
+
#development #git #progress #daily #observation
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
*Use this note as your dashboard. Click any link above to navigate.*
|
package/.vault/README.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Sui-ski Gateway Documentation Vault
|
|
2
|
+
|
|
3
|
+
This is an Obsidian vault for tracking development progress, git observations, and project documentation for the Sui-ski Gateway project.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
.vault/
|
|
9
|
+
├── daily-notes/ # Daily progress logs
|
|
10
|
+
├── git-observations/ # Git state snapshots
|
|
11
|
+
├── progress/ # Feature/task progress entries
|
|
12
|
+
├── templates/ # Note templates
|
|
13
|
+
├── sdk-docs/ # SDK documentation (Sui SDK)
|
|
14
|
+
└── assets/ # Images and attachments
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
### Using npm scripts
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Create today's daily note
|
|
23
|
+
bun run obsidian:daily
|
|
24
|
+
|
|
25
|
+
# Generate git observation
|
|
26
|
+
bun run obsidian:git
|
|
27
|
+
|
|
28
|
+
# Create progress entry
|
|
29
|
+
bun run obsidian:progress "Feature Name"
|
|
30
|
+
|
|
31
|
+
# Create both daily note and git observation
|
|
32
|
+
bun run obsidian:all
|
|
33
|
+
|
|
34
|
+
# Open vault in Obsidian
|
|
35
|
+
bun run obsidian:open
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Manual CLI
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Run the script directly
|
|
42
|
+
bun run scripts/obsidian.ts <command> [args]
|
|
43
|
+
|
|
44
|
+
# Examples:
|
|
45
|
+
bun run scripts/obsidian.ts daily
|
|
46
|
+
bun run scripts/obsidian.ts git
|
|
47
|
+
bun run scripts/obsidian.ts progress "My Feature"
|
|
48
|
+
bun run scripts/obsidian.ts open
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Templates
|
|
52
|
+
|
|
53
|
+
### Daily Note Template
|
|
54
|
+
Located at: `.vault/templates/Daily Note Template.md`
|
|
55
|
+
|
|
56
|
+
Includes:
|
|
57
|
+
- Day at a Glance
|
|
58
|
+
- Tasks checklist
|
|
59
|
+
- Progress Log (Morning/Afternoon/Evening)
|
|
60
|
+
- Notes & Ideas
|
|
61
|
+
- Blockers
|
|
62
|
+
- Git Activity tracking
|
|
63
|
+
- Links to previous/next days
|
|
64
|
+
|
|
65
|
+
### Progress Entry Template
|
|
66
|
+
Located at: `.vault/templates/Progress Entry Template.md`
|
|
67
|
+
|
|
68
|
+
Includes:
|
|
69
|
+
- Status, Priority, Timeline
|
|
70
|
+
- Objectives checklist
|
|
71
|
+
- Implementation Details
|
|
72
|
+
- Code Changes tracking
|
|
73
|
+
- Testing checklist
|
|
74
|
+
- Issues and Related links
|
|
75
|
+
|
|
76
|
+
### Git Observation Template
|
|
77
|
+
Located at: `.vault/templates/Git Observation Template.md`
|
|
78
|
+
|
|
79
|
+
Includes:
|
|
80
|
+
- Repository state (branch, commit)
|
|
81
|
+
- Recent commits log
|
|
82
|
+
- Files changed (modified/added/deleted)
|
|
83
|
+
- Code quality status
|
|
84
|
+
- Observations and patterns
|
|
85
|
+
|
|
86
|
+
## Obsidian Features Enabled
|
|
87
|
+
|
|
88
|
+
- **Daily Notes**: Automatic daily note creation
|
|
89
|
+
- **Templates**: Pre-configured note templates
|
|
90
|
+
- **Graph View**: Visualize note connections
|
|
91
|
+
- **Backlinks**: See which notes link to the current one
|
|
92
|
+
- **Outline**: Navigate document headers
|
|
93
|
+
- **Word Count**: Track document length
|
|
94
|
+
|
|
95
|
+
## Git Integration
|
|
96
|
+
|
|
97
|
+
The vault automatically captures:
|
|
98
|
+
- Current branch and commit
|
|
99
|
+
- Recent commit history
|
|
100
|
+
- Modified, added, and deleted files
|
|
101
|
+
- Can be extended to capture lint/test status
|
|
102
|
+
|
|
103
|
+
## SDK Documentation
|
|
104
|
+
|
|
105
|
+
The `sdk-docs/` directory contains imported documentation from the Mysten Labs SDK:
|
|
106
|
+
|
|
107
|
+
- **[[sdk-docs/DApp-Kit-State|DApp Kit State Management]]** - Reactive stores for wallet connections
|
|
108
|
+
- **[[sdk-docs/Transaction-Executors|Transaction Executors]]** - Serial and Parallel executor patterns
|
|
109
|
+
- **[[sdk-docs/Transaction-Plugins|Transaction Plugins]]** - Plugin system for extending transactions
|
|
110
|
+
- **[[sdk-docs/Building-SDKs|Building SDKs]]** - Best practices for SDK development
|
|
111
|
+
|
|
112
|
+
These are linked in the [[Index]] for easy navigation.
|
|
113
|
+
|
|
114
|
+
## Tips
|
|
115
|
+
|
|
116
|
+
1. **Linking**: Use `[[Note Name]]` to link between notes
|
|
117
|
+
2. **Tags**: Use `#tag` to categorize notes
|
|
118
|
+
3. **Search**: Press `Ctrl/Cmd + O` for quick file search
|
|
119
|
+
4. **Command Palette**: Press `Ctrl/Cmd + P` for all commands
|
|
120
|
+
5. **Graph View**: Press `Ctrl/Cmd + G` to see note connections
|
|
121
|
+
|
|
122
|
+
## Customization
|
|
123
|
+
|
|
124
|
+
Edit templates in `.vault/templates/` to customize your note structure. Templates support these variables:
|
|
125
|
+
|
|
126
|
+
- `{{date:YYYY-MM-DD}}` - Current date
|
|
127
|
+
- `{{date:YYYY-MM-DD HH:mm}}` - Current timestamp
|
|
128
|
+
- `{{yesterday}}` - Yesterday's date
|
|
129
|
+
- `{{tomorrow}}` - Tomorrow's date
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
# Building SDKs
|
|
2
|
+
|
|
3
|
+
**Source**: [Mysten Labs SDK Docs](https://sdk.mystenlabs.com/sui/sdk-building)
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Recommended patterns for building TypeScript SDKs that integrate with the Sui SDK. Following these patterns ensures:
|
|
8
|
+
|
|
9
|
+
- Seamless ecosystem integration
|
|
10
|
+
- Works across transports (JSON-RPC, GraphQL, gRPC)
|
|
11
|
+
- Composes well with other SDKs
|
|
12
|
+
|
|
13
|
+
**Key Requirement**: All SDKs should depend on `ClientWithCoreApi`, the transport-agnostic interface implemented by all Sui clients.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Package Setup
|
|
18
|
+
|
|
19
|
+
### Use Mysten Packages as Peer Dependencies
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"name": "@your-org/your-sdk",
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@mysten/sui": "^2.0.0",
|
|
26
|
+
"@mysten/bcs": "^2.0.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@mysten/sui": "^2.0.0",
|
|
30
|
+
"@mysten/bcs": "^2.0.0"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Benefits:**
|
|
36
|
+
- Prevents multiple versions from being bundled
|
|
37
|
+
- Ensures compatibility with user versions
|
|
38
|
+
- Reduces bundle size
|
|
39
|
+
- Avoids bugs from mismatched package instances
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Client Extensions
|
|
44
|
+
|
|
45
|
+
The recommended way to build SDKs using the **client extension pattern** via the `$extend` method.
|
|
46
|
+
|
|
47
|
+
### Extension Pattern
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import type { ClientWithCoreApi } from '@mysten/sui/client';
|
|
51
|
+
|
|
52
|
+
export interface MySDKOptions<Name = 'mySDK'> {
|
|
53
|
+
name?: Name;
|
|
54
|
+
apiKey?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function mySDK<const Name = 'mySDK'>({
|
|
58
|
+
name = 'mySDK' as Name,
|
|
59
|
+
...options
|
|
60
|
+
}: MySDKOptions<Name> = {}) {
|
|
61
|
+
return {
|
|
62
|
+
name,
|
|
63
|
+
register: (client: ClientWithCoreApi) => {
|
|
64
|
+
return new MySDKClient({ client, ...options });
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export class MySDKClient {
|
|
70
|
+
#client: ClientWithCoreApi;
|
|
71
|
+
#apiKey?: string;
|
|
72
|
+
|
|
73
|
+
constructor({ client, apiKey }: { client: ClientWithCoreApi; apiKey?: string }) {
|
|
74
|
+
this.#client = client;
|
|
75
|
+
this.#apiKey = apiKey;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async getResource(id: string) {
|
|
79
|
+
const result = await this.#client.core.getObject({ objectId: id });
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Usage
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
89
|
+
import { mySDK } from '@your-org/your-sdk';
|
|
90
|
+
|
|
91
|
+
const client = new SuiGrpcClient({
|
|
92
|
+
network: 'testnet',
|
|
93
|
+
baseUrl: 'https://fullnode.testnet.sui.io:443',
|
|
94
|
+
}).$extend(mySDK());
|
|
95
|
+
|
|
96
|
+
// Access extension
|
|
97
|
+
await client.mySDK.getResource('0x...');
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Real-World Examples
|
|
101
|
+
|
|
102
|
+
- **[@mysten/walrus](https://www.npmjs.com/package/@mysten/walrus)** - Decentralized storage
|
|
103
|
+
- **[@mysten/seal](https://www.npmjs.com/package/@mysten/seal)** - Encryption and key management
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## SDK Organization
|
|
108
|
+
|
|
109
|
+
Recommended structure for client extension methods:
|
|
110
|
+
|
|
111
|
+
| Property | Purpose | Example |
|
|
112
|
+
|----------|---------|---------|
|
|
113
|
+
| `methods` | Top-level operations | `sdk.readBlob()`, `sdk.getConfig()` |
|
|
114
|
+
| `tx` | Transaction builders (non-executing) | `sdk.tx.registerBlob()` |
|
|
115
|
+
| `bcs` | BCS type definitions | `sdk.bcs.MyStruct` |
|
|
116
|
+
| `call` | Move calls for `tx.add` | `sdk.call.myFunction()` |
|
|
117
|
+
| `view` | Simulate API for reading state | `sdk.view.getState()` |
|
|
118
|
+
|
|
119
|
+
### Example Organization
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import { Transaction } from '@mysten/sui/transactions';
|
|
123
|
+
import * as myModule from './contracts/my-package/my-module';
|
|
124
|
+
|
|
125
|
+
export class MySDKClient {
|
|
126
|
+
#client: ClientWithCoreApi;
|
|
127
|
+
|
|
128
|
+
constructor({ client }: { client: ClientWithCoreApi }) {
|
|
129
|
+
this.#client = client;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Top-level methods - execute/read
|
|
133
|
+
async executeAction(options: ActionOptions) {
|
|
134
|
+
const transaction = this.tx.createAction(options);
|
|
135
|
+
// Execute and return
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async getResource(objectId: string) {
|
|
139
|
+
const { object } = await this.#client.core.getObject({
|
|
140
|
+
objectId,
|
|
141
|
+
include: { content: true },
|
|
142
|
+
});
|
|
143
|
+
return myModule.MyStruct.parse(object.content);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Transaction builders
|
|
147
|
+
tx = {
|
|
148
|
+
createAction: (options: ActionOptions) => {
|
|
149
|
+
const transaction = new Transaction();
|
|
150
|
+
transaction.add(this.call.action(options));
|
|
151
|
+
return transaction;
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// Move call helpers
|
|
156
|
+
call = {
|
|
157
|
+
action: (options: ActionOptions) => {
|
|
158
|
+
return myModule.action({
|
|
159
|
+
arguments: {
|
|
160
|
+
obj: options.objectId,
|
|
161
|
+
amount: options.amount,
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// View methods - simulate to read state
|
|
168
|
+
view = {
|
|
169
|
+
getBalance: async (managerId: string) => {
|
|
170
|
+
const tx = new Transaction();
|
|
171
|
+
tx.add(myModule.getBalance({ arguments: { manager: managerId } }));
|
|
172
|
+
|
|
173
|
+
const res = await this.#client.core.simulateTransaction({
|
|
174
|
+
transaction: tx,
|
|
175
|
+
include: { commandResults: true },
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
return bcs.U64.parse(res.commandResults![0].returnValues[0].bcs);
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Transaction Building Patterns
|
|
187
|
+
|
|
188
|
+
### Transaction Thunks
|
|
189
|
+
|
|
190
|
+
Functions that accept a `Transaction` and mutate it, enabling composition:
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
import type { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
194
|
+
|
|
195
|
+
// Synchronous thunk
|
|
196
|
+
function createResource(options: { name: string }) {
|
|
197
|
+
return (tx: Transaction): TransactionObjectArgument => {
|
|
198
|
+
const [resource] = tx.moveCall({
|
|
199
|
+
target: `${PACKAGE_ID}::module::create`,
|
|
200
|
+
arguments: [tx.pure.string(options.name)],
|
|
201
|
+
});
|
|
202
|
+
return resource;
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Usage
|
|
207
|
+
const tx = new Transaction();
|
|
208
|
+
const resource = tx.add(createResource({ name: 'my-resource' }));
|
|
209
|
+
tx.transferObjects([resource], recipient);
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Async Thunks
|
|
213
|
+
|
|
214
|
+
For operations requiring async work (like fetching package IDs):
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
function createResourceAsync(options: { name: string }) {
|
|
218
|
+
return async (tx: Transaction): Promise<TransactionObjectArgument> => {
|
|
219
|
+
// Async work happens before signing
|
|
220
|
+
const packageId = await getLatestPackageId();
|
|
221
|
+
|
|
222
|
+
const [resource] = tx.moveCall({
|
|
223
|
+
target: `${packageId}::module::create`,
|
|
224
|
+
arguments: [tx.pure.string(options.name)],
|
|
225
|
+
});
|
|
226
|
+
return resource;
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Usage - identical to synchronous
|
|
231
|
+
const tx = new Transaction();
|
|
232
|
+
const resource = tx.add(createResourceAsync({ name: 'my-resource' }));
|
|
233
|
+
tx.transferObjects([resource], recipient);
|
|
234
|
+
|
|
235
|
+
// Async resolves automatically when building/signing
|
|
236
|
+
await signer.signAndExecuteTransaction({ transaction: tx, client });
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**Critical for web wallet compatibility** - async work during construction won't block user-triggered popups.
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Transaction Execution
|
|
244
|
+
|
|
245
|
+
### Accept a Signer Parameter
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
import type { Signer } from '@mysten/sui/cryptography';
|
|
249
|
+
|
|
250
|
+
export class MySDKClient {
|
|
251
|
+
#client: ClientWithCoreApi;
|
|
252
|
+
|
|
253
|
+
async createAndExecute({
|
|
254
|
+
signer,
|
|
255
|
+
...options
|
|
256
|
+
}: CreateOptions & { signer: Signer }) {
|
|
257
|
+
const transaction = this.tx.create(options);
|
|
258
|
+
|
|
259
|
+
const result = await signer.signAndExecuteTransaction({
|
|
260
|
+
transaction,
|
|
261
|
+
client: this.#client,
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
return result;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
**Benefits:**
|
|
270
|
+
- Wallet integration via dApp Kit
|
|
271
|
+
- Transaction sponsorship support
|
|
272
|
+
- Custom signing flows
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Code Generation
|
|
277
|
+
|
|
278
|
+
Use **[@mysten/codegen](/codegen)** to generate type-safe TypeScript bindings from Move packages.
|
|
279
|
+
|
|
280
|
+
### Benefits
|
|
281
|
+
|
|
282
|
+
- Type safety
|
|
283
|
+
- BCS parsing
|
|
284
|
+
- IDE support
|
|
285
|
+
- MoveRegistry support for human-readable names
|
|
286
|
+
|
|
287
|
+
### Using Generated Code
|
|
288
|
+
|
|
289
|
+
```typescript
|
|
290
|
+
import * as myContract from './contracts/my-package/my-module';
|
|
291
|
+
|
|
292
|
+
// Move call functions return thunks with typed options
|
|
293
|
+
const tx = new Transaction();
|
|
294
|
+
tx.add(
|
|
295
|
+
myContract.doSomething({
|
|
296
|
+
arguments: {
|
|
297
|
+
obj: '0x123...',
|
|
298
|
+
amount: 100n,
|
|
299
|
+
},
|
|
300
|
+
}),
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
// BCS types parse on-chain data
|
|
304
|
+
const { object } = await client.core.getObject({
|
|
305
|
+
objectId: '0x123...',
|
|
306
|
+
include: { content: true },
|
|
307
|
+
});
|
|
308
|
+
const parsed = myContract.MyStruct.parse(object.content);
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
## Reading Object Contents
|
|
314
|
+
|
|
315
|
+
### Single Object
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
import { MyStruct } from './contracts/my-package/my-module';
|
|
319
|
+
|
|
320
|
+
async function getResource(objectId: string) {
|
|
321
|
+
const { object } = await this.#client.core.getObject({
|
|
322
|
+
objectId,
|
|
323
|
+
include: { content: true },
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
if (!object) {
|
|
327
|
+
throw new Error(`Object ${objectId} not found`);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
return MyStruct.parse(object.content);
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Batch Fetch
|
|
335
|
+
|
|
336
|
+
```typescript
|
|
337
|
+
async function getResources(objectIds: string[]) {
|
|
338
|
+
const { objects } = await this.#client.core.getObjects({
|
|
339
|
+
objectIds,
|
|
340
|
+
include: { content: true },
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
return objects.map((obj) => {
|
|
344
|
+
if (obj instanceof Error) {
|
|
345
|
+
throw obj;
|
|
346
|
+
}
|
|
347
|
+
return MyStruct.parse(obj.content);
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## Related
|
|
355
|
+
|
|
356
|
+
- [[Transaction-Executors|Transaction Executors]]
|
|
357
|
+
- [[Transaction-Plugins|Transaction Plugins]]
|
|
358
|
+
- [[DApp-Kit-State|DApp Kit State Management]]
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
*Documentation from Mysten Labs SDK - @mysten/sui v2.0*
|