@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.
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -1
- package/dist/index.mjs.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/dubhe.ts +6 -2
- package/src/utils/index.ts +7 -0
package/dist/utils/index.d.ts
CHANGED
|
@@ -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
package/src/dubhe.ts
CHANGED
|
@@ -40,7 +40,11 @@ import {
|
|
|
40
40
|
SuiObjectArg,
|
|
41
41
|
SuiVecTxArg,
|
|
42
42
|
} from './types';
|
|
43
|
-
import {
|
|
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
|
|
package/src/utils/index.ts
CHANGED
|
@@ -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
|
+
}
|