@easysui/sdk 0.0.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/README.md +108 -0
- package/dist/index.d.mts +118 -0
- package/dist/index.d.ts +118 -0
- package/dist/index.js +598 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +556 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +66 -0
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# EasySui SDK
|
|
2
|
+
|
|
3
|
+
Easy-to-use TypeScript SDK for Sui blockchain development.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @easysui/sdk
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @easysui/sdk
|
|
11
|
+
# or
|
|
12
|
+
yarn add @easysui/sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { Config, getKeypair, deploySuiPackage } from '@easysui/sdk'
|
|
19
|
+
|
|
20
|
+
// Get configuration
|
|
21
|
+
const config = Config.vars
|
|
22
|
+
|
|
23
|
+
// Create keypair from private key
|
|
24
|
+
const keypair = getKeypair('your-private-key')
|
|
25
|
+
|
|
26
|
+
// Deploy a package
|
|
27
|
+
const result = await deploySuiPackage(config.PACKAGE_PATH)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
|
|
32
|
+
- **Configuration Management**: Easy configuration with environment-specific settings
|
|
33
|
+
- **Token Utilities**: Helpers for working with Sui tokens and USDC
|
|
34
|
+
- **Deployment Tools**: Simplified package deployment and upgrades
|
|
35
|
+
- **Cost Analysis**: Gas cost estimation and analysis
|
|
36
|
+
- **Test Utilities**: Testing helpers for Sui development
|
|
37
|
+
|
|
38
|
+
## API Reference
|
|
39
|
+
|
|
40
|
+
### Config
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { Config } from '@easysui/sdk'
|
|
44
|
+
|
|
45
|
+
// Access configuration variables
|
|
46
|
+
const vars = Config.vars
|
|
47
|
+
|
|
48
|
+
// Write configuration to .env file
|
|
49
|
+
Config.write(configVars)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Keypair Management
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { getKeypair } from '@easysui/sdk'
|
|
56
|
+
|
|
57
|
+
const keypair = getKeypair(privateKey)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Package Deployment
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { deploySuiPackage, upgradeSuiPackage } from '@easysui/sdk'
|
|
64
|
+
|
|
65
|
+
// Deploy new package
|
|
66
|
+
const deployResult = await deploySuiPackage(packagePath)
|
|
67
|
+
|
|
68
|
+
// Upgrade existing package
|
|
69
|
+
const upgradeResult = await upgradeSuiPackage(packagePath, upgradeCapId)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Development
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Install dependencies
|
|
76
|
+
pnpm install
|
|
77
|
+
|
|
78
|
+
# Build the package
|
|
79
|
+
pnpm build
|
|
80
|
+
|
|
81
|
+
# Run tests
|
|
82
|
+
pnpm test
|
|
83
|
+
|
|
84
|
+
# Lint code
|
|
85
|
+
pnpm lint
|
|
86
|
+
|
|
87
|
+
# Format code
|
|
88
|
+
pnpm fix
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Publishing
|
|
92
|
+
|
|
93
|
+
This package uses [Changesets](https://github.com/changesets/changesets) for version management and publishing.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Add a changeset
|
|
97
|
+
pnpm changeset
|
|
98
|
+
|
|
99
|
+
# Version packages
|
|
100
|
+
pnpm version
|
|
101
|
+
|
|
102
|
+
# Build and publish to npm
|
|
103
|
+
pnpm release
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Keypair } from '@mysten/sui/cryptography';
|
|
2
|
+
import { Transaction } from '@mysten/sui/transactions';
|
|
3
|
+
import * as _mysten_sui_client from '@mysten/sui/client';
|
|
4
|
+
import { SuiTransactionBlockResponse, SuiObjectChangePublished, SuiObjectChangeCreated, SuiClient as SuiClient$1 } from '@mysten/sui/client';
|
|
5
|
+
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
6
|
+
|
|
7
|
+
declare const DENY_LIST_ID = "0x403";
|
|
8
|
+
declare const CLOCK_ID = "0x6";
|
|
9
|
+
type Network = 'mainnet' | 'testnet' | 'devnet' | 'localnet';
|
|
10
|
+
interface ConfigVars {
|
|
11
|
+
NETWORK: Network;
|
|
12
|
+
RPC: string;
|
|
13
|
+
PACKAGE_PATH: string;
|
|
14
|
+
PACKAGE_ID: string;
|
|
15
|
+
UPGRADE_CAP_ID: string;
|
|
16
|
+
USDC_PACKAGE_ID?: string;
|
|
17
|
+
USDC_TREASURY_CAP?: string;
|
|
18
|
+
}
|
|
19
|
+
declare const ADMIN_KEYPAIR: Keypair;
|
|
20
|
+
declare class Config {
|
|
21
|
+
private static instance;
|
|
22
|
+
private static getInstance;
|
|
23
|
+
get env(): Network;
|
|
24
|
+
static get vars(): ConfigVars;
|
|
25
|
+
static write(config: ConfigVars): string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare const STATIC_CONFIGS: any;
|
|
29
|
+
|
|
30
|
+
declare class Coin {
|
|
31
|
+
static get coinType(): string;
|
|
32
|
+
static getBalance(owner: string): Promise<bigint>;
|
|
33
|
+
static getCoin(owner: Keypair, amount?: bigint): Promise<string>;
|
|
34
|
+
static _mint(treasuryId: string, amount: bigint, minter: Keypair): Promise<void>;
|
|
35
|
+
static send(amount: bigint, from: Keypair, to: string): Promise<void>;
|
|
36
|
+
static assertBalance(wallet: Keypair, amount: bigint | BigInt): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare class USDC extends Coin {
|
|
40
|
+
static get coinType(): string;
|
|
41
|
+
private static getMintCapId;
|
|
42
|
+
static faucet(amount: bigint, receiver: string, admin: Keypair): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare function analyze_cost(ptb: Transaction, resp: SuiTransactionBlockResponse): void;
|
|
46
|
+
|
|
47
|
+
declare function deploy(vars?: ConfigVars): Promise<string>;
|
|
48
|
+
declare function getDeployBytes(): Promise<string>;
|
|
49
|
+
|
|
50
|
+
declare function getKeypair(privkey: string): Keypair;
|
|
51
|
+
|
|
52
|
+
declare class PublishSingleton {
|
|
53
|
+
private readonly publishResp;
|
|
54
|
+
private static instance;
|
|
55
|
+
private constructor();
|
|
56
|
+
private static getDeployVars;
|
|
57
|
+
static publish(signer?: Keypair, packagePath?: string): Promise<void>;
|
|
58
|
+
private static getInstance;
|
|
59
|
+
static publishResponse(): SuiTransactionBlockResponse;
|
|
60
|
+
static get packageId(): string;
|
|
61
|
+
private static findObjectIdByType;
|
|
62
|
+
static get upgradeCapId(): string;
|
|
63
|
+
static get usdcTreasuryCap(): string;
|
|
64
|
+
static getPublishTx(packagePath: string, signer: Keypair): Transaction;
|
|
65
|
+
static getPublishBytes(signer?: Keypair, packagePath?: string): Promise<string>;
|
|
66
|
+
static publishPackage(signer: Keypair, packagePath: string): Promise<SuiTransactionBlockResponse>;
|
|
67
|
+
static findPublishedPackage(resp: SuiTransactionBlockResponse): SuiObjectChangePublished | undefined;
|
|
68
|
+
static findObjectChangeCreatedByType(resp: SuiTransactionBlockResponse, type: string): SuiObjectChangeCreated | undefined;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
declare enum MoveType {
|
|
72
|
+
u8 = 0,
|
|
73
|
+
u16 = 1,
|
|
74
|
+
u32 = 2,
|
|
75
|
+
u64 = 3,
|
|
76
|
+
u128 = 4,
|
|
77
|
+
u256 = 5,
|
|
78
|
+
bool = 6,
|
|
79
|
+
string = 7,
|
|
80
|
+
object = 8,
|
|
81
|
+
address = 9,
|
|
82
|
+
address_opt = 10,
|
|
83
|
+
vec_address = 11
|
|
84
|
+
}
|
|
85
|
+
declare class SuiClient {
|
|
86
|
+
private static instance;
|
|
87
|
+
private client;
|
|
88
|
+
private constructor();
|
|
89
|
+
private static getInstance;
|
|
90
|
+
static get client(): SuiClient$1;
|
|
91
|
+
static signAndExecute(ptb: Transaction, signer: Keypair, errorHandler?: (e: any) => string): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
92
|
+
static toMoveArg(ptb: Transaction, value: any, type?: MoveType): any;
|
|
93
|
+
static moveCall({ signer, target, typeArgs, args, argTypes, errorHandler, ptb, withTransfer, }: {
|
|
94
|
+
signer: Keypair;
|
|
95
|
+
target: string;
|
|
96
|
+
typeArgs?: string[];
|
|
97
|
+
args?: any[];
|
|
98
|
+
argTypes?: MoveType[];
|
|
99
|
+
errorHandler?: (e: any) => string;
|
|
100
|
+
ptb?: Transaction;
|
|
101
|
+
withTransfer?: boolean;
|
|
102
|
+
}): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
103
|
+
static public_transfer(objects: string[], from: Keypair, to: string): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
104
|
+
static devInspect(ptb: Transaction, sender: string): Promise<_mysten_sui_client.DevInspectResults>;
|
|
105
|
+
static devInspectRaw(ptb: Transaction, sender: string): Promise<number[] | undefined>;
|
|
106
|
+
static devInspectBool(ptb: Transaction, sender: string): Promise<boolean | undefined>;
|
|
107
|
+
static devInspectU64(ptb: Transaction, sender: string): Promise<bigint>;
|
|
108
|
+
static devInspectAddress(ptb: Transaction, sender: string): Promise<string | undefined>;
|
|
109
|
+
static getObject(id: string): Promise<_mysten_sui_client.SuiObjectResponse>;
|
|
110
|
+
static getObjectsByType(owner: string, type: string): Promise<(string | undefined)[]>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
declare function createWallet(): Ed25519Keypair;
|
|
114
|
+
declare function createFundedWallet(usdcAmount?: bigint): Promise<Ed25519Keypair>;
|
|
115
|
+
declare function sleep(ms: number): Promise<void>;
|
|
116
|
+
declare function waitForNextEpoch(timeoutMs?: number, pollIntervalMs?: number): Promise<string>;
|
|
117
|
+
|
|
118
|
+
export { ADMIN_KEYPAIR, CLOCK_ID, Coin, Config, type ConfigVars, DENY_LIST_ID, MoveType, PublishSingleton, STATIC_CONFIGS, SuiClient, USDC, analyze_cost, createFundedWallet, createWallet, deploy, getDeployBytes, getKeypair, sleep, waitForNextEpoch };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Keypair } from '@mysten/sui/cryptography';
|
|
2
|
+
import { Transaction } from '@mysten/sui/transactions';
|
|
3
|
+
import * as _mysten_sui_client from '@mysten/sui/client';
|
|
4
|
+
import { SuiTransactionBlockResponse, SuiObjectChangePublished, SuiObjectChangeCreated, SuiClient as SuiClient$1 } from '@mysten/sui/client';
|
|
5
|
+
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
6
|
+
|
|
7
|
+
declare const DENY_LIST_ID = "0x403";
|
|
8
|
+
declare const CLOCK_ID = "0x6";
|
|
9
|
+
type Network = 'mainnet' | 'testnet' | 'devnet' | 'localnet';
|
|
10
|
+
interface ConfigVars {
|
|
11
|
+
NETWORK: Network;
|
|
12
|
+
RPC: string;
|
|
13
|
+
PACKAGE_PATH: string;
|
|
14
|
+
PACKAGE_ID: string;
|
|
15
|
+
UPGRADE_CAP_ID: string;
|
|
16
|
+
USDC_PACKAGE_ID?: string;
|
|
17
|
+
USDC_TREASURY_CAP?: string;
|
|
18
|
+
}
|
|
19
|
+
declare const ADMIN_KEYPAIR: Keypair;
|
|
20
|
+
declare class Config {
|
|
21
|
+
private static instance;
|
|
22
|
+
private static getInstance;
|
|
23
|
+
get env(): Network;
|
|
24
|
+
static get vars(): ConfigVars;
|
|
25
|
+
static write(config: ConfigVars): string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare const STATIC_CONFIGS: any;
|
|
29
|
+
|
|
30
|
+
declare class Coin {
|
|
31
|
+
static get coinType(): string;
|
|
32
|
+
static getBalance(owner: string): Promise<bigint>;
|
|
33
|
+
static getCoin(owner: Keypair, amount?: bigint): Promise<string>;
|
|
34
|
+
static _mint(treasuryId: string, amount: bigint, minter: Keypair): Promise<void>;
|
|
35
|
+
static send(amount: bigint, from: Keypair, to: string): Promise<void>;
|
|
36
|
+
static assertBalance(wallet: Keypair, amount: bigint | BigInt): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare class USDC extends Coin {
|
|
40
|
+
static get coinType(): string;
|
|
41
|
+
private static getMintCapId;
|
|
42
|
+
static faucet(amount: bigint, receiver: string, admin: Keypair): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare function analyze_cost(ptb: Transaction, resp: SuiTransactionBlockResponse): void;
|
|
46
|
+
|
|
47
|
+
declare function deploy(vars?: ConfigVars): Promise<string>;
|
|
48
|
+
declare function getDeployBytes(): Promise<string>;
|
|
49
|
+
|
|
50
|
+
declare function getKeypair(privkey: string): Keypair;
|
|
51
|
+
|
|
52
|
+
declare class PublishSingleton {
|
|
53
|
+
private readonly publishResp;
|
|
54
|
+
private static instance;
|
|
55
|
+
private constructor();
|
|
56
|
+
private static getDeployVars;
|
|
57
|
+
static publish(signer?: Keypair, packagePath?: string): Promise<void>;
|
|
58
|
+
private static getInstance;
|
|
59
|
+
static publishResponse(): SuiTransactionBlockResponse;
|
|
60
|
+
static get packageId(): string;
|
|
61
|
+
private static findObjectIdByType;
|
|
62
|
+
static get upgradeCapId(): string;
|
|
63
|
+
static get usdcTreasuryCap(): string;
|
|
64
|
+
static getPublishTx(packagePath: string, signer: Keypair): Transaction;
|
|
65
|
+
static getPublishBytes(signer?: Keypair, packagePath?: string): Promise<string>;
|
|
66
|
+
static publishPackage(signer: Keypair, packagePath: string): Promise<SuiTransactionBlockResponse>;
|
|
67
|
+
static findPublishedPackage(resp: SuiTransactionBlockResponse): SuiObjectChangePublished | undefined;
|
|
68
|
+
static findObjectChangeCreatedByType(resp: SuiTransactionBlockResponse, type: string): SuiObjectChangeCreated | undefined;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
declare enum MoveType {
|
|
72
|
+
u8 = 0,
|
|
73
|
+
u16 = 1,
|
|
74
|
+
u32 = 2,
|
|
75
|
+
u64 = 3,
|
|
76
|
+
u128 = 4,
|
|
77
|
+
u256 = 5,
|
|
78
|
+
bool = 6,
|
|
79
|
+
string = 7,
|
|
80
|
+
object = 8,
|
|
81
|
+
address = 9,
|
|
82
|
+
address_opt = 10,
|
|
83
|
+
vec_address = 11
|
|
84
|
+
}
|
|
85
|
+
declare class SuiClient {
|
|
86
|
+
private static instance;
|
|
87
|
+
private client;
|
|
88
|
+
private constructor();
|
|
89
|
+
private static getInstance;
|
|
90
|
+
static get client(): SuiClient$1;
|
|
91
|
+
static signAndExecute(ptb: Transaction, signer: Keypair, errorHandler?: (e: any) => string): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
92
|
+
static toMoveArg(ptb: Transaction, value: any, type?: MoveType): any;
|
|
93
|
+
static moveCall({ signer, target, typeArgs, args, argTypes, errorHandler, ptb, withTransfer, }: {
|
|
94
|
+
signer: Keypair;
|
|
95
|
+
target: string;
|
|
96
|
+
typeArgs?: string[];
|
|
97
|
+
args?: any[];
|
|
98
|
+
argTypes?: MoveType[];
|
|
99
|
+
errorHandler?: (e: any) => string;
|
|
100
|
+
ptb?: Transaction;
|
|
101
|
+
withTransfer?: boolean;
|
|
102
|
+
}): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
103
|
+
static public_transfer(objects: string[], from: Keypair, to: string): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
104
|
+
static devInspect(ptb: Transaction, sender: string): Promise<_mysten_sui_client.DevInspectResults>;
|
|
105
|
+
static devInspectRaw(ptb: Transaction, sender: string): Promise<number[] | undefined>;
|
|
106
|
+
static devInspectBool(ptb: Transaction, sender: string): Promise<boolean | undefined>;
|
|
107
|
+
static devInspectU64(ptb: Transaction, sender: string): Promise<bigint>;
|
|
108
|
+
static devInspectAddress(ptb: Transaction, sender: string): Promise<string | undefined>;
|
|
109
|
+
static getObject(id: string): Promise<_mysten_sui_client.SuiObjectResponse>;
|
|
110
|
+
static getObjectsByType(owner: string, type: string): Promise<(string | undefined)[]>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
declare function createWallet(): Ed25519Keypair;
|
|
114
|
+
declare function createFundedWallet(usdcAmount?: bigint): Promise<Ed25519Keypair>;
|
|
115
|
+
declare function sleep(ms: number): Promise<void>;
|
|
116
|
+
declare function waitForNextEpoch(timeoutMs?: number, pollIntervalMs?: number): Promise<string>;
|
|
117
|
+
|
|
118
|
+
export { ADMIN_KEYPAIR, CLOCK_ID, Coin, Config, type ConfigVars, DENY_LIST_ID, MoveType, PublishSingleton, STATIC_CONFIGS, SuiClient, USDC, analyze_cost, createFundedWallet, createWallet, deploy, getDeployBytes, getKeypair, sleep, waitForNextEpoch };
|