@mysten/sui 2.13.0 → 2.13.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/CHANGELOG.md +17 -0
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/bcs/index.d.mts +20 -20
- package/dist/client/core-resolver.d.mts.map +1 -1
- package/dist/client/core-resolver.mjs +9 -6
- package/dist/client/core-resolver.mjs.map +1 -1
- package/dist/cryptography/signature.d.mts +6 -6
- 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_execution_service.client.d.mts +4 -4
- package/dist/jsonRpc/core.d.mts.map +1 -1
- package/dist/jsonRpc/core.mjs +12 -5
- package/dist/jsonRpc/core.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +9 -9
- package/dist/transactions/Transaction.d.mts.map +1 -1
- package/dist/transactions/data/internal.d.mts +109 -109
- package/dist/transactions/data/internal.d.mts.map +1 -1
- package/dist/transactions/data/v1.d.mts +220 -220
- package/dist/transactions/data/v1.d.mts.map +1 -1
- package/dist/transactions/data/v2.d.mts +16 -16
- package/dist/transactions/data/v2.d.mts.map +1 -1
- package/dist/utils/sui-types.d.mts.map +1 -1
- package/dist/utils/sui-types.mjs +2 -0
- package/dist/utils/sui-types.mjs.map +1 -1
- package/dist/version.mjs +1 -1
- 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/core-resolver.ts +17 -10
- package/src/jsonRpc/core.ts +16 -15
- package/src/utils/sui-types.ts +10 -0
- package/src/version.ts +1 -1
|
@@ -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.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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AM,GAAG,GAAG;AAC/B,MAAI,CAAC,MACJ,OAAM,IAAI,MAAM,qBAAqB,OAAO;EAE7C,MAAM,SAAS,aAAa,MAAM;AAClC,MAAI,OAAO,WAAW,SACrB,QAAO,UAAU,OAAO;AAEzB,SAAO,UAAU,mBAAmB,OAAO,CAAC;;AAG7C,KAAI,CAAC,KAAK,SAAS,KAAK,CAAE,QAAO;AAEjC,QAAO,eAAe,KAAK;;AAG5B,SAAgB,eAAe,MAAyB;CACvD,MAAM,QAAQ,KAAK,MAAM,KAAK;AAE9B,KAAI,MAAM,SAAS,EAClB,OAAM,IAAI,MAAM,uBAAuB,OAAO;CAG/C,MAAM,CAAC,SAAS,UAAU;
|
|
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\n\tif (!address || !module) {\n\t\tthrow new Error(`Invalid struct tag: ${type}`);\n\t}\n\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\n\tif (!name || (rest.includes('<') && !rest.endsWith('>'))) {\n\t\tthrow new Error(`Invalid struct tag: ${type}`);\n\t}\n\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,KA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.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.13.
|
|
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.13.2';\nexport const TARGETED_RPC_VERSION = '1.70.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_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:
|
|
6
|
-
inputs:
|
|
7
|
-
proofPoints:
|
|
8
|
-
a:
|
|
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:
|
|
11
|
+
b: _mysten_bcs1118.BcsType<string[][], Iterable<Iterable<string> & {
|
|
12
12
|
length: number;
|
|
13
13
|
}> & {
|
|
14
14
|
length: number;
|
|
15
15
|
}, string>;
|
|
16
|
-
c:
|
|
16
|
+
c: _mysten_bcs1118.BcsType<string[], Iterable<string> & {
|
|
17
17
|
length: number;
|
|
18
18
|
}, string>;
|
|
19
19
|
}, string>;
|
|
20
|
-
issBase64Details:
|
|
21
|
-
value:
|
|
22
|
-
indexMod4:
|
|
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:
|
|
25
|
-
addressSeed:
|
|
24
|
+
headerBase64: _mysten_bcs1118.BcsType<string, string, "string">;
|
|
25
|
+
addressSeed: _mysten_bcs1118.BcsType<string, string, "string">;
|
|
26
26
|
}, string>;
|
|
27
|
-
maxEpoch:
|
|
28
|
-
userSignature:
|
|
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,
|
|
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
|
@@ -25,6 +25,20 @@ const MAX_OBJECTS_PER_FETCH = 50;
|
|
|
25
25
|
const GAS_SAFE_OVERHEAD = 1000n;
|
|
26
26
|
const MAX_GAS = 50_000_000_000;
|
|
27
27
|
|
|
28
|
+
/** Compute a gas budget from gasUsed effects data. */
|
|
29
|
+
export function computeGasBudget(
|
|
30
|
+
gasUsed: { computationCost: string; storageCost: string; storageRebate: string },
|
|
31
|
+
gasPrice: bigint | string = 1n,
|
|
32
|
+
): string {
|
|
33
|
+
const safeOverhead = GAS_SAFE_OVERHEAD * BigInt(gasPrice);
|
|
34
|
+
const baseComputationCostWithOverhead = BigInt(gasUsed.computationCost) + safeOverhead;
|
|
35
|
+
const gasBudget =
|
|
36
|
+
baseComputationCostWithOverhead + BigInt(gasUsed.storageCost) - BigInt(gasUsed.storageRebate);
|
|
37
|
+
return String(
|
|
38
|
+
gasBudget > baseComputationCostWithOverhead ? gasBudget : baseComputationCostWithOverhead,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
28
42
|
function getClient(options: BuildTransactionOptions): ClientWithCoreApi {
|
|
29
43
|
if (!options.client) {
|
|
30
44
|
throw new Error(
|
|
@@ -152,16 +166,9 @@ async function setGasBudget(transactionData: TransactionDataBuilder, client: Cli
|
|
|
152
166
|
});
|
|
153
167
|
}
|
|
154
168
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const baseComputationCostWithOverhead = BigInt(gasUsed.computationCost) + safeOverhead;
|
|
159
|
-
|
|
160
|
-
const gasBudget =
|
|
161
|
-
baseComputationCostWithOverhead + BigInt(gasUsed.storageCost) - BigInt(gasUsed.storageRebate);
|
|
162
|
-
|
|
163
|
-
transactionData.gasData.budget = String(
|
|
164
|
-
gasBudget > baseComputationCostWithOverhead ? gasBudget : baseComputationCostWithOverhead,
|
|
169
|
+
transactionData.gasData.budget = computeGasBudget(
|
|
170
|
+
simulateResult.Transaction.effects!.gasUsed,
|
|
171
|
+
transactionData.gasData.price ? String(transactionData.gasData.price) : undefined,
|
|
165
172
|
);
|
|
166
173
|
}
|
|
167
174
|
|
package/src/jsonRpc/core.ts
CHANGED
|
@@ -20,7 +20,7 @@ import type {
|
|
|
20
20
|
TransactionEffects,
|
|
21
21
|
} from './types/index.js';
|
|
22
22
|
import { Transaction } from '../transactions/Transaction.js';
|
|
23
|
-
import { coreClientResolveTransactionPlugin } from '../client/core-resolver.js';
|
|
23
|
+
import { computeGasBudget, coreClientResolveTransactionPlugin } from '../client/core-resolver.js';
|
|
24
24
|
import { TransactionDataBuilder } from '../transactions/TransactionData.js';
|
|
25
25
|
import { chunk } from '@mysten/utils';
|
|
26
26
|
import { normalizeSuiAddress, normalizeStructTag } from '../utils/sui-types.js';
|
|
@@ -395,9 +395,19 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
395
395
|
|
|
396
396
|
const { effects, objectTypes } = parseTransactionEffectsJson({
|
|
397
397
|
effects: effectsSource.effects,
|
|
398
|
-
objectChanges: dryRunResult?.objectChanges ?? [],
|
|
398
|
+
objectChanges: (!dryRunFailed ? dryRunResult?.objectChanges : null) ?? [],
|
|
399
399
|
});
|
|
400
400
|
|
|
401
|
+
let parsedTransaction: SuiClientTypes.TransactionData | undefined;
|
|
402
|
+
if (options.include?.transaction) {
|
|
403
|
+
parsedTransaction = parseTransactionBcs(transactionBytes);
|
|
404
|
+
if (data && !dryRunFailed && effects.gasUsed) {
|
|
405
|
+
if (!data.gasData.budget) {
|
|
406
|
+
parsedTransaction.gasData.budget = computeGasBudget(effects.gasUsed);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
401
411
|
const transactionData: SuiClientTypes.Transaction<Include> = {
|
|
402
412
|
digest: TransactionDataBuilder.getDigestFromBytes(transactionBytes),
|
|
403
413
|
epoch: null,
|
|
@@ -409,21 +419,12 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
409
419
|
? objectTypes
|
|
410
420
|
: undefined) as SuiClientTypes.Transaction<Include>['objectTypes'],
|
|
411
421
|
signatures: [],
|
|
412
|
-
transaction: (
|
|
413
|
-
|
|
414
|
-
options.transaction instanceof Uint8Array
|
|
415
|
-
? options.transaction
|
|
416
|
-
: await options.transaction
|
|
417
|
-
.build({
|
|
418
|
-
client: this,
|
|
419
|
-
})
|
|
420
|
-
.catch(() => null as never),
|
|
421
|
-
)
|
|
422
|
-
: undefined) as SuiClientTypes.Transaction<Include>['transaction'],
|
|
422
|
+
transaction: (parsedTransaction ??
|
|
423
|
+
undefined) as SuiClientTypes.Transaction<Include>['transaction'],
|
|
423
424
|
bcs: (options.include?.bcs
|
|
424
425
|
? transactionBytes
|
|
425
426
|
: undefined) as SuiClientTypes.Transaction<Include>['bcs'],
|
|
426
|
-
balanceChanges: (options.include?.balanceChanges && dryRunResult
|
|
427
|
+
balanceChanges: (options.include?.balanceChanges && dryRunResult && !dryRunFailed
|
|
427
428
|
? dryRunResult.balanceChanges.map((change) => ({
|
|
428
429
|
coinType: normalizeStructTag(change.coinType),
|
|
429
430
|
address: parseOwnerAddress(change.owner)!,
|
|
@@ -606,7 +607,7 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
606
607
|
async defaultNameServiceName(
|
|
607
608
|
options: SuiClientTypes.DefaultNameServiceNameOptions,
|
|
608
609
|
): Promise<SuiClientTypes.DefaultNameServiceNameResponse> {
|
|
609
|
-
const name = (await this.#jsonRpcClient.resolveNameServiceNames(options)).data[0];
|
|
610
|
+
const name = (await this.#jsonRpcClient.resolveNameServiceNames(options)).data[0] ?? null;
|
|
610
611
|
return {
|
|
611
612
|
data: {
|
|
612
613
|
name,
|
package/src/utils/sui-types.ts
CHANGED
|
@@ -125,10 +125,20 @@ export function parseStructTag(type: string): StructTag {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
const [address, module] = parts;
|
|
128
|
+
|
|
129
|
+
if (!address || !module) {
|
|
130
|
+
throw new Error(`Invalid struct tag: ${type}`);
|
|
131
|
+
}
|
|
132
|
+
|
|
128
133
|
const isMvrPackage = isValidNamedPackage(address);
|
|
129
134
|
|
|
130
135
|
const rest = type.slice(address.length + module.length + 4);
|
|
131
136
|
const name = rest.includes('<') ? rest.slice(0, rest.indexOf('<')) : rest;
|
|
137
|
+
|
|
138
|
+
if (!name || (rest.includes('<') && !rest.endsWith('>'))) {
|
|
139
|
+
throw new Error(`Invalid struct tag: ${type}`);
|
|
140
|
+
}
|
|
141
|
+
|
|
132
142
|
const typeParams = rest.includes('<')
|
|
133
143
|
? splitGenericParameters(rest.slice(rest.indexOf('<') + 1, rest.lastIndexOf('>'))).map(
|
|
134
144
|
(typeParam) => parseTypeTag(typeParam.trim()),
|
package/src/version.ts
CHANGED