sui-easy-sdk 0.0.1 → 0.0.5

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/README.md CHANGED
@@ -5,49 +5,50 @@ Designed to solve common developer pain points: pagination, name resolution, arg
5
5
 
6
6
  ## Installation
7
7
 
8
- \`\`\`bash
8
+ ```bash
9
9
  npm install sui-easy-sdk @mysten/sui @mysten/bcs
10
- \`\`\`
11
-
10
+ ```
11
+ <!--
12
+ <!--
12
13
  ## Publishing to NPM
13
14
 
14
15
  1. Build the project:
15
- \`\`\`bash
16
+ ```bash
16
17
  npm run build
17
- \`\`\`
18
+ ```
18
19
  2. Login to NPM:
19
- \`\`\`bash
20
+ ```bash
20
21
  npm login
21
- \`\`\`
22
+ ```
22
23
  3. Publish:
23
24
  - **If you have 2FA enabled (likely):**
24
- \`\`\`bash
25
+ ```bash
25
26
  npm publish --access public --otp=YOUR_OTP_CODE
26
- \`\`\`
27
+ ```
27
28
  - Otherwise:
28
- \`\`\`bash
29
+ ```bash
29
30
  npm publish --access public
30
- \`\`\`
31
+ ``` --> -->
31
32
 
32
33
  ## Core Features
33
34
 
34
35
  ### 1. Universal Naming
35
36
  **Every method** that accepts an address also accepts a `.sui` name.
36
- \`\`\`typescript
37
+ ```typescript
37
38
  const objects = await client.getAllOwnedObjects('demo.sui');
38
- \`\`\`
39
+ ```
39
40
 
40
41
  ### 2. Auto-Pagination
41
42
  Never write a `while(hasNextPage)` loop again.
42
- \`\`\`typescript
43
+ ```typescript
43
44
  const allCoins = await CoinUtils.selectCoins(client, 'demo.sui', 500n, '0x...::type', 'all');
44
- \`\`\`
45
+ ```
45
46
 
46
47
  ### 3. Fluent Transaction Builder
47
48
  Auto-wraps `number` -> `u64`, `string` -> `Pure` or `Object`, performs async name resolution.
48
- \`\`\`typescript
49
+ ```typescript
49
50
  await builder.moveCallWithResolving(client, 'pkg::mod::fn', ['friend.sui', 100]);
50
- \`\`\`
51
+ ```
51
52
 
52
53
  ---
53
54
 
@@ -104,6 +105,8 @@ Wraps `Transaction`.
104
105
  - `vectorU8ToString(bytes)`: Decodes bytes.
105
106
  - `toHex(bytes)`, `fromHex(str)`: Hex utils.
106
107
  - `normalizeAddress(addr)`: 0x-padding.
108
+ - `formatAddress(addr)`: Truncates for display (e.g. `0x12...34`).
109
+ - `isValidStructTag(str)`: Validates struct format.
107
110
 
108
111
  ---
109
112
 
@@ -112,9 +115,9 @@ Wraps `Transaction`.
112
115
  ### Buying an NFT with Kiosk and Names
113
116
  See `examples/showcase.ts` for the full code.
114
117
 
115
- \`\`\`typescript
118
+ ```typescript
116
119
  const { selectedCoins } = await CoinUtils.selectCoins(client, 'buyer.sui', price);
117
120
  const [payment] = CoinUtils.createCoinInput(builder.tx, selectedCoins, price, SUI_TYPE);
118
121
 
119
122
  await builder.moveCallWithResolving(client, 'mkt::buy', ['kiosk.sui', payment]);
120
- \`\`\`
123
+ ```
@@ -23,7 +23,7 @@ class CoinUtils {
23
23
  }
24
24
  let hasNextPage = true;
25
25
  let nextCursor = null;
26
- let allCoins = [];
26
+ const allCoins = [];
27
27
  // 1. Fetch ALL coins (or until safe limit)
28
28
  // In production, might want to limit this loop if user has 10k coins
29
29
  while (hasNextPage) {
package/dist/display.js CHANGED
@@ -47,7 +47,7 @@ class ObjectDisplayUtils {
47
47
  static resolveImageUrl(display) {
48
48
  if (!display)
49
49
  return null;
50
- let url = display.image_url || display.img_url || display.url;
50
+ const url = display.image_url || display.img_url || display.url;
51
51
  if (!url)
52
52
  return null;
53
53
  if (url.startsWith('ipfs://')) {
package/dist/utils.d.ts CHANGED
@@ -32,4 +32,15 @@ export declare class DataUtils {
32
32
  * Converts Base64 to bytes.
33
33
  */
34
34
  static fromBase64(b64: string): Uint8Array;
35
+ /**
36
+ * Formats an address for display (e.g. 0x1234...5678).
37
+ * @param addr The address to format
38
+ * @param startChars Number of characters to keep at start (default 6)
39
+ * @param endChars Number of characters to keep at end (default 4)
40
+ */
41
+ static formatAddress(addr: string, startChars?: number, endChars?: number): string;
42
+ /**
43
+ * Checks if a string looks like a valid Struct Tag (pkg::mod::type).
44
+ */
45
+ static isValidStructTag(tag: string): boolean;
35
46
  }
package/dist/utils.js CHANGED
@@ -54,5 +54,23 @@ class DataUtils {
54
54
  static fromBase64(b64) {
55
55
  return (0, bcs_1.fromB64)(b64);
56
56
  }
57
+ /**
58
+ * Formats an address for display (e.g. 0x1234...5678).
59
+ * @param addr The address to format
60
+ * @param startChars Number of characters to keep at start (default 6)
61
+ * @param endChars Number of characters to keep at end (default 4)
62
+ */
63
+ static formatAddress(addr, startChars = 6, endChars = 4) {
64
+ if (!addr || addr.length <= startChars + endChars)
65
+ return addr;
66
+ return `${addr.slice(0, startChars)}...${addr.slice(-endChars)}`;
67
+ }
68
+ /**
69
+ * Checks if a string looks like a valid Struct Tag (pkg::mod::type).
70
+ */
71
+ static isValidStructTag(tag) {
72
+ // Basic regex for 0x...::module::Type
73
+ return /^0x[a-fA-F0-9]+::\w+::\w+/.test(tag);
74
+ }
57
75
  }
58
76
  exports.DataUtils = DataUtils;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sui-easy-sdk",
3
- "version": "0.0.1",
3
+ "version": "0.0.5",
4
4
  "description": "A developer-friendly SDK for SUI blockchain interactions",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,13 +24,17 @@
24
24
  "author": "dotandev",
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
- "@mysten/sui": "^1.21.1",
28
- "@mysten/bcs": "^1.1.0"
27
+ "@mysten/bcs": "^1.1.0",
28
+ "@mysten/sui": "^1.21.1"
29
29
  },
30
30
  "devDependencies": {
31
- "typescript": "^5.7.3",
32
- "vitest": "^3.0.4",
31
+ "@eslint/js": "^9.39.2",
33
32
  "@types/node": "^22.10.7",
34
- "ts-node": "^10.9.2"
33
+ "eslint": "^9.39.2",
34
+ "globals": "^17.1.0",
35
+ "ts-node": "^10.9.2",
36
+ "typescript": "^5.7.3",
37
+ "typescript-eslint": "^8.53.1",
38
+ "vitest": "^3.0.4"
35
39
  }
36
- }
40
+ }