@0xobelisk/sui-client 1.0.4 → 1.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.
@@ -1,3 +1,4 @@
1
1
  export declare function capitalizeFirstLetter(input: string): string;
2
2
  export declare function normalizeHexAddress(input: string): string | null;
3
3
  export declare function numberToAddressHex(num: number): string;
4
+ export declare function normalizePackageId(input: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xobelisk/sui-client",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Tookit for interacting with move eps framework",
5
5
  "keywords": [
6
6
  "sui",
package/src/dubhe.ts CHANGED
@@ -40,7 +40,11 @@ import {
40
40
  SuiObjectArg,
41
41
  SuiVecTxArg,
42
42
  } from './types';
43
- import { normalizeHexAddress, numberToAddressHex } from './utils';
43
+ import {
44
+ normalizeHexAddress,
45
+ normalizePackageId,
46
+ numberToAddressHex,
47
+ } from './utils';
44
48
  import { bcs, fromHEX, toHEX } from '@mysten/bcs';
45
49
  import { ContractDataParsingError } from './errors';
46
50
 
@@ -240,7 +244,7 @@ export class Dubhe {
240
244
  fullnodeUrls = fullnodeUrls || [getFullnodeUrl(networkType ?? 'mainnet')];
241
245
  this.suiInteractor = new SuiInteractor(fullnodeUrls, networkType);
242
246
 
243
- this.packageId = packageId;
247
+ this.packageId = packageId ? normalizePackageId(packageId) : undefined;
244
248
  if (metadata !== undefined) {
245
249
  this.metadata = metadata as SuiMoveNormalizedModules;
246
250
 
@@ -21,3 +21,10 @@ export function numberToAddressHex(num: number): string {
21
21
  const paddedHex = '0x' + hex.padStart(64, '0');
22
22
  return paddedHex;
23
23
  }
24
+
25
+ export function normalizePackageId(input: string): string {
26
+ const withPrefix = input.startsWith('0x') ? input : '0x' + input;
27
+ const withoutPrefix = withPrefix.slice(2);
28
+ const normalized = withoutPrefix.replace(/^0+/, '');
29
+ return '0x' + normalized;
30
+ }