@cetusprotocol/xcetus-sdk 1.0.0

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/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@cetusprotocol/xcetus-sdk",
3
+ "version": "1.0.0",
4
+ "description": "SDK for cetus xcetus",
5
+ "typings": "dist/index.d.ts",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.mjs",
8
+ "scripts": {
9
+ "test": "jest",
10
+ "lint": "eslint src/*.ts src/**/*.ts",
11
+ "lint:fix": "eslint src/*.ts src/**/*.ts --fix",
12
+ "build": "pnpm run build:tsup",
13
+ "build:tsup": "npm run build:clean && npm run _build:node",
14
+ "build:clean": "rm -rf dist",
15
+ "_build:node": "tsup --format cjs,esm --dts",
16
+ "build:doc": "npx typedoc",
17
+ "publish_batch:test": "npm publish --tag experimental",
18
+ "publish:test": "node ../../scripts/version.js xcetus && npm publish --tag experimental"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": ""
23
+ },
24
+ "keywords": [],
25
+ "author": "test",
26
+ "license": "Apache-2.0",
27
+ "devDependencies": {
28
+ "@cetusprotocol/common-sdk": "workspace:*",
29
+ "@cetusprotocol/test-utils": "workspace:*"
30
+ },
31
+ "peerDependencies": {
32
+ "@cetusprotocol/common-sdk": ">=1.0.0",
33
+ "@mysten/bcs": "^1.5.0",
34
+ "@mysten/sui": "^1.24.0"
35
+ }
36
+ }
@@ -0,0 +1,2 @@
1
+ export * from './mainnet'
2
+ export * from './testnet'
@@ -0,0 +1,37 @@
1
+ import { FullRpcUrlMainnet } from '@cetusprotocol/common-sdk'
2
+ import type { SdkOptions } from '../../src'
3
+
4
+ const SDKConfig = {
5
+ xcetusConfig: {
6
+ xcetus_manager_id: '0x838b3dbade12b1e602efcaf8c8b818fae643e43176462bf14fd196afa59d1d9d',
7
+ lock_manager_id: '0x288b59d9dedb51d0bb6cb5e13bfb30885ecf44f8c9076b6f5221c5ef6644fd28',
8
+ lock_handle_id: '0x7c534bb7b8a2cc21538d0dbedd2437cc64f47106cb4c259b9ff921b5c3cb1a49',
9
+ },
10
+ xcetusDividendsConfig: {
11
+ dividend_manager_id: '0x721c990bfc031d074341c6059a113a59c1febfbd2faeb62d49dcead8408fa6b5',
12
+ dividend_admin_id: '0x682ba823134f156eac2bcfb27d85a284954a0e61998dc628c40b9bcb4a46ff30',
13
+ dividend_settle_id: '0xade40abe9f6dd10b83b11085be18f07b63b681cf1c169b041fa16854403388c5',
14
+ venft_dividends_id: '0x9dcdb97b4307684bedaeaf803d381b12321a31ecbb9dad7df2cd5f64384f9456',
15
+ venft_dividends_id_v2: '0xaa21fbc1707786d56302952f8327362f4eb9a431a5bc574834e6d46125390de3',
16
+ },
17
+ }
18
+
19
+ export const xcetus_mainnet: SdkOptions = {
20
+ full_rpc_url: FullRpcUrlMainnet,
21
+ xcetus: {
22
+ package_id: '0x9e69acc50ca03bc943c4f7c5304c2a6002d507b51c11913b247159c60422c606',
23
+ published_at: '0x9e69acc50ca03bc943c4f7c5304c2a6002d507b51c11913b247159c60422c606',
24
+ config: SDKConfig.xcetusConfig,
25
+ },
26
+ xcetus_dividends: {
27
+ package_id: '0x785248249ac457dfd378bdc6d2fbbfec9d1daf65e9d728b820eb4888c8da2c10',
28
+ published_at: '0x5aa58e1623885bd93de2331d05c29bf4930e54e56beeabcab8fe5385de2d31dc',
29
+ version: 4,
30
+ config: SDKConfig.xcetusDividendsConfig,
31
+ },
32
+ cetus_faucet: {
33
+ package_id: '0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b',
34
+ published_at: '0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b',
35
+ },
36
+ env: 'mainnet',
37
+ }
@@ -0,0 +1,37 @@
1
+ import { FullRpcUrlTestnet } from '@cetusprotocol/common-sdk'
2
+ import type { SdkOptions } from '../../src'
3
+ const SDKConfig = {
4
+ xcetusConfig: {
5
+ xcetus_manager_id: '0x3be34cbad122c8b100ed7157d762b9610e68b3c65734e08bc3c3baf857da807d',
6
+ lock_manager_id: '0x7c67e805182e3fecd098bd68a6b06c317f28f8c6249bd771e07904a10b424e60',
7
+ lock_handle_id: '0xc5f3bbfefe9a45c13da7a34bc72cac122ee45d633690476a8ac56bd2c4e78c86',
8
+ },
9
+ xcetusDividendsConfig: {
10
+ dividend_manager_id: '0x9d1be1a6b1146b30448a266bc87127466c0bae1585750c42adffce3e25e1ab6d',
11
+ dividend_admin_id: '0x36d63c1a588bd93775aff8f47538a0063960564f0a171d100a9f49526a872b92',
12
+ dividend_settle_id: '0x9eb78595419560b1dcaa9fb0ca307921ab1664a5f63c877c6887ab696344b400',
13
+ venft_dividends_id: '0xc31a85fa5a77fc1def0dc5b2aadc5317a9d744ffda24b472e56a646711770676',
14
+ venft_dividends_id_v2: '0x53b24031120730f6e4a733526147917650b1ecd3c56b43164b69eaa74f9b9ff7',
15
+ },
16
+ }
17
+
18
+ export const xcetus_testnet: SdkOptions = {
19
+ full_rpc_url: FullRpcUrlTestnet,
20
+ xcetus: {
21
+ package_id: '0xdebaab6b851fd3414c0a62dbdf8eb752d6b0d31f5cfce5e38541bc6c6daa8966',
22
+ published_at: '0xdebaab6b851fd3414c0a62dbdf8eb752d6b0d31f5cfce5e38541bc6c6daa8966',
23
+ version: 1,
24
+ config: SDKConfig.xcetusConfig,
25
+ },
26
+ xcetus_dividends: {
27
+ package_id: '0x4061e279415a3c45cfd31554d38c5b3bb0e06c65833811a98a66f469e04c69c3',
28
+ published_at: '0xfeda040996e722ba532ab2203d13333484024456ca38bf4adeb526ce1457332d',
29
+ version: 1,
30
+ config: SDKConfig.xcetusDividendsConfig,
31
+ },
32
+ cetus_faucet: {
33
+ package_id: '0x1a69aee6be709054750949959a67aedbb4200583b39586d5e3eabe57f40012c7',
34
+ published_at: '0x1a69aee6be709054750949959a67aedbb4200583b39586d5e3eabe57f40012c7',
35
+ },
36
+ env: 'testnet',
37
+ }
@@ -0,0 +1,29 @@
1
+ import { BaseError } from '@cetusprotocol/common-sdk'
2
+
3
+ export enum XCetusErrorCode {
4
+ InvalidVeNftId = `InvalidVeNftId`,
5
+ InvalidLockId = `InvalidLockId`,
6
+ InvalidPhase = `InvalidPhase`,
7
+ InvalidAccountAddress = `InvalidAccountAddress`,
8
+ InvalidLockManagerId = `InvalidLockManagerId`,
9
+ BuildError = 'BuildError',
10
+ FetchError = 'FetchError',
11
+ }
12
+
13
+ export class XCetusError extends BaseError {
14
+ constructor(message: string, error_code?: XCetusErrorCode, details?: Record<string, any>) {
15
+ super(message, error_code || 'UnknownError', details)
16
+ }
17
+
18
+ static isXCetusErrorCode(e: any, code: XCetusErrorCode): boolean {
19
+ return this.isErrorCode<XCetusError>(e, code)
20
+ }
21
+ }
22
+
23
+ export const handleError = (code: XCetusErrorCode, error: Error | string, details?: Record<string, any>) => {
24
+ if (error instanceof Error) {
25
+ throw new XCetusError(error.message, code, details)
26
+ } else {
27
+ throw new XCetusError(error, code, details)
28
+ }
29
+ }
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { CetusXcetusSDK, SdkOptions } from "./sdk";
2
+
3
+ export * from "./utils";
4
+ export * from "./types";
5
+ export * from "./modules";
6
+ export { CetusXcetusSDK, SdkOptions };
7
+ export default CetusXcetusSDK;
@@ -0,0 +1 @@
1
+ export * from "./xcetusModule";