@mysten/pas 0.0.1 → 0.0.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +107 -1
  3. package/package.json +58 -58
package/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # @mysten/pas
2
+
3
+ ## 0.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - fd00b1d: Adds a README file
8
+ - Updated dependencies [c769abb]
9
+ - @mysten/sui@2.9.0
package/README.md CHANGED
@@ -1 +1,107 @@
1
- # Permissioned Assets Standard SDK
1
+ # @mysten/pas
2
+
3
+ TypeScript SDK for the [Permissioned Assets Standard](https://github.com/MystenLabs/pas) (PAS) on
4
+ Sui.
5
+
6
+ PAS lets asset issuers define transfer policies that are enforced on-chain. The SDK handles policy
7
+ resolution, account derivation, and transaction building so callers work with a simple intent-based
8
+ API.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install @mysten/pas
14
+ ```
15
+
16
+ ## Setup
17
+
18
+ The PAS client plugs into any Sui client via the `$extend` pattern:
19
+
20
+ ```typescript
21
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
22
+ import { pas } from '@mysten/pas';
23
+
24
+ const client = new SuiGrpcClient({ network: 'testnet' }).$extend(pas());
25
+ ```
26
+
27
+ The client auto-selects the correct on-chain package config for the connected network (mainnet or
28
+ testnet). For custom deployments (e.g. during localnet / CI testing) you can pass a `packageConfig`
29
+ explicitly:
30
+
31
+ ```typescript
32
+ const client = new SuiGrpcClient({ network: 'testnet' }).$extend(
33
+ pas({
34
+ packageConfig: {
35
+ packageId: '0x...',
36
+ namespaceId: '0x...',
37
+ },
38
+ }),
39
+ );
40
+ ```
41
+
42
+ ## Reading data
43
+
44
+ Every PAS user has a deterministic **Account** address derived from their wallet address. You can
45
+ derive it locally — no network call needed — and then use regular Sui queries against it:
46
+
47
+ ```typescript
48
+ const accountAddress = client.pas.deriveAccountAddress(ownerAddress);
49
+ ```
50
+
51
+ Once you have the account address, use the standard core client to query balances, objects, or any
52
+ other on-chain state:
53
+
54
+ ```typescript
55
+ const DEMO_USD = '0xabc...::demo_usd::DEMO_USD';
56
+
57
+ const [walletBalance, accountBalance] = await Promise.all([
58
+ client.core.getBalance({ owner: ownerAddress, coinType: DEMO_USD }),
59
+ client.core.getBalance({ owner: accountAddress, coinType: DEMO_USD }),
60
+ ]);
61
+ ```
62
+
63
+ Other derivation helpers are available for policies and templates:
64
+
65
+ ```typescript
66
+ const policyAddress = client.pas.derivePolicyAddress(assetType);
67
+ const templateRegistryAddress = client.pas.deriveTemplateRegistryAddress();
68
+ ```
69
+
70
+ ## Writing transactions
71
+
72
+ Transactions use an intent-based API. You add intents to a `Transaction` and the SDK resolves them
73
+ at build time — fetching policies, approval templates, and creating accounts as needed.
74
+
75
+ ### Transferring a permissioned asset
76
+
77
+ ```typescript
78
+ import { Transaction } from '@mysten/sui/transactions';
79
+
80
+ const DEMO_USD = '0xabc...::demo_usd::DEMO_USD';
81
+
82
+ const tx = new Transaction();
83
+ tx.add(
84
+ client.pas.call.sendBalance({
85
+ from: senderAddress, // The sender address (NOT the account address)
86
+ to: recipientAddress, // the recipient wallet address. NOT the account address.
87
+ amount: 1_000_000,
88
+ assetType: DEMO_USD,
89
+ }),
90
+ );
91
+
92
+ // .. sign and execute
93
+ ```
94
+
95
+ Under the hood, `sendBalance` will:
96
+
97
+ 1. Derive the sender and recipient Account addresses.
98
+ 2. Create any accounts that don't exist yet.
99
+ 3. Fetch the issuer's `Policy` for the asset type and resolve the required approval template
100
+ commands.
101
+ 4. Build the full PTB (auth, request, approvals, resolve) in a single transaction.
102
+
103
+ ## More resources
104
+
105
+ - [PAS repository](https://github.com/MystenLabs/pas) — Move contracts, architecture docs, and a
106
+ full working example app
107
+ - [`@mysten/pas` on npm](https://www.npmjs.com/package/@mysten/pas)
package/package.json CHANGED
@@ -1,59 +1,59 @@
1
1
  {
2
- "name": "@mysten/pas",
3
- "version": "0.0.1",
4
- "private": false,
5
- "description": "Permissioned Assets Standard SDK",
6
- "license": "Apache-2.0",
7
- "author": "Mysten Labs <build@mystenlabs.com>",
8
- "type": "module",
9
- "main": "./dist/index.mjs",
10
- "types": "./dist/index.d.mts",
11
- "exports": {
12
- ".": {
13
- "types": "./dist/index.d.mts",
14
- "import": "./dist/index.mjs",
15
- "default": "./dist/index.mjs"
16
- }
17
- },
18
- "sideEffects": false,
19
- "files": [
20
- "CHANGELOG.md",
21
- "dist",
22
- "src"
23
- ],
24
- "engines": {
25
- "node": ">=18"
26
- },
27
- "repository": {
28
- "type": "git",
29
- "url": "git+https://github.com/MystenLabs/ts-sdks.git"
30
- },
31
- "bugs": {
32
- "url": "https://github.com/mystenlabs/ts-sdks/issues"
33
- },
34
- "scripts": {
35
- "clean": "rm -rf tsconfig.tsbuildinfo ./dist",
36
- "build": "rm -rf dist && tsc --noEmit && tsdown",
37
- "test": "NODE_OPTIONS='--expose-gc' vitest run",
38
- "test:e2e": "vitest run e2e",
39
- "codegen": "sui-ts-codegen generate && pnpm lint:fix",
40
- "prettier:check": "prettier -c --ignore-unknown .",
41
- "prettier:fix": "prettier -w --ignore-unknown .",
42
- "oxlint:check": "oxlint .",
43
- "oxlint:fix": "oxlint --fix",
44
- "lint": "pnpm run oxlint:check && pnpm run prettier:check",
45
- "lint:fix": "pnpm run oxlint:fix && pnpm run prettier:fix"
46
- },
47
- "devDependencies": {
48
- "@mysten/codegen": "workspace:^",
49
- "@mysten/sui": "workspace:^",
50
- "@types/node": "^25.0.8",
51
- "ts-retry-promise": "^0.8.1",
52
- "tsdown": "0.20.0-beta.1",
53
- "typescript": "^5.9.3",
54
- "vitest": "^4.0.17"
55
- },
56
- "peerDependencies": {
57
- "@mysten/sui": "workspace:^"
58
- }
59
- }
2
+ "name": "@mysten/pas",
3
+ "version": "0.0.2",
4
+ "private": false,
5
+ "description": "Permissioned Assets Standard SDK",
6
+ "license": "Apache-2.0",
7
+ "author": "Mysten Labs <build@mystenlabs.com>",
8
+ "type": "module",
9
+ "main": "./dist/index.mjs",
10
+ "types": "./dist/index.d.mts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.mts",
14
+ "import": "./dist/index.mjs",
15
+ "default": "./dist/index.mjs"
16
+ }
17
+ },
18
+ "sideEffects": false,
19
+ "files": [
20
+ "CHANGELOG.md",
21
+ "dist",
22
+ "src"
23
+ ],
24
+ "engines": {
25
+ "node": ">=18"
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/MystenLabs/ts-sdks.git"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/mystenlabs/ts-sdks/issues"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^25.0.8",
36
+ "ts-retry-promise": "^0.8.1",
37
+ "tsdown": "0.20.0-beta.1",
38
+ "typescript": "^5.9.3",
39
+ "vitest": "^4.0.17",
40
+ "@mysten/codegen": "^0.8.3",
41
+ "@mysten/sui": "^2.9.0"
42
+ },
43
+ "peerDependencies": {
44
+ "@mysten/sui": "^2.9.0"
45
+ },
46
+ "scripts": {
47
+ "clean": "rm -rf tsconfig.tsbuildinfo ./dist",
48
+ "build": "rm -rf dist && tsc --noEmit && tsdown",
49
+ "test": "NODE_OPTIONS='--expose-gc' vitest run",
50
+ "test:e2e": "vitest run e2e",
51
+ "codegen": "sui-ts-codegen generate && pnpm lint:fix",
52
+ "prettier:check": "prettier -c --ignore-unknown .",
53
+ "prettier:fix": "prettier -w --ignore-unknown .",
54
+ "oxlint:check": "oxlint .",
55
+ "oxlint:fix": "oxlint --fix",
56
+ "lint": "pnpm run oxlint:check && pnpm run prettier:check",
57
+ "lint:fix": "pnpm run oxlint:fix && pnpm run prettier:fix"
58
+ }
59
+ }