@mysten/sui 2.15.0 → 2.16.1

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 (78) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/bcs/bcs.d.mts +6 -6
  3. package/dist/client/mvr.d.mts.map +1 -1
  4. package/dist/client/mvr.mjs +3 -0
  5. package/dist/client/mvr.mjs.map +1 -1
  6. package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
  7. package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
  8. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  9. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
  10. package/dist/jsonRpc/http-transport.mjs +1 -2
  11. package/dist/jsonRpc/http-transport.mjs.map +1 -1
  12. package/dist/transactions/Transaction.d.mts +6 -6
  13. package/dist/transactions/data/internal.d.mts +109 -109
  14. package/dist/transactions/data/internal.d.mts.map +1 -1
  15. package/dist/transactions/data/v1.d.mts +220 -220
  16. package/dist/transactions/data/v1.d.mts.map +1 -1
  17. package/dist/transactions/data/v2.d.mts +16 -16
  18. package/dist/transactions/data/v2.d.mts.map +1 -1
  19. package/dist/utils/format.d.mts +5 -1
  20. package/dist/utils/format.d.mts.map +1 -1
  21. package/dist/utils/format.mjs +19 -1
  22. package/dist/utils/format.mjs.map +1 -1
  23. package/dist/utils/index.d.mts +2 -2
  24. package/dist/utils/index.mjs +2 -2
  25. package/dist/version.mjs +2 -3
  26. package/dist/version.mjs.map +1 -1
  27. package/dist/zklogin/bcs.d.mts +14 -14
  28. package/dist/zklogin/bcs.d.mts.map +1 -1
  29. package/package.json +4 -5
  30. package/src/client/mvr.ts +12 -0
  31. package/src/jsonRpc/http-transport.ts +1 -2
  32. package/src/utils/format.ts +36 -0
  33. package/src/utils/index.ts +1 -1
  34. package/src/version.ts +1 -2
  35. package/docs/bcs.md +0 -131
  36. package/docs/clients/core.md +0 -616
  37. package/docs/clients/graphql.md +0 -99
  38. package/docs/clients/grpc.md +0 -205
  39. package/docs/clients/index.md +0 -93
  40. package/docs/clients/json-rpc.md +0 -235
  41. package/docs/cryptography/keypairs.md +0 -258
  42. package/docs/cryptography/multisig.md +0 -192
  43. package/docs/cryptography/passkey.md +0 -111
  44. package/docs/cryptography/webcrypto-signer.md +0 -81
  45. package/docs/executors.md +0 -147
  46. package/docs/faucet.md +0 -26
  47. package/docs/hello-sui.md +0 -114
  48. package/docs/index.md +0 -54
  49. package/docs/install.md +0 -61
  50. package/docs/llm-docs.md +0 -32
  51. package/docs/llms-index.md +0 -60
  52. package/docs/migrations/0.38.md +0 -57
  53. package/docs/migrations/sui-1.0.md +0 -453
  54. package/docs/migrations/sui-2.0/agent-prompt.md +0 -42
  55. package/docs/migrations/sui-2.0/dapp-kit.md +0 -350
  56. package/docs/migrations/sui-2.0/deepbook-v3.md +0 -33
  57. package/docs/migrations/sui-2.0/index.md +0 -157
  58. package/docs/migrations/sui-2.0/json-rpc-migration.md +0 -399
  59. package/docs/migrations/sui-2.0/kiosk.md +0 -120
  60. package/docs/migrations/sui-2.0/sdk-maintainers.md +0 -90
  61. package/docs/migrations/sui-2.0/seal.md +0 -14
  62. package/docs/migrations/sui-2.0/sui.md +0 -341
  63. package/docs/migrations/sui-2.0/suins.md +0 -42
  64. package/docs/migrations/sui-2.0/wallet-builders.md +0 -66
  65. package/docs/migrations/sui-2.0/walrus.md +0 -41
  66. package/docs/migrations/sui-2.0/zksend.md +0 -94
  67. package/docs/plugins.md +0 -255
  68. package/docs/sdk-building.md +0 -340
  69. package/docs/transaction-building/basics.md +0 -297
  70. package/docs/transaction-building/gas.md +0 -62
  71. package/docs/transaction-building/intents.md +0 -61
  72. package/docs/transaction-building/offline.md +0 -71
  73. package/docs/transaction-building/sponsored-transactions.md +0 -22
  74. package/docs/utils/derived_objects.md +0 -80
  75. package/docs/utils/index.md +0 -52
  76. package/docs/zklogin.md +0 -78
  77. package/src/transactions/__tests__/Transaction.test.ts +0 -184
  78. package/src/transactions/__tests__/bcs.test.ts +0 -205
