@mysten/sui 2.4.0 → 2.5.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.
- package/CHANGELOG.md +21 -0
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/bcs/index.d.mts +20 -20
- package/dist/client/types.d.mts +13 -6
- package/dist/client/types.d.mts.map +1 -1
- package/dist/cryptography/signature.d.mts +6 -6
- package/dist/graphql/core.d.mts.map +1 -1
- package/dist/graphql/core.mjs +7 -3
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/graphql/generated/queries.mjs +1 -0
- package/dist/graphql/generated/queries.mjs.map +1 -1
- package/dist/grpc/core.d.mts.map +1 -1
- package/dist/grpc/core.mjs +7 -3
- package/dist/grpc/core.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts.map +1 -1
- package/dist/jsonRpc/core.d.mts +1 -9
- package/dist/jsonRpc/core.d.mts.map +1 -1
- package/dist/jsonRpc/core.mjs +10 -4
- package/dist/jsonRpc/core.mjs.map +1 -1
- package/dist/keypairs/ed25519/keypair.d.mts +3 -1
- package/dist/keypairs/ed25519/keypair.d.mts.map +1 -1
- package/dist/keypairs/ed25519/keypair.mjs +5 -1
- package/dist/keypairs/ed25519/keypair.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +9 -9
- package/dist/transactions/Transaction.d.mts.map +1 -1
- package/dist/transactions/executor/parallel.mjs +1 -1
- package/dist/transactions/executor/parallel.mjs.map +1 -1
- package/dist/utils/sui-types.d.mts.map +1 -1
- package/dist/utils/sui-types.mjs +8 -0
- package/dist/utils/sui-types.mjs.map +1 -1
- package/dist/version.mjs +2 -2
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/dist/zklogin/bcs.d.mts.map +1 -1
- package/package.json +1 -1
- package/src/client/types.ts +8 -6
- package/src/graphql/core.ts +14 -4
- package/src/graphql/generated/queries.ts +2 -1
- package/src/graphql/queries/getDynamicFields.graphql +1 -0
- package/src/grpc/core.ts +20 -16
- package/src/jsonRpc/core.ts +11 -4
- package/src/keypairs/ed25519/keypair.ts +5 -1
- package/src/transactions/executor/parallel.ts +0 -1
- package/src/utils/sui-types.ts +15 -0
- package/src/version.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sui-types.mjs","names":[],"sources":["../../src/utils/sui-types.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase58, splitGenericParameters } from '@mysten/bcs';\n\nimport { isValidNamedPackage } from './move-registry.js';\n\nconst TX_DIGEST_LENGTH = 32;\n\n/** Returns whether the tx digest is valid based on the serialization format */\nexport function isValidTransactionDigest(value: string): value is string {\n\ttry {\n\t\tconst buffer = fromBase58(value);\n\t\treturn buffer.length === TX_DIGEST_LENGTH;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n// TODO - can we automatically sync this with rust length definition?\n// Source of truth is\n// https://github.com/MystenLabs/sui/blob/acb2b97ae21f47600e05b0d28127d88d0725561d/crates/sui-types/src/base_types.rs#L67\n// which uses the Move account address length\n// https://github.com/move-language/move/blob/67ec40dc50c66c34fd73512fcc412f3b68d67235/language/move-core/types/src/account_address.rs#L23 .\n\nexport const SUI_ADDRESS_LENGTH = 32;\nexport function isValidSuiAddress(value: string): value is string {\n\treturn isHex(value) && getHexByteLength(value) === SUI_ADDRESS_LENGTH;\n}\n\nexport function isValidSuiObjectId(value: string): boolean {\n\treturn isValidSuiAddress(value);\n}\n\nconst MOVE_IDENTIFIER_REGEX = /^[a-zA-Z][a-zA-Z0-9_]*$/;\n\nexport function isValidMoveIdentifier(name: string): boolean {\n\treturn MOVE_IDENTIFIER_REGEX.test(name);\n}\n\nconst PRIMITIVE_TYPE_TAGS = [\n\t'bool',\n\t'u8',\n\t'u16',\n\t'u32',\n\t'u64',\n\t'u128',\n\t'u256',\n\t'address',\n\t'signer',\n];\n\nconst VECTOR_TYPE_REGEX = /^vector<(.+)>$/;\n\nfunction isValidTypeTag(type: string): boolean {\n\tif (PRIMITIVE_TYPE_TAGS.includes(type)) return true;\n\n\tconst vectorMatch = type.match(VECTOR_TYPE_REGEX);\n\tif (vectorMatch) return isValidTypeTag(vectorMatch[1]);\n\n\tif (type.includes('::')) return isValidStructTag(type);\n\n\treturn false;\n}\n\nfunction isValidParsedStructTag(tag: StructTag): boolean {\n\tif (!isValidSuiAddress(tag.address) && !isValidNamedPackage(tag.address)) {\n\t\treturn false;\n\t}\n\n\tif (!isValidMoveIdentifier(tag.module) || !isValidMoveIdentifier(tag.name)) {\n\t\treturn false;\n\t}\n\n\treturn tag.typeParams.every((param) => {\n\t\tif (typeof param === 'string') {\n\t\t\treturn isValidTypeTag(param);\n\t\t}\n\t\treturn isValidParsedStructTag(param);\n\t});\n}\n\nexport function isValidStructTag(type: string): boolean {\n\ttry {\n\t\tconst tag = parseStructTag(type);\n\t\treturn isValidParsedStructTag(tag);\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport type StructTag = {\n\taddress: string;\n\tmodule: string;\n\tname: string;\n\ttypeParams: (string | StructTag)[];\n};\n\nfunction parseTypeTag(type: string): string | StructTag {\n\tif (!type.includes('::')) return type;\n\n\treturn parseStructTag(type);\n}\n\nexport function parseStructTag(type: string): StructTag {\n\tconst parts = type.split('::');\n\n\tif (parts.length < 3) {\n\t\tthrow new Error(`Invalid struct tag: ${type}`);\n\t}\n\n\tconst [address, module] = parts;\n\tconst isMvrPackage = isValidNamedPackage(address);\n\n\tconst rest = type.slice(address.length + module.length + 4);\n\tconst name = rest.includes('<') ? rest.slice(0, rest.indexOf('<')) : rest;\n\tconst typeParams = rest.includes('<')\n\t\t? splitGenericParameters(rest.slice(rest.indexOf('<') + 1, rest.lastIndexOf('>'))).map(\n\t\t\t\t(typeParam) => parseTypeTag(typeParam.trim()),\n\t\t\t)\n\t\t: [];\n\n\treturn {\n\t\taddress: isMvrPackage ? address : normalizeSuiAddress(address),\n\t\tmodule,\n\t\tname,\n\t\ttypeParams,\n\t};\n}\n\nexport function normalizeStructTag(type: string | StructTag): string {\n\tconst { address, module, name, typeParams } =\n\t\ttypeof type === 'string' ? parseStructTag(type) : type;\n\n\tconst formattedTypeParams =\n\t\ttypeParams?.length > 0\n\t\t\t? `<${typeParams\n\t\t\t\t\t.map((typeParam) =>\n\t\t\t\t\t\ttypeof typeParam === 'string' ? typeParam : normalizeStructTag(typeParam),\n\t\t\t\t\t)\n\t\t\t\t\t.join(',')}>`\n\t\t\t: '';\n\n\treturn `${address}::${module}::${name}${formattedTypeParams}`;\n}\n\n/**\n * Perform the following operations:\n * 1. Make the address lower case\n * 2. Prepend `0x` if the string does not start with `0x`.\n * 3. Add more zeros if the length of the address(excluding `0x`) is less than `SUI_ADDRESS_LENGTH`\n *\n * WARNING: if the address value itself starts with `0x`, e.g., `0x0x`, the default behavior\n * is to treat the first `0x` not as part of the address. The default behavior can be overridden by\n * setting `forceAdd0x` to true\n *\n */\nexport function normalizeSuiAddress(value: string, forceAdd0x: boolean = false): string {\n\tlet address = value.toLowerCase();\n\tif (!forceAdd0x && address.startsWith('0x')) {\n\t\taddress = address.slice(2);\n\t}\n\treturn `0x${address.padStart(SUI_ADDRESS_LENGTH * 2, '0')}`;\n}\n\nexport function normalizeSuiObjectId(value: string, forceAdd0x: boolean = false): string {\n\treturn normalizeSuiAddress(value, forceAdd0x);\n}\n\nfunction isHex(value: string): boolean {\n\treturn /^(0x|0X)?[a-fA-F0-9]+$/.test(value) && value.length % 2 === 0;\n}\n\nfunction getHexByteLength(value: string): number {\n\treturn /^(0x|0X)/.test(value) ? (value.length - 2) / 2 : value.length / 2;\n}\n"],"mappings":";;;;AAOA,MAAM,mBAAmB;;AAGzB,SAAgB,yBAAyB,OAAgC;AACxE,KAAI;AAEH,SADe,WAAW,MAAM,CAClB,WAAW;SAClB;AACP,SAAO;;;AAUT,MAAa,qBAAqB;AAClC,SAAgB,kBAAkB,OAAgC;AACjE,QAAO,MAAM,MAAM,IAAI,iBAAiB,MAAM,KAAK;;AAGpD,SAAgB,mBAAmB,OAAwB;AAC1D,QAAO,kBAAkB,MAAM;;AAGhC,MAAM,wBAAwB;AAE9B,SAAgB,sBAAsB,MAAuB;AAC5D,QAAO,sBAAsB,KAAK,KAAK;;AAGxC,MAAM,sBAAsB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAED,MAAM,oBAAoB;AAE1B,SAAS,eAAe,MAAuB;AAC9C,KAAI,oBAAoB,SAAS,KAAK,CAAE,QAAO;CAE/C,MAAM,cAAc,KAAK,MAAM,kBAAkB;AACjD,KAAI,YAAa,QAAO,eAAe,YAAY,GAAG;AAEtD,KAAI,KAAK,SAAS,KAAK,CAAE,QAAO,iBAAiB,KAAK;AAEtD,QAAO;;AAGR,SAAS,uBAAuB,KAAyB;AACxD,KAAI,CAAC,kBAAkB,IAAI,QAAQ,IAAI,CAAC,oBAAoB,IAAI,QAAQ,CACvE,QAAO;AAGR,KAAI,CAAC,sBAAsB,IAAI,OAAO,IAAI,CAAC,sBAAsB,IAAI,KAAK,CACzE,QAAO;AAGR,QAAO,IAAI,WAAW,OAAO,UAAU;AACtC,MAAI,OAAO,UAAU,SACpB,QAAO,eAAe,MAAM;AAE7B,SAAO,uBAAuB,MAAM;GACnC;;AAGH,SAAgB,iBAAiB,MAAuB;AACvD,KAAI;AAEH,SAAO,uBADK,eAAe,KAAK,CACE;SAC3B;AACP,SAAO;;;AAWT,SAAS,aAAa,MAAkC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B,OAAO,WAAW;;AAG9C,SAAS,MAAM,OAAwB;AACtC,QAAO,yBAAyB,KAAK,MAAM,IAAI,MAAM,SAAS,MAAM;;AAGrE,SAAS,iBAAiB,OAAuB;AAChD,QAAO,WAAW,KAAK,MAAM,IAAI,MAAM,SAAS,KAAK,IAAI,MAAM,SAAS"}
|
|
1
|
+
{"version":3,"file":"sui-types.mjs","names":[],"sources":["../../src/utils/sui-types.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase58, splitGenericParameters } from '@mysten/bcs';\n\nimport { isValidNamedPackage } from './move-registry.js';\n\nconst TX_DIGEST_LENGTH = 32;\n\n/** Returns whether the tx digest is valid based on the serialization format */\nexport function isValidTransactionDigest(value: string): value is string {\n\ttry {\n\t\tconst buffer = fromBase58(value);\n\t\treturn buffer.length === TX_DIGEST_LENGTH;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n// TODO - can we automatically sync this with rust length definition?\n// Source of truth is\n// https://github.com/MystenLabs/sui/blob/acb2b97ae21f47600e05b0d28127d88d0725561d/crates/sui-types/src/base_types.rs#L67\n// which uses the Move account address length\n// https://github.com/move-language/move/blob/67ec40dc50c66c34fd73512fcc412f3b68d67235/language/move-core/types/src/account_address.rs#L23 .\n\nexport const SUI_ADDRESS_LENGTH = 32;\nexport function isValidSuiAddress(value: string): value is string {\n\treturn isHex(value) && getHexByteLength(value) === SUI_ADDRESS_LENGTH;\n}\n\nexport function isValidSuiObjectId(value: string): boolean {\n\treturn isValidSuiAddress(value);\n}\n\nconst MOVE_IDENTIFIER_REGEX = /^[a-zA-Z][a-zA-Z0-9_]*$/;\n\nexport function isValidMoveIdentifier(name: string): boolean {\n\treturn MOVE_IDENTIFIER_REGEX.test(name);\n}\n\nconst PRIMITIVE_TYPE_TAGS = [\n\t'bool',\n\t'u8',\n\t'u16',\n\t'u32',\n\t'u64',\n\t'u128',\n\t'u256',\n\t'address',\n\t'signer',\n];\n\nconst VECTOR_TYPE_REGEX = /^vector<(.+)>$/;\n\nfunction isValidTypeTag(type: string): boolean {\n\tif (PRIMITIVE_TYPE_TAGS.includes(type)) return true;\n\n\tconst vectorMatch = type.match(VECTOR_TYPE_REGEX);\n\tif (vectorMatch) return isValidTypeTag(vectorMatch[1]);\n\n\tif (type.includes('::')) return isValidStructTag(type);\n\n\treturn false;\n}\n\nfunction isValidParsedStructTag(tag: StructTag): boolean {\n\tif (!isValidSuiAddress(tag.address) && !isValidNamedPackage(tag.address)) {\n\t\treturn false;\n\t}\n\n\tif (!isValidMoveIdentifier(tag.module) || !isValidMoveIdentifier(tag.name)) {\n\t\treturn false;\n\t}\n\n\treturn tag.typeParams.every((param) => {\n\t\tif (typeof param === 'string') {\n\t\t\treturn isValidTypeTag(param);\n\t\t}\n\t\treturn isValidParsedStructTag(param);\n\t});\n}\n\nexport function isValidStructTag(type: string): boolean {\n\ttry {\n\t\tconst tag = parseStructTag(type);\n\t\treturn isValidParsedStructTag(tag);\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport type StructTag = {\n\taddress: string;\n\tmodule: string;\n\tname: string;\n\ttypeParams: (string | StructTag)[];\n};\n\nfunction parseTypeTag(type: string): string | StructTag {\n\tif (type.startsWith('vector<')) {\n\t\tif (!type.endsWith('>')) {\n\t\t\tthrow new Error(`Invalid type tag: ${type}`);\n\t\t}\n\t\tconst inner = type.slice(7, -1);\n\t\tif (!inner) {\n\t\t\tthrow new Error(`Invalid type tag: ${type}`);\n\t\t}\n\t\tconst parsed = parseTypeTag(inner);\n\t\tif (typeof parsed === 'string') {\n\t\t\treturn `vector<${parsed}>`;\n\t\t}\n\t\treturn `vector<${normalizeStructTag(parsed)}>`;\n\t}\n\n\tif (!type.includes('::')) return type;\n\n\treturn parseStructTag(type);\n}\n\nexport function parseStructTag(type: string): StructTag {\n\tconst parts = type.split('::');\n\n\tif (parts.length < 3) {\n\t\tthrow new Error(`Invalid struct tag: ${type}`);\n\t}\n\n\tconst [address, module] = parts;\n\tconst isMvrPackage = isValidNamedPackage(address);\n\n\tconst rest = type.slice(address.length + module.length + 4);\n\tconst name = rest.includes('<') ? rest.slice(0, rest.indexOf('<')) : rest;\n\tconst typeParams = rest.includes('<')\n\t\t? splitGenericParameters(rest.slice(rest.indexOf('<') + 1, rest.lastIndexOf('>'))).map(\n\t\t\t\t(typeParam) => parseTypeTag(typeParam.trim()),\n\t\t\t)\n\t\t: [];\n\n\treturn {\n\t\taddress: isMvrPackage ? address : normalizeSuiAddress(address),\n\t\tmodule,\n\t\tname,\n\t\ttypeParams,\n\t};\n}\n\nexport function normalizeStructTag(type: string | StructTag): string {\n\tconst { address, module, name, typeParams } =\n\t\ttypeof type === 'string' ? parseStructTag(type) : type;\n\n\tconst formattedTypeParams =\n\t\ttypeParams?.length > 0\n\t\t\t? `<${typeParams\n\t\t\t\t\t.map((typeParam) =>\n\t\t\t\t\t\ttypeof typeParam === 'string' ? typeParam : normalizeStructTag(typeParam),\n\t\t\t\t\t)\n\t\t\t\t\t.join(',')}>`\n\t\t\t: '';\n\n\treturn `${address}::${module}::${name}${formattedTypeParams}`;\n}\n\n/**\n * Perform the following operations:\n * 1. Make the address lower case\n * 2. Prepend `0x` if the string does not start with `0x`.\n * 3. Add more zeros if the length of the address(excluding `0x`) is less than `SUI_ADDRESS_LENGTH`\n *\n * WARNING: if the address value itself starts with `0x`, e.g., `0x0x`, the default behavior\n * is to treat the first `0x` not as part of the address. The default behavior can be overridden by\n * setting `forceAdd0x` to true\n *\n */\nexport function normalizeSuiAddress(value: string, forceAdd0x: boolean = false): string {\n\tlet address = value.toLowerCase();\n\tif (!forceAdd0x && address.startsWith('0x')) {\n\t\taddress = address.slice(2);\n\t}\n\treturn `0x${address.padStart(SUI_ADDRESS_LENGTH * 2, '0')}`;\n}\n\nexport function normalizeSuiObjectId(value: string, forceAdd0x: boolean = false): string {\n\treturn normalizeSuiAddress(value, forceAdd0x);\n}\n\nfunction isHex(value: string): boolean {\n\treturn /^(0x|0X)?[a-fA-F0-9]+$/.test(value) && value.length % 2 === 0;\n}\n\nfunction getHexByteLength(value: string): number {\n\treturn /^(0x|0X)/.test(value) ? (value.length - 2) / 2 : value.length / 2;\n}\n"],"mappings":";;;;AAOA,MAAM,mBAAmB;;AAGzB,SAAgB,yBAAyB,OAAgC;AACxE,KAAI;AAEH,SADe,WAAW,MAAM,CAClB,WAAW;SAClB;AACP,SAAO;;;AAUT,MAAa,qBAAqB;AAClC,SAAgB,kBAAkB,OAAgC;AACjE,QAAO,MAAM,MAAM,IAAI,iBAAiB,MAAM,KAAK;;AAGpD,SAAgB,mBAAmB,OAAwB;AAC1D,QAAO,kBAAkB,MAAM;;AAGhC,MAAM,wBAAwB;AAE9B,SAAgB,sBAAsB,MAAuB;AAC5D,QAAO,sBAAsB,KAAK,KAAK;;AAGxC,MAAM,sBAAsB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAED,MAAM,oBAAoB;AAE1B,SAAS,eAAe,MAAuB;AAC9C,KAAI,oBAAoB,SAAS,KAAK,CAAE,QAAO;CAE/C,MAAM,cAAc,KAAK,MAAM,kBAAkB;AACjD,KAAI,YAAa,QAAO,eAAe,YAAY,GAAG;AAEtD,KAAI,KAAK,SAAS,KAAK,CAAE,QAAO,iBAAiB,KAAK;AAEtD,QAAO;;AAGR,SAAS,uBAAuB,KAAyB;AACxD,KAAI,CAAC,kBAAkB,IAAI,QAAQ,IAAI,CAAC,oBAAoB,IAAI,QAAQ,CACvE,QAAO;AAGR,KAAI,CAAC,sBAAsB,IAAI,OAAO,IAAI,CAAC,sBAAsB,IAAI,KAAK,CACzE,QAAO;AAGR,QAAO,IAAI,WAAW,OAAO,UAAU;AACtC,MAAI,OAAO,UAAU,SACpB,QAAO,eAAe,MAAM;AAE7B,SAAO,uBAAuB,MAAM;GACnC;;AAGH,SAAgB,iBAAiB,MAAuB;AACvD,KAAI;AAEH,SAAO,uBADK,eAAe,KAAK,CACE;SAC3B;AACP,SAAO;;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,KAAK,cACL,OAAO,cAAc,WAAW,YAAY,mBAAmB,UAAU,CACzE,CACA,KAAK,IAAI,CAAC,KACX;;;;;;;;;;;;;AAgBL,SAAgB,oBAAoB,OAAe,aAAsB,OAAe;CACvF,IAAI,UAAU,MAAM,aAAa;AACjC,KAAI,CAAC,cAAc,QAAQ,WAAW,KAAK,CAC1C,WAAU,QAAQ,MAAM,EAAE;AAE3B,QAAO,KAAK,QAAQ,SAAS,qBAAqB,GAAG,IAAI;;AAG1D,SAAgB,qBAAqB,OAAe,aAAsB,OAAe;AACxF,QAAO,oBAAoB,OAAO,WAAW;;AAG9C,SAAS,MAAM,OAAwB;AACtC,QAAO,yBAAyB,KAAK,MAAM,IAAI,MAAM,SAAS,MAAM;;AAGrE,SAAS,iBAAiB,OAAuB;AAChD,QAAO,WAAW,KAAK,MAAM,IAAI,MAAM,SAAS,KAAK,IAAI,MAAM,SAAS"}
|
package/dist/version.mjs
CHANGED
package/dist/version.mjs.map
CHANGED
|
@@ -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.
|
|
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.5.1';\nexport const TARGETED_RPC_VERSION = '1.68.0';\n"],"mappings":";AAKA,MAAa,kBAAkB;AAC/B,MAAa,uBAAuB"}
|
package/dist/zklogin/bcs.d.mts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _mysten_bcs817 from "@mysten/bcs";
|
|
2
2
|
import { InferBcsInput } from "@mysten/bcs";
|
|
3
3
|
|
|
4
4
|
//#region src/zklogin/bcs.d.ts
|
|
5
|
-
declare const zkLoginSignature:
|
|
6
|
-
inputs:
|
|
7
|
-
proofPoints:
|
|
8
|
-
a:
|
|
5
|
+
declare const zkLoginSignature: _mysten_bcs817.BcsStruct<{
|
|
6
|
+
inputs: _mysten_bcs817.BcsStruct<{
|
|
7
|
+
proofPoints: _mysten_bcs817.BcsStruct<{
|
|
8
|
+
a: _mysten_bcs817.BcsType<string[], Iterable<string> & {
|
|
9
9
|
length: number;
|
|
10
10
|
}, string>;
|
|
11
|
-
b:
|
|
11
|
+
b: _mysten_bcs817.BcsType<string[][], Iterable<Iterable<string> & {
|
|
12
12
|
length: number;
|
|
13
13
|
}> & {
|
|
14
14
|
length: number;
|
|
15
15
|
}, string>;
|
|
16
|
-
c:
|
|
16
|
+
c: _mysten_bcs817.BcsType<string[], Iterable<string> & {
|
|
17
17
|
length: number;
|
|
18
18
|
}, string>;
|
|
19
19
|
}, string>;
|
|
20
|
-
issBase64Details:
|
|
21
|
-
value:
|
|
22
|
-
indexMod4:
|
|
20
|
+
issBase64Details: _mysten_bcs817.BcsStruct<{
|
|
21
|
+
value: _mysten_bcs817.BcsType<string, string, "string">;
|
|
22
|
+
indexMod4: _mysten_bcs817.BcsType<number, number, "u8">;
|
|
23
23
|
}, string>;
|
|
24
|
-
headerBase64:
|
|
25
|
-
addressSeed:
|
|
24
|
+
headerBase64: _mysten_bcs817.BcsType<string, string, "string">;
|
|
25
|
+
addressSeed: _mysten_bcs817.BcsType<string, string, "string">;
|
|
26
26
|
}, string>;
|
|
27
|
-
maxEpoch:
|
|
28
|
-
userSignature:
|
|
27
|
+
maxEpoch: _mysten_bcs817.BcsType<string, string | number | bigint, "u64">;
|
|
28
|
+
userSignature: _mysten_bcs817.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"],"sourcesContent":[],"mappings":";;;;cAMa,
|
|
1
|
+
{"version":3,"file":"bcs.d.mts","names":[],"sources":["../../src/zklogin/bcs.ts"],"sourcesContent":[],"mappings":";;;;cAMa,iCAAgB;;;MAAhB,CAAA,wBAgBX,CAAA,MAAA,EAAA,UAAA,CAAA,MAAA,CAAA,GAAA;;;;;;;;;;;;;;;;;;;;eAhB2B,wBAAA,WAAA,gBAAA,CAAA,UAAA,CAAA,MAAA,CAAA,EAAA,YAAA,CAAA;CAAA,EAAA,MAAA,CAAA;AAkBjB,KAAA,gBAAA,GAAmB,aAAqB,CAAA,OAAA,gBAAR,CAAA;AAChC,KAAA,sBAAA,GAAyB,gBAAA,CAAA,QAAgB,CAAA"}
|
package/package.json
CHANGED
package/src/client/types.ts
CHANGED
|
@@ -155,15 +155,17 @@ export namespace SuiClientTypes {
|
|
|
155
155
|
balance: string;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
export type DynamicFieldEntry = {
|
|
159
|
+
fieldId: string;
|
|
160
|
+
type: string;
|
|
161
|
+
name: DynamicFieldName;
|
|
162
|
+
valueType: string;
|
|
163
|
+
} & ({ $kind: 'DynamicField'; childId?: never } | { $kind: 'DynamicObject'; childId: string });
|
|
164
|
+
|
|
158
165
|
export interface ListDynamicFieldsResponse {
|
|
159
166
|
hasNextPage: boolean;
|
|
160
167
|
cursor: string | null;
|
|
161
|
-
dynamicFields:
|
|
162
|
-
fieldId: string;
|
|
163
|
-
type: string;
|
|
164
|
-
name: DynamicFieldName;
|
|
165
|
-
valueType: string;
|
|
166
|
-
}[];
|
|
168
|
+
dynamicFields: DynamicFieldEntry[];
|
|
167
169
|
}
|
|
168
170
|
|
|
169
171
|
export interface GetDynamicFieldResponse {
|
package/src/graphql/core.ts
CHANGED
|
@@ -571,19 +571,25 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
571
571
|
);
|
|
572
572
|
|
|
573
573
|
return {
|
|
574
|
-
dynamicFields: result.nodes.map((dynamicField) => {
|
|
574
|
+
dynamicFields: result.nodes.map((dynamicField): SuiClientTypes.DynamicFieldEntry => {
|
|
575
575
|
const valueType =
|
|
576
576
|
dynamicField.value?.__typename === 'MoveObject'
|
|
577
577
|
? dynamicField.value.contents?.type?.repr!
|
|
578
578
|
: dynamicField.value?.type?.repr!;
|
|
579
|
+
const isDynamicObject = dynamicField.value?.__typename === 'MoveObject';
|
|
580
|
+
const derivedNameType = isDynamicObject
|
|
581
|
+
? `0x2::dynamic_object_field::Wrapper<${dynamicField.name?.type?.repr}>`
|
|
582
|
+
: dynamicField.name?.type?.repr!;
|
|
583
|
+
|
|
579
584
|
return {
|
|
585
|
+
$kind: isDynamicObject ? 'DynamicObject' : 'DynamicField',
|
|
580
586
|
fieldId: deriveDynamicFieldID(
|
|
581
587
|
options.parentId,
|
|
582
|
-
|
|
588
|
+
derivedNameType,
|
|
583
589
|
fromBase64(dynamicField.name?.bcs!),
|
|
584
590
|
),
|
|
585
591
|
type: normalizeStructTag(
|
|
586
|
-
|
|
592
|
+
isDynamicObject
|
|
587
593
|
? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${dynamicField.name?.type?.repr}>,0x2::object::ID>`
|
|
588
594
|
: `0x2::dynamic_field::Field<${dynamicField.name?.type?.repr},${valueType}>`,
|
|
589
595
|
),
|
|
@@ -592,7 +598,11 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
592
598
|
bcs: fromBase64(dynamicField.name?.bcs!),
|
|
593
599
|
},
|
|
594
600
|
valueType,
|
|
595
|
-
|
|
601
|
+
childId:
|
|
602
|
+
isDynamicObject && dynamicField.value?.__typename === 'MoveObject'
|
|
603
|
+
? dynamicField.value.address
|
|
604
|
+
: undefined,
|
|
605
|
+
} as SuiClientTypes.DynamicFieldEntry;
|
|
596
606
|
}),
|
|
597
607
|
cursor: result.pageInfo.endCursor ?? null,
|
|
598
608
|
hasNextPage: result.pageInfo.hasNextPage,
|
|
@@ -4648,7 +4648,7 @@ export type GetDynamicFieldsQueryVariables = Exact<{
|
|
|
4648
4648
|
|
|
4649
4649
|
|
|
4650
4650
|
export type GetDynamicFieldsQuery = { __typename?: 'Query', address?: { __typename?: 'Address', dynamicFields?: { __typename?: 'DynamicFieldConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'DynamicField', name?: { __typename?: 'MoveValue', bcs?: string | null, type?: { __typename?: 'MoveType', repr: string } | null } | null, value?:
|
|
4651
|
-
| { __typename: 'MoveObject', contents?: { __typename?: 'MoveValue', type?: { __typename?: 'MoveType', repr: string } | null } | null }
|
|
4651
|
+
| { __typename: 'MoveObject', address: string, contents?: { __typename?: 'MoveValue', type?: { __typename?: 'MoveType', repr: string } | null } | null }
|
|
4652
4652
|
| { __typename: 'MoveValue', type?: { __typename?: 'MoveType', repr: string } | null }
|
|
4653
4653
|
| null }> } | null } | null };
|
|
4654
4654
|
|
|
@@ -5147,6 +5147,7 @@ export const GetDynamicFieldsDocument = new TypedDocumentString(`
|
|
|
5147
5147
|
}
|
|
5148
5148
|
}
|
|
5149
5149
|
... on MoveObject {
|
|
5150
|
+
address
|
|
5150
5151
|
contents {
|
|
5151
5152
|
type {
|
|
5152
5153
|
repr
|
package/src/grpc/core.ts
CHANGED
|
@@ -566,26 +566,30 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
566
566
|
pageToken: options.cursor ? fromBase64(options.cursor) : undefined,
|
|
567
567
|
pageSize: options.limit,
|
|
568
568
|
readMask: {
|
|
569
|
-
paths: ['field_id', 'name', 'value_type', 'kind'],
|
|
569
|
+
paths: ['field_id', 'name', 'value_type', 'kind', 'child_id'],
|
|
570
570
|
},
|
|
571
571
|
});
|
|
572
572
|
|
|
573
573
|
return {
|
|
574
|
-
dynamicFields: response.response.dynamicFields.map(
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
574
|
+
dynamicFields: response.response.dynamicFields.map(
|
|
575
|
+
(field): SuiClientTypes.DynamicFieldEntry => {
|
|
576
|
+
const isDynamicObject = field.kind === DynamicField_DynamicFieldKind.OBJECT;
|
|
577
|
+
const fieldType = isDynamicObject
|
|
578
|
+
? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${field.name?.name!}>,0x2::object::ID>`
|
|
579
|
+
: `0x2::dynamic_field::Field<${field.name?.name!},${field.valueType!}>`;
|
|
580
|
+
return {
|
|
581
|
+
$kind: isDynamicObject ? 'DynamicObject' : 'DynamicField',
|
|
582
|
+
fieldId: field.fieldId!,
|
|
583
|
+
name: {
|
|
584
|
+
type: field.name?.name!,
|
|
585
|
+
bcs: field.name?.value!,
|
|
586
|
+
},
|
|
587
|
+
valueType: field.valueType!,
|
|
588
|
+
type: normalizeStructTag(fieldType),
|
|
589
|
+
childId: field.childId,
|
|
590
|
+
} as SuiClientTypes.DynamicFieldEntry;
|
|
591
|
+
},
|
|
592
|
+
),
|
|
589
593
|
cursor: response.response.nextPageToken ? toBase64(response.response.nextPageToken) : null,
|
|
590
594
|
hasNextPage: response.response.nextPageToken !== undefined,
|
|
591
595
|
};
|
package/src/jsonRpc/core.ts
CHANGED
|
@@ -22,6 +22,7 @@ import { coreClientResolveTransactionPlugin } from '../client/core-resolver.js';
|
|
|
22
22
|
import { TransactionDataBuilder } from '../transactions/TransactionData.js';
|
|
23
23
|
import { chunk } from '@mysten/utils';
|
|
24
24
|
import { normalizeSuiAddress, normalizeStructTag } from '../utils/sui-types.js';
|
|
25
|
+
import { deriveDynamicFieldID } from '../utils/dynamic-fields.js';
|
|
25
26
|
import { SUI_FRAMEWORK_ADDRESS, SUI_SYSTEM_ADDRESS } from '../utils/constants.js';
|
|
26
27
|
import { CoreClient } from '../client/core.js';
|
|
27
28
|
import type { SuiClientTypes } from '../client/types.js';
|
|
@@ -503,21 +504,27 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
503
504
|
});
|
|
504
505
|
|
|
505
506
|
return {
|
|
506
|
-
dynamicFields: dynamicFields.data.map((dynamicField) => {
|
|
507
|
+
dynamicFields: dynamicFields.data.map((dynamicField): SuiClientTypes.DynamicFieldEntry => {
|
|
507
508
|
const isDynamicObject = dynamicField.type === 'DynamicObject';
|
|
508
509
|
const fullType = isDynamicObject
|
|
509
510
|
? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${dynamicField.name.type}>, 0x2::object::ID>`
|
|
510
511
|
: `0x2::dynamic_field::Field<${dynamicField.name.type}, ${dynamicField.objectType}>`;
|
|
511
512
|
|
|
513
|
+
const bcsBytes = fromBase64(dynamicField.bcsName);
|
|
514
|
+
const derivedNameType = isDynamicObject
|
|
515
|
+
? `0x2::dynamic_object_field::Wrapper<${dynamicField.name.type}>`
|
|
516
|
+
: dynamicField.name.type;
|
|
512
517
|
return {
|
|
513
|
-
|
|
518
|
+
$kind: isDynamicObject ? 'DynamicObject' : 'DynamicField',
|
|
519
|
+
fieldId: deriveDynamicFieldID(options.parentId, derivedNameType, bcsBytes),
|
|
514
520
|
type: normalizeStructTag(fullType),
|
|
515
521
|
name: {
|
|
516
522
|
type: dynamicField.name.type,
|
|
517
|
-
bcs:
|
|
523
|
+
bcs: bcsBytes,
|
|
518
524
|
},
|
|
519
525
|
valueType: dynamicField.objectType,
|
|
520
|
-
|
|
526
|
+
childId: isDynamicObject ? dynamicField.objectId : undefined,
|
|
527
|
+
} as SuiClientTypes.DynamicFieldEntry;
|
|
521
528
|
}),
|
|
522
529
|
hasNextPage: dynamicFields.hasNextPage,
|
|
523
530
|
cursor: dynamicFields.nextCursor,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Mysten Labs, Inc.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { toHex } from '@mysten/bcs';
|
|
4
5
|
import { ed25519 } from '@noble/curves/ed25519.js';
|
|
5
6
|
|
|
6
7
|
import {
|
|
@@ -166,14 +167,17 @@ export class Ed25519Keypair extends Keypair {
|
|
|
166
167
|
*
|
|
167
168
|
* If path is none, it will default to m/44'/784'/0'/0'/0', otherwise the path must
|
|
168
169
|
* be compliant to SLIP-0010 in form m/44'/784'/{account_index}'/{change_index}'/{address_index}'.
|
|
170
|
+
*
|
|
171
|
+
* @param seed - The seed as a hex string or Uint8Array.
|
|
169
172
|
*/
|
|
170
|
-
static deriveKeypairFromSeed(
|
|
173
|
+
static deriveKeypairFromSeed(seed: string | Uint8Array, path?: string): Ed25519Keypair {
|
|
171
174
|
if (path == null) {
|
|
172
175
|
path = DEFAULT_ED25519_DERIVATION_PATH;
|
|
173
176
|
}
|
|
174
177
|
if (!isValidHardenedPath(path)) {
|
|
175
178
|
throw new Error('Invalid derivation path');
|
|
176
179
|
}
|
|
180
|
+
const seedHex = typeof seed === 'string' ? seed : toHex(seed);
|
|
177
181
|
const { key } = derivePath(path, seedHex);
|
|
178
182
|
|
|
179
183
|
return Ed25519Keypair.fromSecretKey(key);
|
|
@@ -262,7 +262,6 @@ export class ParallelTransactionExecutor {
|
|
|
262
262
|
if (gasOwner === this.#signer.toSuiAddress()) {
|
|
263
263
|
const totalUsed =
|
|
264
264
|
BigInt(gasUsed.computationCost) +
|
|
265
|
-
BigInt(gasUsed.storageCost) +
|
|
266
265
|
BigInt(gasUsed.storageCost) -
|
|
267
266
|
BigInt(gasUsed.storageRebate);
|
|
268
267
|
const remainingBalance = coin.balance - totalUsed;
|
package/src/utils/sui-types.ts
CHANGED
|
@@ -97,6 +97,21 @@ export type StructTag = {
|
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
function parseTypeTag(type: string): string | StructTag {
|
|
100
|
+
if (type.startsWith('vector<')) {
|
|
101
|
+
if (!type.endsWith('>')) {
|
|
102
|
+
throw new Error(`Invalid type tag: ${type}`);
|
|
103
|
+
}
|
|
104
|
+
const inner = type.slice(7, -1);
|
|
105
|
+
if (!inner) {
|
|
106
|
+
throw new Error(`Invalid type tag: ${type}`);
|
|
107
|
+
}
|
|
108
|
+
const parsed = parseTypeTag(inner);
|
|
109
|
+
if (typeof parsed === 'string') {
|
|
110
|
+
return `vector<${parsed}>`;
|
|
111
|
+
}
|
|
112
|
+
return `vector<${normalizeStructTag(parsed)}>`;
|
|
113
|
+
}
|
|
114
|
+
|
|
100
115
|
if (!type.includes('::')) return type;
|
|
101
116
|
|
|
102
117
|
return parseStructTag(type);
|
package/src/version.ts
CHANGED