Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default defineConfig({
},
{
name: 'parallel-e2e-tests',
testMatch: ['tests/e2e/queries/*.spec.js'],
testMatch: ['tests/e2e/queries/*.spec.js', 'tests/e2e/wallet/*.spec.js'],
fullyParallel: true,
// workers: process.env.CI ? 1 : undefined,
use: {
Expand Down
220 changes: 220 additions & 0 deletions public/AI_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3652,6 +3652,226 @@ identitySigner.addKey(identityPrivateKey);
await sdk.addresses.createIdentity({ identity, inputs, identitySigner, addressSigner });
```

## Wallet Helpers

### Pattern
The `wallet` namespace is a package-level export, called without an SDK instance or platform connection — it runs locally in the WebAssembly runtime:
```javascript
import { wallet } from '@dashevo/evo-sdk';
const result = await wallet.<method>(params);
```

### Available Wallet Helpers
#### Wallet Utilities

*Wallet helpers run locally in the WebAssembly runtime and never contact Dash Platform — no connection is created or required. Operations that take a network use the value selected in the site's network selector.*

**Generate Mnemonic** - `wallet.generateMnemonic`
*Generate a random BIP39 mnemonic seed phrase. Generated key material is for testing only — never use it to store real funds.*

Signature: `generateMnemonic(params?: wasm.GenerateMnemonicParams): Promise<string>`

Parameters:
- `params`: `wasm.GenerateMnemonicParams` (optional)
- Type declarations: [`wasm.GenerateMnemonicParams`](TYPE_REFERENCE.md#type-generatemnemonicparams)
- `wordCount`: `number` (optional)
- `languageCode`: `string` (optional)

Returns:

- `Promise<string>`

Example:
```javascript
import { wallet } from '@dashevo/evo-sdk';
const mnemonic = await wallet.generateMnemonic({ wordCount: 12 });
```

**Validate Mnemonic** - `wallet.validateMnemonic`
*Check whether a BIP39 mnemonic seed phrase is valid. Select the matching language for non-English wordlists; the default check does not detect every language.*

Signature: `validateMnemonic(mnemonic: string, languageCode?: string): Promise<boolean>`

Parameters:
- `mnemonic`: `string` (required)

- `languageCode`: `string` (optional)

Returns:

- `Promise<boolean>`

Example:
```javascript
import { wallet } from '@dashevo/evo-sdk';
const isValid = await wallet.validateMnemonic('your seed phrase here …');
```

**Mnemonic to Seed** - `wallet.mnemonicToSeed`
*Derive the 64-byte BIP39 seed (hex-encoded) from a mnemonic seed phrase and optional passphrase.*

Signature: `mnemonicToSeed(mnemonic: string, passphrase?: string): Promise<Uint8Array>`

Parameters:
- `mnemonic`: `string` (required)

- `passphrase`: `string` (optional)

Returns:

- `Promise<Uint8Array>`

Example:
```javascript
import { wallet } from '@dashevo/evo-sdk';
const seedBytes = await wallet.mnemonicToSeed('your seed phrase here …');
```

**Generate Key Pair** - `wallet.generateKeyPair`
*Generate a random private key with its public key and address. The network comes from the site's network selector. Generated key material is for testing only — never use it to store real funds.*

Signature: `generateKeyPair(network: NetworkLike): Promise<wasm.KeyPair>`

Parameters:
- `network`: `NetworkLike` (required)
- Type declarations: [`NetworkLike`](TYPE_REFERENCE.md#type-networklike)

Returns:

- `Promise<wasm.KeyPair>`
- Type declarations: [`wasm.KeyPair`](TYPE_REFERENCE.md#type-keypair)

Example:
```javascript
import { wallet } from '@dashevo/evo-sdk';
const keyPair = await wallet.generateKeyPair('testnet');
```

**Generate Key Pairs** - `wallet.generateKeyPairs`
*Generate multiple random key pairs at once. The network comes from the site's network selector. Generated key material is for testing only — never use it to store real funds.*

Signature: `generateKeyPairs(network: NetworkLike, count: number): Promise<wasm.KeyPair[]>`

Parameters:
- `network`: `NetworkLike` (required)
- Type declarations: [`NetworkLike`](TYPE_REFERENCE.md#type-networklike)

- `count`: `number` (required)

Returns:

- `Promise<wasm.KeyPair[]>`
- Type declarations: [`wasm.KeyPair`](TYPE_REFERENCE.md#type-keypair)

Example:
```javascript
import { wallet } from '@dashevo/evo-sdk';
const keyPairs = await wallet.generateKeyPairs('testnet', 3);
```

**Key Pair from WIF** - `wallet.keyPairFromWif`
*Import a private key from WIF and show its public key and address. The WIF version prefix determines the network, so the site's network selector does not affect this operation.*

Signature: `keyPairFromWif(privateKeyWif: string): Promise<wasm.KeyPair>`

Parameters:
- `privateKeyWif`: `string` (required)

Returns:

- `Promise<wasm.KeyPair>`
- Type declarations: [`wasm.KeyPair`](TYPE_REFERENCE.md#type-keypair)

Example:
```javascript
import { wallet } from '@dashevo/evo-sdk';
const keyPair = await wallet.keyPairFromWif('cYourTestnetPrivateKeyWif…');
```

**Key Pair from Hex** - `wallet.keyPairFromHex`
*Import a raw 32-byte private key (64 hex characters) and show its WIF, public key, and address. The network comes from the site's network selector.*

Signature: `keyPairFromHex(privateKeyHex: string, network: NetworkLike): Promise<wasm.KeyPair>`

Parameters:
- `privateKeyHex`: `string` (required)

- `network`: `NetworkLike` (required)
- Type declarations: [`NetworkLike`](TYPE_REFERENCE.md#type-networklike)

Returns:

- `Promise<wasm.KeyPair>`
- Type declarations: [`wasm.KeyPair`](TYPE_REFERENCE.md#type-keypair)

Example:
```javascript
import { wallet } from '@dashevo/evo-sdk';
const keyPair = await wallet.keyPairFromHex('c4bb… (64 hex chars)', 'testnet');
```

**Public Key to Address** - `wallet.pubkeyToAddress`
*Convert a compressed public key (hex) to a Dash address. The network comes from the site's network selector.*

Signature: `pubkeyToAddress(pubkeyHex: string, network: NetworkLike): Promise<string>`

Parameters:
- `pubkeyHex`: `string` (required)

- `network`: `NetworkLike` (required)
- Type declarations: [`NetworkLike`](TYPE_REFERENCE.md#type-networklike)

Returns:

- `Promise<string>`

Example:
```javascript
import { wallet } from '@dashevo/evo-sdk';
const address = await wallet.pubkeyToAddress('0378d4…', 'testnet');
```

**Validate Address** - `wallet.validateAddress`
*Check whether a Dash address is valid for a network. The network comes from the site's network selector.*

Signature: `validateAddress(address: string, network: NetworkLike): Promise<boolean>`

Parameters:
- `address`: `string` (required)

- `network`: `NetworkLike` (required)
- Type declarations: [`NetworkLike`](TYPE_REFERENCE.md#type-networklike)

Returns:

- `Promise<boolean>`

Example:
```javascript
import { wallet } from '@dashevo/evo-sdk';
const isValid = await wallet.validateAddress('yXSSUfQ8AFeWVionamYzedYSf3PANMazbw', 'testnet');
```

**Sign Message** - `wallet.signMessage`
*Sign an arbitrary message with a private key (WIF) using deterministic ECDSA. The message is signed exactly as entered.*

Signature: `signMessage(message: string, privateKeyWif: string): Promise<string>`

Parameters:
- `message`: `string` (required)

- `privateKeyWif`: `string` (required)

Returns:

- `Promise<string>`

Example:
```javascript
import { wallet } from '@dashevo/evo-sdk';
const signature = await wallet.signMessage('Hello Dash', 'cYourPrivateKeyWif…');
```

## Common Patterns

### Error Handling
Expand Down
80 changes: 57 additions & 23 deletions public/TYPE_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1299,6 +1299,18 @@ export interface FinalizedEpochsQuery {
}
```

<a id="type-generatemnemonicparams"></a>
## `GenerateMnemonicParams`

Source declaration: `wasm-sdk/dist/raw/wasm_sdk.d.ts`

```typescript
export interface GenerateMnemonicParams {
wordCount?: number;
languageCode?: string;
}
```

<a id="type-group"></a>
## `Group`

Expand Down Expand Up @@ -2410,6 +2422,28 @@ export interface IdentityUpdateOptions {
}
```

<a id="type-keypair"></a>
## `KeyPair`

Source declaration: `wasm-sdk/dist/raw/wasm_sdk.d.ts`

```typescript
export class KeyPair {
private constructor();
free(): void;
[Symbol.dispose](): void;
static fromJSON(js: object): KeyPair;
static fromObject(obj: object): KeyPair;
toJSON(): any;
toObject(): any;
address: string;
network: string;
privateKeyHex: string;
privateKeyWif: string;
publicKey: string;
}
```

<a id="type-masternodevoteoptions"></a>
## `MasternodeVoteOptions`

Expand Down Expand Up @@ -2454,6 +2488,15 @@ export interface MasternodeVoteOptions {
}
```

<a id="type-networklike"></a>
## `NetworkLike`

Source declaration: `wasm-sdk/dist/raw/wasm_sdk.d.ts`

```typescript
export type NetworkLike = Network | "mainnet" | "testnet" | "devnet" | "regtest" | 0 | 1 | 2 | 3;
```

<a id="type-pathelement"></a>
## `PathElement`

Expand Down Expand Up @@ -4352,15 +4395,6 @@ export class ContestedResourceVoteWinner {
}
```

<a id="type-networklike"></a>
## `NetworkLike`

Source declaration: `wasm-sdk/dist/raw/wasm_sdk.d.ts`

```typescript
export type NetworkLike = Network | "mainnet" | "testnet" | "devnet" | "regtest" | 0 | 1 | 2 | 3;
```

<a id="type-datacontractconfig"></a>
## `DataContractConfig`

Expand Down Expand Up @@ -5071,6 +5105,20 @@ export interface IdentityPublicKeyInCreationOptions {
}
```

<a id="type-network"></a>
## `Network`

Source declaration: `wasm-sdk/dist/raw/wasm_sdk.d.ts`

```typescript
export enum Network {
Mainnet = 0,
Testnet = 1,
Devnet = 2,
Regtest = 3,
}
```

<a id="type-groveelementtype"></a>
## `GroveElementType`

Expand Down Expand Up @@ -5614,20 +5662,6 @@ export class ContestedDocumentVotePollWinnerInfo {
}
```

<a id="type-network"></a>
## `Network`

Source declaration: `wasm-sdk/dist/raw/wasm_sdk.d.ts`

```typescript
export enum Network {
Mainnet = 0,
Testnet = 1,
Devnet = 2,
Regtest = 3,
}
```

<a id="type-platformversion"></a>
## `PlatformVersion`

Expand Down
Loading
Loading