@@ -1,3 +1,5 @@
1
+ import { SUI_DECIMALS } from "./constants.mjs";
2
+
1
3
  //#region src/utils/format.ts
2
4
  const ELLIPSIS = "…";
3
5
  function formatAddress(address) {
@@ -8,7 +10,23 @@ function formatAddress(address) {
8
10
  function formatDigest(digest) {
9
11
  return `${digest.slice(0, 10)}${ELLIPSIS}`;
10
12
  }
13
+ const AMOUNT_REGEX = /^-?(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)$/;
14
+ /** Parse a decimal string into its smallest-unit bigint representation. No floating point. */
15
+ function parseToUnits(amount, decimals) {
16
+ if (decimals < 0 || !Number.isInteger(decimals)) throw new Error(`Invalid decimals: ${decimals}`);
17
+ if (!AMOUNT_REGEX.test(amount)) throw new Error(`Invalid amount: "${amount}"`);
18
+ const negative = amount.startsWith("-");
19
+ const [whole, fraction = ""] = (negative ? amount.slice(1) : amount).split(".");
20
+ if (fraction.length > decimals) throw new Error(`Too many decimal places: "${amount}" has ${fraction.length} but max is ${decimals}`);
21
+ const paddedFraction = fraction.padEnd(decimals, "0") || "0";
22
+ const result = BigInt(whole || "0") * 10n ** BigInt(decimals) + BigInt(paddedFraction);
23
+ return negative ? -result : result;
24
+ }
25
+ /** Parse a SUI decimal string into MIST. */
26
+ function parseToMist(amount) {
27
+ return parseToUnits(amount, SUI_DECIMALS);
28
+ }
11
29
 
12
30
  //#endregion
13
- export { formatAddress, formatDigest };
31
+ export { formatAddress, formatDigest, parseToMist, parseToUnits };
14
32
  //# sourceMappingURL=format.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.mjs","names":[],"sources":["../../src/utils/format.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nconst ELLIPSIS = '\\u{2026}';\n\nexport function formatAddress(address: string) {\n\tif (address.length <= 6) {\n\t\treturn address;\n\t}\n\n\tconst offset = address.startsWith('0x') ? 2 : 0;\n\n\treturn `0x${address.slice(offset, offset + 4)}${ELLIPSIS}${address.slice(-4)}`;\n}\n\nexport function formatDigest(digest: string) {\n\t// Use 10 first characters\n\treturn `${digest.slice(0, 10)}${ELLIPSIS}`;\n}\n"],"mappings":";AAGA,MAAM,WAAW;AAEjB,SAAgB,cAAc,SAAiB;AAC9C,KAAI,QAAQ,UAAU,EACrB,QAAO;CAGR,MAAM,SAAS,QAAQ,WAAW,KAAK,GAAG,IAAI;AAE9C,QAAO,KAAK,QAAQ,MAAM,QAAQ,SAAS,EAAE,GAAG,WAAW,QAAQ,MAAM,GAAG;;AAG7E,SAAgB,aAAa,QAAgB;AAE5C,QAAO,GAAG,OAAO,MAAM,GAAG,GAAG,GAAG"}
1
+ {"version":3,"file":"format.mjs","names":[],"sources":["../../src/utils/format.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SUI_DECIMALS } from './constants.js';\n\nconst ELLIPSIS = '\\u{2026}';\n\nexport function formatAddress(address: string) {\n\tif (address.length <= 6) {\n\t\treturn address;\n\t}\n\n\tconst offset = address.startsWith('0x') ? 2 : 0;\n\n\treturn `0x${address.slice(offset, offset + 4)}${ELLIPSIS}${address.slice(-4)}`;\n}\n\nexport function formatDigest(digest: string) {\n\t// Use 10 first characters\n\treturn `${digest.slice(0, 10)}${ELLIPSIS}`;\n}\n\nconst AMOUNT_REGEX = /^-?(?:[0-9]+(?:\\.[0-9]+)?|\\.[0-9]+)$/;\n\n/** Parse a decimal string into its smallest-unit bigint representation. No floating point. */\nexport function parseToUnits(amount: string, decimals: number): bigint {\n\tif (decimals < 0 || !Number.isInteger(decimals)) {\n\t\tthrow new Error(`Invalid decimals: ${decimals}`);\n\t}\n\n\tif (!AMOUNT_REGEX.test(amount)) {\n\t\tthrow new Error(`Invalid amount: \"${amount}\"`);\n\t}\n\n\tconst negative = amount.startsWith('-');\n\tconst stripped = negative ? amount.slice(1) : amount;\n\n\tconst [whole, fraction = ''] = stripped.split('.');\n\n\tif (fraction.length > decimals) {\n\t\tthrow new Error(\n\t\t\t`Too many decimal places: \"${amount}\" has ${fraction.length} but max is ${decimals}`,\n\t\t);\n\t}\n\n\tconst paddedFraction = fraction.padEnd(decimals, '0') || '0';\n\tconst result = BigInt(whole || '0') * 10n ** BigInt(decimals) + BigInt(paddedFraction);\n\n\treturn negative ? -result : result;\n}\n\n/** Parse a SUI decimal string into MIST. */\nexport function parseToMist(amount: string): bigint {\n\treturn parseToUnits(amount, SUI_DECIMALS);\n}\n"],"mappings":";;;AAKA,MAAM,WAAW;AAEjB,SAAgB,cAAc,SAAiB;AAC9C,KAAI,QAAQ,UAAU,EACrB,QAAO;CAGR,MAAM,SAAS,QAAQ,WAAW,KAAK,GAAG,IAAI;AAE9C,QAAO,KAAK,QAAQ,MAAM,QAAQ,SAAS,EAAE,GAAG,WAAW,QAAQ,MAAM,GAAG;;AAG7E,SAAgB,aAAa,QAAgB;AAE5C,QAAO,GAAG,OAAO,MAAM,GAAG,GAAG,GAAG;;AAGjC,MAAM,eAAe;;AAGrB,SAAgB,aAAa,QAAgB,UAA0B;AACtE,KAAI,WAAW,KAAK,CAAC,OAAO,UAAU,SAAS,CAC9C,OAAM,IAAI,MAAM,qBAAqB,WAAW;AAGjD,KAAI,CAAC,aAAa,KAAK,OAAO,CAC7B,OAAM,IAAI,MAAM,oBAAoB,OAAO,GAAG;CAG/C,MAAM,WAAW,OAAO,WAAW,IAAI;CAGvC,MAAM,CAAC,OAAO,WAAW,OAFR,WAAW,OAAO,MAAM,EAAE,GAAG,QAEN,MAAM,IAAI;AAElD,KAAI,SAAS,SAAS,SACrB,OAAM,IAAI,MACT,6BAA6B,OAAO,QAAQ,SAAS,OAAO,cAAc,WAC1E;CAGF,MAAM,iBAAiB,SAAS,OAAO,UAAU,IAAI,IAAI;CACzD,MAAM,SAAS,OAAO,SAAS,IAAI,GAAG,OAAO,OAAO,SAAS,GAAG,OAAO,eAAe;AAEtF,QAAO,WAAW,CAAC,SAAS;;;AAI7B,SAAgB,YAAY,QAAwB;AACnD,QAAO,aAAa,QAAQ,aAAa"}
@@ -1,10 +1,10 @@
1
1
  import { normalizeTypeTag } from "../bcs/type-tag-serializer.mjs";
2
2
  import { SUI_ADDRESS_LENGTH, isValidStructTag, isValidSuiAddress, isValidSuiObjectId, isValidTransactionDigest, normalizeStructTag, normalizeSuiAddress, normalizeSuiObjectId, parseStructTag } from "./sui-types.mjs";
3
- import { formatAddress, formatDigest } from "./format.mjs";
3
+ import { formatAddress, formatDigest, parseToMist, parseToUnits } from "./format.mjs";
4
4
  import { isValidSuiNSName, normalizeSuiNSName } from "./suins.mjs";
5
5
  import { MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_CLOCK_OBJECT_ID, SUI_COIN_REGISTRY_OBJECT_ID, SUI_DECIMALS, SUI_DENY_LIST_OBJECT_ID, SUI_FRAMEWORK_ADDRESS, SUI_RANDOM_OBJECT_ID, SUI_SYSTEM_ADDRESS, SUI_SYSTEM_MODULE_NAME, SUI_SYSTEM_STATE_OBJECT_ID, SUI_TYPE_ARG } from "./constants.mjs";
6
6
  import { isValidNamedPackage, isValidNamedType } from "./move-registry.mjs";
7
7
  import { deriveDynamicFieldID } from "./dynamic-fields.mjs";
8
8
  import { deriveObjectID } from "./derived-objects.mjs";
9
9
  import { fromBase58, fromBase64, fromHex, toBase58, toBase64, toHex } from "@mysten/bcs";
10
- export { MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_ADDRESS_LENGTH, SUI_CLOCK_OBJECT_ID, SUI_COIN_REGISTRY_OBJECT_ID, SUI_DECIMALS, SUI_DENY_LIST_OBJECT_ID, SUI_FRAMEWORK_ADDRESS, SUI_RANDOM_OBJECT_ID, SUI_SYSTEM_ADDRESS, SUI_SYSTEM_MODULE_NAME, SUI_SYSTEM_STATE_OBJECT_ID, SUI_TYPE_ARG, deriveDynamicFieldID, deriveObjectID, formatAddress, formatDigest, fromBase58, fromBase64, fromHex, isValidNamedPackage, isValidNamedType, isValidStructTag, isValidSuiAddress, isValidSuiNSName, isValidSuiObjectId, isValidTransactionDigest, normalizeStructTag, normalizeSuiAddress, normalizeSuiNSName, normalizeSuiObjectId, normalizeTypeTag, parseStructTag, toBase58, toBase64, toHex };
10
+ export { MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_ADDRESS_LENGTH, SUI_CLOCK_OBJECT_ID, SUI_COIN_REGISTRY_OBJECT_ID, SUI_DECIMALS, SUI_DENY_LIST_OBJECT_ID, SUI_FRAMEWORK_ADDRESS, SUI_RANDOM_OBJECT_ID, SUI_SYSTEM_ADDRESS, SUI_SYSTEM_MODULE_NAME, SUI_SYSTEM_STATE_OBJECT_ID, SUI_TYPE_ARG, deriveDynamicFieldID, deriveObjectID, formatAddress, formatDigest, fromBase58, fromBase64, fromHex, isValidNamedPackage, isValidNamedType, isValidStructTag, isValidSuiAddress, isValidSuiNSName, isValidSuiObjectId, isValidTransactionDigest, normalizeStructTag, normalizeSuiAddress, normalizeSuiNSName, normalizeSuiObjectId, normalizeTypeTag, parseStructTag, parseToMist, parseToUnits, toBase58, toBase64, toHex };
@@ -4,8 +4,8 @@ import { SUI_ADDRESS_LENGTH, isValidStructTag, isValidSuiAddress, isValidSuiObje
4
4
  import { normalizeTypeTag } from "../bcs/type-tag-serializer.mjs";
5
5
  import { deriveDynamicFieldID } from "./dynamic-fields.mjs";
6
6
  import { MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_CLOCK_OBJECT_ID, SUI_COIN_REGISTRY_OBJECT_ID, SUI_DECIMALS, SUI_DENY_LIST_OBJECT_ID, SUI_FRAMEWORK_ADDRESS, SUI_RANDOM_OBJECT_ID, SUI_SYSTEM_ADDRESS, SUI_SYSTEM_MODULE_NAME, SUI_SYSTEM_STATE_OBJECT_ID, SUI_TYPE_ARG } from "./constants.mjs";
7
- import { formatAddress, formatDigest } from "./format.mjs";
7
+ import { formatAddress, formatDigest, parseToMist, parseToUnits } from "./format.mjs";
8
8
  import { deriveObjectID } from "./derived-objects.mjs";
9
9
  import { fromBase58, fromBase64, fromHex, toBase58, toBase64, toHex } from "@mysten/bcs";
10
10
 
11
- export { MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_ADDRESS_LENGTH, SUI_CLOCK_OBJECT_ID, SUI_COIN_REGISTRY_OBJECT_ID, SUI_DECIMALS, SUI_DENY_LIST_OBJECT_ID, SUI_FRAMEWORK_ADDRESS, SUI_RANDOM_OBJECT_ID, SUI_SYSTEM_ADDRESS, SUI_SYSTEM_MODULE_NAME, SUI_SYSTEM_STATE_OBJECT_ID, SUI_TYPE_ARG, deriveDynamicFieldID, deriveObjectID, formatAddress, formatDigest, fromBase58, fromBase64, fromHex, isValidNamedPackage, isValidNamedType, isValidStructTag, isValidSuiAddress, isValidSuiNSName, isValidSuiObjectId, isValidTransactionDigest, normalizeStructTag, normalizeSuiAddress, normalizeSuiNSName, normalizeSuiObjectId, normalizeTypeTag, parseStructTag, toBase58, toBase64, toHex };
11
+ export { MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_ADDRESS_LENGTH, SUI_CLOCK_OBJECT_ID, SUI_COIN_REGISTRY_OBJECT_ID, SUI_DECIMALS, SUI_DENY_LIST_OBJECT_ID, SUI_FRAMEWORK_ADDRESS, SUI_RANDOM_OBJECT_ID, SUI_SYSTEM_ADDRESS, SUI_SYSTEM_MODULE_NAME, SUI_SYSTEM_STATE_OBJECT_ID, SUI_TYPE_ARG, deriveDynamicFieldID, deriveObjectID, formatAddress, formatDigest, fromBase58, fromBase64, fromHex, isValidNamedPackage, isValidNamedType, isValidStructTag, isValidSuiAddress, isValidSuiNSName, isValidSuiObjectId, isValidTransactionDigest, normalizeStructTag, normalizeSuiAddress, normalizeSuiNSName, normalizeSuiObjectId, normalizeTypeTag, parseStructTag, parseToMist, parseToUnits, toBase58, toBase64, toHex };
package/dist/version.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  //#region src/version.ts
2
- const PACKAGE_VERSION = "2.15.0";
3
- const TARGETED_RPC_VERSION = "1.70.0";
2
+ const PACKAGE_VERSION = "2.16.1";
4
3
 
5
4
  //#endregion
6
- export { PACKAGE_VERSION, TARGETED_RPC_VERSION };
5
+ export { PACKAGE_VERSION };
7
6
  //# sourceMappingURL=version.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// This file is generated by genversion.mjs. Do not edit it directly.\n\nexport const PACKAGE_VERSION = '2.15.0';\nexport const TARGETED_RPC_VERSION = '1.70.0';\n"],"mappings":";AAKA,MAAa,kBAAkB;AAC/B,MAAa,uBAAuB"}
1
+ {"version":3,"file":"version.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// This file is generated by genversion.mjs. Do not edit it directly.\n\nexport const PACKAGE_VERSION = '2.16.1';\n"],"mappings":";AAKA,MAAa,kBAAkB"}
@@ -1,31 +1,31 @@
1
- import * as _mysten_bcs810 from "@mysten/bcs";
1
+ import * as _mysten_bcs1118 from "@mysten/bcs";
2
2
  import { InferBcsInput } from "@mysten/bcs";
3
3
 
4
4
  //#region src/zklogin/bcs.d.ts
5
- declare const zkLoginSignature: _mysten_bcs810.BcsStruct<{
6
- inputs: _mysten_bcs810.BcsStruct<{
7
- proofPoints: _mysten_bcs810.BcsStruct<{
8
- a: _mysten_bcs810.BcsType<string[], Iterable<string> & {
5
+ declare const zkLoginSignature: _mysten_bcs1118.BcsStruct<{
6
+ inputs: _mysten_bcs1118.BcsStruct<{
7
+ proofPoints: _mysten_bcs1118.BcsStruct<{
8
+ a: _mysten_bcs1118.BcsType<string[], Iterable<string> & {
9
9
  length: number;
10
10
  }, string>;
11
- b: _mysten_bcs810.BcsType<string[][], Iterable<Iterable<string> & {
11
+ b: _mysten_bcs1118.BcsType<string[][], Iterable<Iterable<string> & {
12
12
  length: number;
13
13
  }> & {
14
14
  length: number;
15
15
  }, string>;
16
- c: _mysten_bcs810.BcsType<string[], Iterable<string> & {
16
+ c: _mysten_bcs1118.BcsType<string[], Iterable<string> & {
17
17
  length: number;
18
18
  }, string>;
19
19
  }, string>;
20
- issBase64Details: _mysten_bcs810.BcsStruct<{
21
- value: _mysten_bcs810.BcsType<string, string, "string">;
22
- indexMod4: _mysten_bcs810.BcsType<number, number, "u8">;
20
+ issBase64Details: _mysten_bcs1118.BcsStruct<{
21
+ value: _mysten_bcs1118.BcsType<string, string, "string">;
22
+ indexMod4: _mysten_bcs1118.BcsType<number, number, "u8">;
23
23
  }, string>;
24
- headerBase64: _mysten_bcs810.BcsType<string, string, "string">;
25
- addressSeed: _mysten_bcs810.BcsType<string, string, "string">;
24
+ headerBase64: _mysten_bcs1118.BcsType<string, string, "string">;
25
+ addressSeed: _mysten_bcs1118.BcsType<string, string, "string">;
26
26
  }, string>;
27
- maxEpoch: _mysten_bcs810.BcsType<string, string | number | bigint, "u64">;
28
- userSignature: _mysten_bcs810.BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
27
+ maxEpoch: _mysten_bcs1118.BcsType<string, string | number | bigint, "u64">;
28
+ userSignature: _mysten_bcs1118.BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
29
29
  }, string>;
30
30
  type ZkLoginSignature = InferBcsInput<typeof zkLoginSignature>;
31
31
  type ZkLoginSignatureInputs = ZkLoginSignature['inputs'];
@@ -1 +1 @@
1
- {"version":3,"file":"bcs.d.mts","names":[],"sources":["../../src/zklogin/bcs.ts"],"mappings":";;;;cAMa,gBAAA,iBAAgB,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;KAkBjB,gBAAA,GAAmB,aAAA,QAAqB,gBAAA;AAAA,KACxC,sBAAA,GAAyB,gBAAA"}
1
+ {"version":3,"file":"bcs.d.mts","names":[],"sources":["../../src/zklogin/bcs.ts"],"mappings":";;;;cAMa,gBAAA,kBAAgB,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;KAkBjB,gBAAA,GAAmB,aAAA,QAAqB,gBAAA;AAAA,KACxC,sBAAA,GAAyB,gBAAA"}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "Mysten Labs <build@mystenlabs.com>",
4
4
  "description": "Sui TypeScript API",
5
5
  "homepage": "https://sdk.mystenlabs.com",
6
- "version": "2.15.0",
6
+ "version": "2.16.1",
7
7
  "license": "Apache-2.0",
8
8
  "sideEffects": false,
9
9
  "files": [
@@ -139,7 +139,6 @@
139
139
  "@graphql-codegen/typescript-document-nodes": "5.0.7",
140
140
  "@graphql-codegen/typescript-operations": "^5.0.7",
141
141
  "@grpc/grpc-js": "^1.13.3",
142
- "@iarna/toml": "^2.2.5",
143
142
  "@parcel/watcher": "^2.5.4",
144
143
  "@protobuf-ts/grpc-transport": "^2.11.1",
145
144
  "@types/node": "^25.0.8",
@@ -169,8 +168,8 @@
169
168
  "graphql": "^16.12.0",
170
169
  "poseidon-lite": "0.2.1",
171
170
  "valibot": "^1.2.0",
172
- "@mysten/bcs": "^2.0.3",
173
- "@mysten/utils": "^0.3.1"
171
+ "@mysten/bcs": "^2.0.4",
172
+ "@mysten/utils": "^0.3.2"
174
173
  },
175
174
  "scripts": {
176
175
  "clean": "rm -rf tsconfig.tsbuildinfo ./dist",
@@ -183,7 +182,7 @@
183
182
  "codegen:grpc-header": "find src/grpc/proto -type f -exec sh -c 'echo \"// Copyright (c) Mysten Labs, Inc.\\n// SPDX-License-Identifier: Apache-2.0\\n\" | cat - {} > temp && mv temp {}' \\;",
184
183
  "codegen:grpc-extensions": "find src/grpc/proto -name '*.ts' | xargs sed -i '' -E 's/from \"(\\.[^\"]+)\"/from \"\\1.js\"/g'",
185
184
  "build": "rm -rf dist && node genversion.mjs && tsc --noEmit && tsdown",
186
- "build:docs": "tsx ../docs/scripts/build-docs.ts",
185
+ "build:docs": "node ../docs/scripts/build-docs.ts",
187
186
  "vitest": "vitest",
188
187
  "test": "pnpm test:typecheck && pnpm test:unit",
189
188
  "test:typecheck": "tsc -p ./test",
package/src/client/mvr.ts CHANGED
@@ -332,6 +332,10 @@ function validateOverrides(overrides?: {
332
332
  export function extractMvrTypes(type: string | StructTag, types = new Set<string>()) {
333
333
  if (typeof type === 'string' && !hasMvrName(type)) return types;
334
334
 
335
+ if (typeof type === 'string' && type.startsWith('vector<') && type.endsWith('>')) {
336
+ return extractMvrTypes(type.slice(7, -1), types);
337
+ }
338
+
335
339
  const tag = isStructTag(type) ? type : parseStructTag(type);
336
340
 
337
341
  if (hasMvrName(tag.address)) types.add(`${tag.address}::${tag.module}::${tag.name}`);
@@ -348,6 +352,14 @@ export function extractMvrTypes(type: string | StructTag, types = new Set<string
348
352
  * based on the supplied type cache.
349
353
  */
350
354
  function replaceMvrNames(tag: string | StructTag, typeCache: Record<string, string>): string {
355
+ if (typeof tag === 'string' && !tag.includes('::')) {
356
+ return tag;
357
+ }
358
+
359
+ if (typeof tag === 'string' && tag.startsWith('vector<') && tag.endsWith('>')) {
360
+ return `vector<${replaceMvrNames(tag.slice(7, -1), typeCache)}>`;
361
+ }
362
+
351
363
  const type = isStructTag(tag) ? tag : parseStructTag(tag);
352
364
 
353
365
  const typeTag = `${type.address}::${type.module}::${type.name}`;
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { PACKAGE_VERSION, TARGETED_RPC_VERSION } from '../version.js';
4
+ import { PACKAGE_VERSION } from '../version.js';
5
5
  import { JsonRpcError, SuiHTTPStatusError } from './errors.js';
6
6
 
7
7
  /**
@@ -58,7 +58,6 @@ export class JsonRpcHTTPTransport implements JsonRpcTransport {
58
58
  'Content-Type': 'application/json',
59
59
  'Client-Sdk-Type': 'typescript',
60
60
  'Client-Sdk-Version': PACKAGE_VERSION,
61
- 'Client-Target-Api-Version': TARGETED_RPC_VERSION,
62
61
  'Client-Request-Method': input.method,
63
62
  ...this.#options.rpc?.headers,
64
63
  },
@@ -1,6 +1,8 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import { SUI_DECIMALS } from './constants.js';
5
+
4
6
  const ELLIPSIS = '\u{2026}';
5
7
 
6
8
  export function formatAddress(address: string) {
@@ -17,3 +19,37 @@ export function formatDigest(digest: string) {
17
19
  // Use 10 first characters
18
20
  return `${digest.slice(0, 10)}${ELLIPSIS}`;
19
21
  }
22
+
23
+ const AMOUNT_REGEX = /^-?(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)$/;
24
+
25
+ /** Parse a decimal string into its smallest-unit bigint representation. No floating point. */
26
+ export function parseToUnits(amount: string, decimals: number): bigint {
27
+ if (decimals < 0 || !Number.isInteger(decimals)) {
28
+ throw new Error(`Invalid decimals: ${decimals}`);
29
+ }
30
+
31
+ if (!AMOUNT_REGEX.test(amount)) {
32
+ throw new Error(`Invalid amount: "${amount}"`);
33
+ }
34
+
35
+ const negative = amount.startsWith('-');
36
+ const stripped = negative ? amount.slice(1) : amount;
37
+
38
+ const [whole, fraction = ''] = stripped.split('.');
39
+
40
+ if (fraction.length > decimals) {
41
+ throw new Error(
42
+ `Too many decimal places: "${amount}" has ${fraction.length} but max is ${decimals}`,
43
+ );
44
+ }
45
+
46
+ const paddedFraction = fraction.padEnd(decimals, '0') || '0';
47
+ const result = BigInt(whole || '0') * 10n ** BigInt(decimals) + BigInt(paddedFraction);
48
+
49
+ return negative ? -result : result;
50
+ }
51
+
52
+ /** Parse a SUI decimal string into MIST. */
53
+ export function parseToMist(amount: string): bigint {
54
+ return parseToUnits(amount, SUI_DECIMALS);
55
+ }
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- export { formatAddress, formatDigest } from './format.js';
4
+ export { formatAddress, formatDigest, parseToUnits, parseToMist } from './format.js';
5
5
  export {
6
6
  isValidStructTag,
7
7
  isValidSuiAddress,
package/src/version.ts CHANGED
@@ -3,5 +3,4 @@
3
3
 
4
4
  // This file is generated by genversion.mjs. Do not edit it directly.
5
5
 
6
- export const PACKAGE_VERSION = '2.15.0';
7
- export const TARGETED_RPC_VERSION = '1.70.0';
6
+ export const PACKAGE_VERSION = '2.16.1';
package/docs/bcs.md DELETED
@@ -1,131 +0,0 @@
1
- # BCS
2
-
3
- > Binary Canonical Serialization for encoding Sui Move types
4
-
5
- The `@mysten/sui/bcs` package extends `@mysten/bcs` with Sui specific scheme definitions.
6
-
7
- To learn more about using BCS see the [BCS documentation](/bcs).
8
-
9
- the `bcs` export of `@mysten/sui/bcs` contains all the same exports as `bcs` from `@mysten/bcs` plus
10
- the following pre-defined schemes:
11
-
12
- - `U8`
13
- - `U16`
14
- - `U32`
15
- - `U64`
16
- - `U128`
17
- - `U256`
18
- - `ULEB128`
19
- - `Bool`
20
- - `String`
21
- - `Address`
22
- - `Argument`
23
- - `CallArg`
24
- - `CompressedSignature`
25
- - `GasData`
26
- - `MultiSig`
27
- - `MultiSigPkMap`
28
- - `MultiSigPublicKey`
29
- - `ObjectArg`
30
- - `ObjectDigest`
31
- - `ProgrammableMoveCall`
32
- - `ProgrammableTransaction`
33
- - `PublicKey`
34
- - `SenderSignedData`
35
- - `SharedObjectRef`
36
- - `StructTag`
37
- - `SuiObjectRef`
38
- - `Transaction`
39
- - `TransactionData`
40
- - `TransactionDataV1`
41
- - `TransactionExpiration`
42
- - `TransactionKind`
43
- - `TypeTag`
44
- - `Object` - Complete object with data, owner, previousTransaction, and storageRebate
45
- - `TransactionEffects` - Transaction execution effects (supports both V1 and V2)
46
- - `TransactionEffectsV1` - Legacy transaction effects format
47
- - `TransactionEffectsV2` - Current transaction effects format with detailed object changes
48
-
49
- All the upper-cased values are `BcsType` instances, and can be used directly to parse and serialize
50
- data.
51
-
52
- ```typescript
53
- bcs.U8.serialize(1);
54
- bcs.Address.serialize('0x1');
55
- bcs.TypeTag.serialize({
56
- vector: {
57
- u8: true,
58
- },
59
- });
60
- ```
61
-
62
- ## Working with Objects
63
-
64
- To parse on-chain objects, fetch them with `include: { content: true }` and pass `object.content` to
65
- a generated BCS type or a manual struct definition. The `content` field contains only the inner Move
66
- struct bytes:
67
-
68
- ```typescript
69
- const { object } = await client.core.getObject({
70
- objectId: '0x123...',
71
- include: { content: true },
72
- });
73
-
74
- const parsed = MyStruct.parse(object.content);
75
- ```
76
-
77
- ### `bcs.Object` — Full object envelope
78
-
79
- The `bcs.Object` schema represents the complete on-chain object, including metadata (type, owner,
80
- version, previous transaction, storage rebate) wrapping the inner struct bytes. This is what the
81
- `objectBcs` include option returns. Most of this metadata is already available as fields on the
82
- object response, so you typically only need `content`.
83
-
84
- ```typescript
85
-
86
- // Parse a full object envelope (from objectBcs include option)
87
- const envelope = bcs.Object.parse(object.objectBcs);
88
- console.log('Owner:', envelope.owner);
89
- console.log('Inner struct bytes:', envelope.data.Move.contents);
90
-
91
- // Serialize a full object envelope
92
- const serialized = bcs.Object.serialize({
93
- data: {
94
- Move: {
95
- type: { GasCoin: null },
96
- hasPublicTransfer: true,
97
- version: '1',
98
- contents: new Uint8Array([...]),
99
- },
100
- },
101
- owner: { AddressOwner: '0x...' },
102
- previousTransaction: '...',
103
- storageRebate: '1000',
104
- });
105
- ```
106
-
107
- > **Warning:** Do not pass `objectBcs` bytes to a Move struct parser — it contains wrapping metadata
108
- > that will cause parsing to fail. Use `content` for parsing Move struct fields. See the
109
- > [Core API docs](/sui/clients/core#objectbcs) for details.
110
-
111
- ## Working with Transaction Effects
112
-
113
- The `bcs.TransactionEffects` schema can be used to parse transaction effects:
114
-
115
- ```typescript
116
- // Parse transaction effects
117
- const effects = bcs.TransactionEffects.parse(effectsBytes);
118
-
119
- // Check execution status
120
- if (effects.V2.status.$kind === 'Success') {
121
- console.log('Transaction succeeded');
122
- } else {
123
- console.log('Transaction failed:', effects.V2.status.Failure.error);
124
- }
125
-
126
- // Access changed objects
127
- for (const [objectId, change] of effects.V2.changedObjects) {
128
- console.log('Object:', objectId);
129
- console.log('Output state:', change.outputState.$kind);
130
- }
131
- ```