rebrand(lethean): update branding, ports, and config for Lethean blockchain
- Coin: Zano → Lethean, ticker: ZAN/ZANO → LTHN - Ports: 11211 → 36941 (mainnet RPC), 46941 (testnet RPC) - Wallet: 11212 → 36944/46944 - Address prefix: iTHN - URLs: zano.org → lethean.io - Explorer links: explorer.lthn.io Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
71194385e3
commit
5e38ba0bc8
37 changed files with 385 additions and 230 deletions
24
Dockerfile
Normal file
24
Dockerfile
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# Build-only: compiles web, server, and shared TypeScript bundles
|
||||
FROM node:22-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# Final image exposes the compiled output only
|
||||
FROM node:22-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/web/dist ./web/dist
|
||||
COPY --from=builder /app/server/dist ./server/dist
|
||||
COPY --from=builder /app/shared/dist ./shared/dist
|
||||
COPY --from=builder /app/package.json ./
|
||||
|
||||
# The server entrypoint
|
||||
EXPOSE 3000
|
||||
CMD ["node", "server/dist/index.js"]
|
||||
164
README.md
164
README.md
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
# ZanoWallet
|
||||
# LetheanWallet
|
||||
|
||||
`zano_web3` is a TypeScript library for interacting with the ZanoWallet extension in the browser. It allows you to connect to a user's ZanoWallet, handle authentication, and manage wallet credentials.
|
||||
`lethean_web3` is a TypeScript library for interacting with the LetheanWallet extension in the browser. It allows you to connect to a user's LetheanWallet, handle authentication, and manage wallet credentials.
|
||||
|
||||
## Features
|
||||
|
||||
- **Easy Integration**: Simplifies the process of connecting to the ZanoWallet extension.
|
||||
- **Easy Integration**: Simplifies the process of connecting to the LetheanWallet extension.
|
||||
- **Local Storage Support**: Optionally store wallet credentials in local storage.
|
||||
- **Customizable**: Offers hooks for various connection lifecycle events.
|
||||
- **Error Handling**: Provides a structured way to handle errors during the connection process.
|
||||
|
|
@ -13,16 +13,16 @@
|
|||
|
||||
## Installation
|
||||
|
||||
To install `zano_web3`, use npm or yarn:
|
||||
To install `lethean_web3`, use npm or yarn:
|
||||
|
||||
```bash
|
||||
npm install zano_web3
|
||||
npm install lethean_web3
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
yarn add zano_web3
|
||||
yarn add lethean_web3
|
||||
```
|
||||
|
||||
# WEB API (extension):
|
||||
|
|
@ -32,15 +32,15 @@ yarn add zano_web3
|
|||
### Importing the Library
|
||||
|
||||
```typescript
|
||||
import ZanoWallet from 'zano_web3/web';
|
||||
import LetheanWallet from 'lethean_web3/web';
|
||||
```
|
||||
|
||||
### Creating a ZanoWallet Instance
|
||||
### Creating a LetheanWallet Instance
|
||||
|
||||
To create a `ZanoWallet` instance, you need to provide configuration options via the `ZanoWalletParams` interface.
|
||||
To create a `LetheanWallet` instance, you need to provide configuration options via the `LetheanWalletParams` interface.
|
||||
|
||||
```typescript
|
||||
const zanoWallet = new ZanoWallet({
|
||||
const letheanWallet = new LetheanWallet({
|
||||
authPath: '/api/auth', // Custom server path for authentication
|
||||
useLocalStorage: true, // Store wallet credentials in local storage (default: true)
|
||||
aliasRequired: false, // Whether an alias is required (optional)
|
||||
|
|
@ -49,7 +49,7 @@ const zanoWallet = new ZanoWallet({
|
|||
disableServerRequest: false, // Disable server request after signing (optional)
|
||||
|
||||
onConnectStart: () => {
|
||||
console.log('Connecting to ZanoWallet...');
|
||||
console.log('Connecting to LetheanWallet...');
|
||||
},
|
||||
onConnectEnd: (data) => {
|
||||
console.log('Connected:', data);
|
||||
|
|
@ -68,31 +68,31 @@ const zanoWallet = new ZanoWallet({
|
|||
|
||||
### React / Next.js
|
||||
|
||||
For React or Next.js projects, you can use the `useZanoWallet` hook to create a `ZanoWallet` instance:
|
||||
For React or Next.js projects, you can use the `useLetheanWallet` hook to create a `LetheanWallet` instance:
|
||||
|
||||
```tsx
|
||||
|
||||
import { useZanoWallet } from 'zano_web3/web';
|
||||
import { useLetheanWallet } from 'lethean_web3/web';
|
||||
|
||||
const MyComponent = () => {
|
||||
const zanoWallet = useZanoWallet({
|
||||
// same options as for ZanoWallet constructor
|
||||
const letheanWallet = useLetheanWallet({
|
||||
// same options as for LetheanWallet constructor
|
||||
});
|
||||
|
||||
return (
|
||||
<div>
|
||||
<button onClick={() => zanoWallet.connect()}>Connect to ZanoWallet</button>
|
||||
<button onClick={() => letheanWallet.connect()}>Connect to LetheanWallet</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
### Connecting to ZanoWallet
|
||||
### Connecting to LetheanWallet
|
||||
|
||||
To initiate the connection process, call the `connect` method:
|
||||
|
||||
```typescript
|
||||
await zanoWallet.connect();
|
||||
await letheanWallet.connect();
|
||||
```
|
||||
|
||||
### Handling Wallet Credentials
|
||||
|
|
@ -100,12 +100,12 @@ await zanoWallet.connect();
|
|||
You can manually manage wallet credentials using `getSavedWalletCredentials` and `setWalletCredentials` methods:
|
||||
|
||||
```typescript
|
||||
const credentials = zanoWallet.getSavedWalletCredentials();
|
||||
const credentials = letheanWallet.getSavedWalletCredentials();
|
||||
if (credentials) {
|
||||
console.log('Stored credentials:', credentials);
|
||||
}
|
||||
|
||||
zanoWallet.setWalletCredentials({
|
||||
letheanWallet.setWalletCredentials({
|
||||
nonce: 'newNonce',
|
||||
signature: 'newSignature',
|
||||
publicKey: 'newPublicKey'
|
||||
|
|
@ -117,7 +117,7 @@ zanoWallet.setWalletCredentials({
|
|||
You can retrieve the wallet data using the `getWallet` method:
|
||||
|
||||
```typescript
|
||||
const wallet = await zanoWallet.getWallet();
|
||||
const wallet = await letheanWallet.getWallet();
|
||||
console.log('Wallet data:', wallet);
|
||||
```
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ console.log('Wallet data:', wallet);
|
|||
To get an address by alias, use the `getAddressByAlias` method:
|
||||
|
||||
```typescript
|
||||
const address = await zanoWallet.getAddressByAlias('exampleAlias');
|
||||
const address = await letheanWallet.getAddressByAlias('exampleAlias');
|
||||
console.log('Address:', address);
|
||||
```
|
||||
|
||||
|
|
@ -135,18 +135,18 @@ console.log('Address:', address);
|
|||
To create a new alias, use the `createAlias` method:
|
||||
|
||||
```typescript
|
||||
const newAliasData = await zanoWallet.createAlias('newAlias');
|
||||
const newAliasData = await letheanWallet.createAlias('newAlias');
|
||||
console.log('Alias created:', newAliasData);
|
||||
```
|
||||
|
||||
|
||||
## Exported Types
|
||||
|
||||
The following TypeScript interfaces are exported by the `zano_web3` library.
|
||||
The following TypeScript interfaces are exported by the `lethean_web3` library.
|
||||
You can import them directly from library:
|
||||
|
||||
```typescript
|
||||
import { Wallet, Asset, Transfer, Transaction } from 'zano_web3';
|
||||
import { Wallet, Asset, Transfer, Transaction } from 'lethean_web3';
|
||||
```
|
||||
|
||||
```typescript
|
||||
|
|
@ -189,7 +189,7 @@ export interface Wallet {
|
|||
|
||||
## Requirements
|
||||
|
||||
- ZanoWallet browser extension must be installed.
|
||||
- LetheanWallet browser extension must be installed.
|
||||
|
||||
|
||||
# Server api (Wallet RPC, Daemon):
|
||||
|
|
@ -212,16 +212,16 @@ export interface Wallet {
|
|||
#### 1. **Updating Wallet RPC URL**
|
||||
|
||||
```javascript
|
||||
import { ServerWallet } from "zano_web3/server";
|
||||
import { ServerWallet } from "lethean_web3/server";
|
||||
|
||||
(async () => {
|
||||
const zanoServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:11211/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:11211/json_rpc"
|
||||
const letheanServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:36941/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:36941/json_rpc"
|
||||
});
|
||||
|
||||
// Update the wallet RPC URL
|
||||
await zanoServerAPI.updateWalletRpcUrl("http://new_wallet_url:11211/json_rpc");
|
||||
await letheanServerAPI.updateWalletRpcUrl("http://new_wallet_url:36944/json_rpc");
|
||||
|
||||
console.log("Wallet RPC URL updated.");
|
||||
})();
|
||||
|
|
@ -230,16 +230,16 @@ import { ServerWallet } from "zano_web3/server";
|
|||
#### 2. **Updating Daemon RPC URL**
|
||||
|
||||
```javascript
|
||||
import { ServerWallet } from "zano_web3/server";
|
||||
import { ServerWallet } from "lethean_web3/server";
|
||||
|
||||
(async () => {
|
||||
const zanoServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:11211/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:11211/json_rpc"
|
||||
const letheanServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:36941/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:36941/json_rpc"
|
||||
});
|
||||
|
||||
// Update the daemon RPC URL
|
||||
await zanoServerAPI.updateDaemonRpcUrl("http://new_daemon_url:11211/json_rpc");
|
||||
await letheanServerAPI.updateDaemonRpcUrl("http://new_daemon_url:36941/json_rpc");
|
||||
|
||||
console.log("Daemon RPC URL updated.");
|
||||
})();
|
||||
|
|
@ -248,16 +248,16 @@ import { ServerWallet } from "zano_web3/server";
|
|||
#### 3. **Getting the List of Assets**
|
||||
|
||||
```javascript
|
||||
import { ServerWallet } from "zano_web3/server";
|
||||
import { ServerWallet } from "lethean_web3/server";
|
||||
|
||||
(async () => {
|
||||
const zanoServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:11211/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:11211/json_rpc"
|
||||
const letheanServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:36941/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:36941/json_rpc"
|
||||
});
|
||||
|
||||
// Get the list of assets
|
||||
const assets = await zanoServerAPI.getAssetsList();
|
||||
const assets = await letheanServerAPI.getAssetsList();
|
||||
|
||||
console.log("Assets List:", assets);
|
||||
})();
|
||||
|
|
@ -266,17 +266,17 @@ import { ServerWallet } from "zano_web3/server";
|
|||
#### 4. **Getting Asset Details**
|
||||
|
||||
```javascript
|
||||
import { ServerWallet } from "zano_web3/server";
|
||||
import { ServerWallet } from "lethean_web3/server";
|
||||
|
||||
(async () => {
|
||||
const zanoServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:11211/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:11211/json_rpc"
|
||||
const letheanServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:36941/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:36941/json_rpc"
|
||||
});
|
||||
|
||||
// Get details of a specific asset by ID
|
||||
const assetId = "example-asset-id";
|
||||
const assetDetails = await zanoServerAPI.getAssetDetails(assetId);
|
||||
const assetDetails = await letheanServerAPI.getAssetDetails(assetId);
|
||||
|
||||
console.log(`Details for Asset ID ${assetId}:`, assetDetails);
|
||||
})();
|
||||
|
|
@ -285,17 +285,17 @@ import { ServerWallet } from "zano_web3/server";
|
|||
#### 5. **Getting Asset Info**
|
||||
|
||||
```javascript
|
||||
import { ServerWallet } from "zano_web3/server";
|
||||
import { ServerWallet } from "lethean_web3/server";
|
||||
|
||||
(async () => {
|
||||
const zanoServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:11211/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:11211/json_rpc"
|
||||
const letheanServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:36941/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:36941/json_rpc"
|
||||
});
|
||||
|
||||
// Get info for a specific asset by ID
|
||||
const assetId = "example-asset-id";
|
||||
const assetInfo = await zanoServerAPI.getAssetInfo(assetId);
|
||||
const assetInfo = await letheanServerAPI.getAssetInfo(assetId);
|
||||
|
||||
console.log(`Info for Asset ID ${assetId}:`, assetInfo);
|
||||
})();
|
||||
|
|
@ -304,12 +304,12 @@ import { ServerWallet } from "zano_web3/server";
|
|||
#### 6. **Sending a Transfer**
|
||||
|
||||
```javascript
|
||||
import { ServerWallet } from "zano_web3/server";
|
||||
import { ServerWallet } from "lethean_web3/server";
|
||||
|
||||
(async () => {
|
||||
const zanoServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:11211/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:11211/json_rpc"
|
||||
const letheanServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:36941/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:36941/json_rpc"
|
||||
});
|
||||
|
||||
// Send a transfer
|
||||
|
|
@ -318,7 +318,7 @@ import { ServerWallet } from "zano_web3/server";
|
|||
const amount = "10.5"; // in asset units
|
||||
|
||||
try {
|
||||
const transferResult = await zanoServerAPI.sendTransfer(assetId, address, amount);
|
||||
const transferResult = await letheanServerAPI.sendTransfer(assetId, address, amount);
|
||||
console.log("Transfer successful:", transferResult);
|
||||
} catch (error) {
|
||||
console.error("Transfer failed:", error.message);
|
||||
|
|
@ -329,16 +329,16 @@ import { ServerWallet } from "zano_web3/server";
|
|||
#### 7. **Getting Balances**
|
||||
|
||||
```javascript
|
||||
import { ServerWallet } from "zano_web3/server";
|
||||
import { ServerWallet } from "lethean_web3/server";
|
||||
|
||||
(async () => {
|
||||
const zanoServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:11211/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:11211/json_rpc"
|
||||
const letheanServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:36941/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:36941/json_rpc"
|
||||
});
|
||||
|
||||
// Get the balances
|
||||
const balances = await zanoServerAPI.getBalances();
|
||||
const balances = await letheanServerAPI.getBalances();
|
||||
|
||||
console.log("Balances:", balances);
|
||||
})();
|
||||
|
|
@ -347,13 +347,13 @@ import { ServerWallet } from "zano_web3/server";
|
|||
#### 8. **Validating a Wallet**
|
||||
|
||||
```javascript
|
||||
import { ServerWallet } from "zano_web3/server";
|
||||
import { ServerWallet } from "lethean_web3/server";
|
||||
import { AuthData } from "./types";
|
||||
|
||||
(async () => {
|
||||
const zanoServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:11211/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:11211/json_rpc"
|
||||
const letheanServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:36941/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:36941/json_rpc"
|
||||
});
|
||||
|
||||
// Validate wallet using AuthData
|
||||
|
|
@ -365,7 +365,7 @@ import { AuthData } from "./types";
|
|||
};
|
||||
|
||||
try {
|
||||
const isValid = await zanoServerAPI.validateWallet(authData);
|
||||
const isValid = await letheanServerAPI.validateWallet(authData);
|
||||
console.log("Wallet validation:", isValid ? "Valid" : "Invalid");
|
||||
} catch (error) {
|
||||
console.error("Validation failed:", error.message);
|
||||
|
|
@ -376,18 +376,18 @@ import { AuthData } from "./types";
|
|||
#### 9. **Get Alias details**
|
||||
|
||||
```javascript
|
||||
import { ServerWallet } from "zano_web3/server";
|
||||
import { ServerWallet } from "lethean_web3/server";
|
||||
|
||||
const alias = "alias";
|
||||
|
||||
(async (alias) => {
|
||||
const zanoServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:11211/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:11211/json_rpc"
|
||||
const letheanServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:36941/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:36941/json_rpc"
|
||||
});
|
||||
|
||||
try {
|
||||
const aliasDetails = await zanoServerAPI.getAliasDetails(alias);
|
||||
const aliasDetails = await letheanServerAPI.getAliasDetails(alias);
|
||||
console.log(aliasDetails);
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
|
|
@ -398,17 +398,17 @@ const alias = "alias";
|
|||
#### 10. **Fetch Daemon**
|
||||
|
||||
```javascript
|
||||
import { ServerWallet } from "zano_web3/server";
|
||||
import { ServerWallet } from "lethean_web3/server";
|
||||
|
||||
(async () => {
|
||||
const zanoServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:11211/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:11211/json_rpc"
|
||||
const letheanServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:36941/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:36941/json_rpc"
|
||||
});
|
||||
|
||||
try {
|
||||
// Fetch daemon and retrieve a response (e.g., the getinfo method)
|
||||
const getInfoResponse = await zanoServerAPI.fetchDaemon("getinfo", {
|
||||
const getInfoResponse = await letheanServerAPI.fetchDaemon("getinfo", {
|
||||
"flags": 1048575
|
||||
});
|
||||
|
||||
|
|
@ -423,17 +423,17 @@ import { ServerWallet } from "zano_web3/server";
|
|||
#### 11. **Fetch Wallet**
|
||||
|
||||
```javascript
|
||||
import { ServerWallet } from "zano_web3/server";
|
||||
import { ServerWallet } from "lethean_web3/server";
|
||||
|
||||
(async () => {
|
||||
const zanoServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:11211/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:11211/json_rpc"
|
||||
const letheanServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:36941/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:36941/json_rpc"
|
||||
});
|
||||
|
||||
try {
|
||||
// Fetch wallet and retrieve a response (e.g., the getaddress method)
|
||||
const getAddressResponse = await zanoServerAPI.fetchWallet("getaddress", {});
|
||||
const getAddressResponse = await letheanServerAPI.fetchWallet("getaddress", {});
|
||||
|
||||
console.log("Address Info:", getAddressResponse.data.result);
|
||||
} catch (error) {
|
||||
|
|
@ -453,7 +453,7 @@ import { ServerWallet } from "zano_web3/server";
|
|||
validateTokensInput function checks whether a numeric or string value can be used as an amount for an asset with the specified DP.
|
||||
|
||||
```typescript
|
||||
import { validateTokensInput } from "zano_web3/shared";
|
||||
import { validateTokensInput } from "lethean_web3/shared";
|
||||
|
||||
let isValidAmount = validateTokensInput("18446744.073709551615", 12); // true
|
||||
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"name": "zano_web3",
|
||||
"name": "lethean_web3",
|
||||
"version": "9.2.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "zano_web3",
|
||||
"name": "lethean_web3",
|
||||
"version": "9.2.2",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
|
|
|
|||
10
package.json
10
package.json
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "zano_web3",
|
||||
"name": "lethean_web3",
|
||||
"version": "9.2.2",
|
||||
"description": "",
|
||||
"type": "module",
|
||||
|
|
@ -24,10 +24,10 @@
|
|||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/hyle-team/zano_web3.git"
|
||||
"url": "git+https://github.com/hyle-team/lethean_web3.git"
|
||||
},
|
||||
"keywords": [
|
||||
"zano",
|
||||
"lethean",
|
||||
"web3",
|
||||
"crypto",
|
||||
"blockchain",
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
"uuid": "^10.0.0"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/hyle-team/zano_web3/issues"
|
||||
"url": "https://github.com/hyle-team/lethean_web3/issues"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
|
|
@ -81,5 +81,5 @@
|
|||
"package.json",
|
||||
"README.md"
|
||||
],
|
||||
"homepage": "https://github.com/hyle-team/zano_web3#readme"
|
||||
"homepage": "https://github.com/hyle-team/lethean_web3#readme"
|
||||
}
|
||||
|
|
|
|||
4
server/dist/index.d.ts
vendored
4
server/dist/index.d.ts
vendored
|
|
@ -1,3 +1,3 @@
|
|||
import ServerWallet from "./server";
|
||||
import ServerWallet from "./server.js";
|
||||
export { ServerWallet };
|
||||
export * from "./types";
|
||||
export * from "./types.js";
|
||||
|
|
|
|||
4
server/dist/index.js
vendored
4
server/dist/index.js
vendored
|
|
@ -1,4 +1,4 @@
|
|||
import ServerWallet from "./server";
|
||||
import ServerWallet from "./server.js";
|
||||
export { ServerWallet };
|
||||
export * from "./types";
|
||||
export * from "./types.js";
|
||||
//# sourceMappingURL=index.js.map
|
||||
2
server/dist/index.js.map
vendored
2
server/dist/index.js.map
vendored
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,YAAY,EAAC,CAAC;AAEtB,cAAc,SAAS,CAAC"}
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,EAAC,YAAY,EAAC,CAAC;AAEtB,cAAc,YAAY,CAAC"}
|
||||
4
server/dist/server.d.ts
vendored
4
server/dist/server.d.ts
vendored
|
|
@ -1,5 +1,5 @@
|
|||
import { AuthData, BalanceInfo, TxInfo, AliasDetails } from "./types";
|
||||
import { APIAsset } from "./types";
|
||||
import { AuthData, BalanceInfo, TxInfo, AliasDetails } from "./types.js";
|
||||
import { APIAsset } from "./types.js";
|
||||
interface ConstructorParams {
|
||||
walletUrl: string;
|
||||
daemonUrl: string;
|
||||
|
|
|
|||
44
server/dist/server.js
vendored
44
server/dist/server.js
vendored
|
|
@ -1,6 +1,6 @@
|
|||
import axios from "axios";
|
||||
import Big from "big.js";
|
||||
import { ZANO_ASSET_ID, ZanoError } from "./utils";
|
||||
import { LTHN_ASSET_ID, LetheanError } from "./utils.js";
|
||||
import forge from "node-forge";
|
||||
class ServerWallet {
|
||||
walletUrl;
|
||||
|
|
@ -40,7 +40,7 @@ class ServerWallet {
|
|||
// Example payload
|
||||
const payload = {
|
||||
body_hash: bodyHash,
|
||||
user: "zano_extension",
|
||||
user: "lethean_extension",
|
||||
salt: this.generateRandomString(64),
|
||||
exp: Math.floor(Date.now() / 1000) + 60, // Expires in 1 minute
|
||||
};
|
||||
|
|
@ -55,7 +55,7 @@ class ServerWallet {
|
|||
};
|
||||
const headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Zano-Access-Token": this.generateAccessToken(JSON.stringify(data)),
|
||||
"Lethean-Access-Token": this.generateAccessToken(JSON.stringify(data)),
|
||||
};
|
||||
return axios.post(this.daemonUrl, data, { headers });
|
||||
}
|
||||
|
|
@ -68,7 +68,7 @@ class ServerWallet {
|
|||
};
|
||||
const headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Zano-Access-Token": this.generateAccessToken(JSON.stringify(data)),
|
||||
"Lethean-Access-Token": this.generateAccessToken(JSON.stringify(data)),
|
||||
};
|
||||
return axios.post(this.walletUrl, data, { headers });
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@ class ServerWallet {
|
|||
count,
|
||||
offset,
|
||||
});
|
||||
const assets = response.data.result.assets;
|
||||
const assets = response.data.result.assets ?? [];
|
||||
if (assets.length < count) {
|
||||
keepFetching = false;
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ class ServerWallet {
|
|||
offset += count;
|
||||
}
|
||||
catch (error) {
|
||||
throw new ZanoError("Failed to fetch assets list", "ASSETS_FETCH_ERROR");
|
||||
throw new LetheanError("Failed to fetch assets list", "ASSETS_FETCH_ERROR");
|
||||
}
|
||||
}
|
||||
return allAssets;
|
||||
|
|
@ -106,7 +106,7 @@ class ServerWallet {
|
|||
const assets = await this.getAssetsList();
|
||||
const asset = assets.find((a) => a.asset_id === assetId);
|
||||
if (!asset) {
|
||||
throw new ZanoError(`Asset with ID ${assetId} not found`, "ASSET_NOT_FOUND");
|
||||
throw new LetheanError(`Asset with ID ${assetId} not found`, "ASSET_NOT_FOUND");
|
||||
}
|
||||
return asset;
|
||||
}
|
||||
|
|
@ -119,18 +119,18 @@ class ServerWallet {
|
|||
return response.data.result;
|
||||
}
|
||||
else {
|
||||
throw new ZanoError(`Error fetching info for asset ID ${assetId}`, "ASSET_INFO_ERROR");
|
||||
throw new LetheanError(`Error fetching info for asset ID ${assetId}`, "ASSET_INFO_ERROR");
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
throw new ZanoError("Failed to fetch asset info", "ASSET_INFO_FETCH_ERROR");
|
||||
throw new LetheanError("Failed to fetch asset info", "ASSET_INFO_FETCH_ERROR");
|
||||
}
|
||||
}
|
||||
async sendTransfer(assetId, address, amount) {
|
||||
let decimalPoint;
|
||||
let auditable;
|
||||
if (assetId === ZANO_ASSET_ID) {
|
||||
if (assetId === LTHN_ASSET_ID) {
|
||||
decimalPoint = 12;
|
||||
}
|
||||
else {
|
||||
|
|
@ -142,7 +142,7 @@ class ServerWallet {
|
|||
auditable = response.data.result.address.startsWith("a");
|
||||
}
|
||||
catch (error) {
|
||||
throw new ZanoError("Failed to fetch address", "ADDRESS_FETCH_ERROR");
|
||||
throw new LetheanError("Failed to fetch address", "ADDRESS_FETCH_ERROR");
|
||||
}
|
||||
const bigAmount = new Big(amount)
|
||||
.times(new Big(10).pow(decimalPoint))
|
||||
|
|
@ -158,18 +158,18 @@ class ServerWallet {
|
|||
}
|
||||
else if (response.data.error &&
|
||||
response.data.error.message === "WALLET_RPC_ERROR_CODE_NOT_ENOUGH_MONEY") {
|
||||
throw new ZanoError("Not enough funds", "NOT_ENOUGH_FUNDS");
|
||||
throw new LetheanError("Not enough funds", "NOT_ENOUGH_FUNDS");
|
||||
}
|
||||
else {
|
||||
throw new ZanoError("Error sending transfer", "TRANSFER_ERROR");
|
||||
throw new LetheanError("Error sending transfer", "TRANSFER_ERROR");
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof ZanoError) {
|
||||
if (error instanceof LetheanError) {
|
||||
throw error;
|
||||
}
|
||||
else {
|
||||
throw new ZanoError("Failed to send transfer", "TRANSFER_SEND_ERROR");
|
||||
throw new LetheanError("Failed to send transfer", "TRANSFER_SEND_ERROR");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -180,11 +180,11 @@ class ServerWallet {
|
|||
return response.data.result;
|
||||
}
|
||||
else {
|
||||
throw new ZanoError(`Error fetching alias for address ${address}`, "ALIAS_FETCH_ERROR");
|
||||
throw new LetheanError(`Error fetching alias for address ${address}`, "ALIAS_FETCH_ERROR");
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
throw new ZanoError("Failed to fetch alias", "ALIAS_FETCH_ERROR");
|
||||
throw new LetheanError("Failed to fetch alias", "ALIAS_FETCH_ERROR");
|
||||
}
|
||||
}
|
||||
async getBalances() {
|
||||
|
|
@ -205,15 +205,15 @@ class ServerWallet {
|
|||
asset_info: asset.asset_info,
|
||||
}));
|
||||
return balances.sort((a, b) => {
|
||||
if (a.id === ZANO_ASSET_ID)
|
||||
if (a.id === LTHN_ASSET_ID)
|
||||
return -1;
|
||||
if (b.id === ZANO_ASSET_ID)
|
||||
if (b.id === LTHN_ASSET_ID)
|
||||
return 1;
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
throw new ZanoError("Failed to fetch balances", "BALANCES_FETCH_ERROR");
|
||||
throw new LetheanError("Failed to fetch balances", "BALANCES_FETCH_ERROR");
|
||||
}
|
||||
}
|
||||
async validateWallet(authData) {
|
||||
|
|
@ -271,11 +271,11 @@ class ServerWallet {
|
|||
return response.data.result;
|
||||
}
|
||||
else {
|
||||
throw new ZanoError(`Error fetching alias ${alias}`, "ALIAS_FETCH_ERROR");
|
||||
throw new LetheanError(`Error fetching alias ${alias}`, "ALIAS_FETCH_ERROR");
|
||||
}
|
||||
}
|
||||
catch {
|
||||
throw new ZanoError("Failed to fetch alias", "ALIAS_FETCH_ERROR");
|
||||
throw new LetheanError("Failed to fetch alias", "ALIAS_FETCH_ERROR");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
server/dist/server.js.map
vendored
2
server/dist/server.js.map
vendored
File diff suppressed because one or more lines are too long
4
server/dist/utils.d.ts
vendored
4
server/dist/utils.d.ts
vendored
|
|
@ -1,5 +1,5 @@
|
|||
export declare const ZANO_ASSET_ID = "d6329b5b1f7c0805b5c345f4957554002a2f557845f64d7645dae0e051a6498a";
|
||||
export declare class ZanoError extends Error {
|
||||
export declare const LTHN_ASSET_ID = "d6329b5b1f7c0805b5c345f4957554002a2f557845f64d7645dae0e051a6498a";
|
||||
export declare class LetheanError extends Error {
|
||||
code: string;
|
||||
name: string;
|
||||
constructor(message: string, code: string);
|
||||
|
|
|
|||
6
server/dist/utils.js
vendored
6
server/dist/utils.js
vendored
|
|
@ -1,10 +1,10 @@
|
|||
export const ZANO_ASSET_ID = "d6329b5b1f7c0805b5c345f4957554002a2f557845f64d7645dae0e051a6498a";
|
||||
export class ZanoError extends Error {
|
||||
export const LTHN_ASSET_ID = "d6329b5b1f7c0805b5c345f4957554002a2f557845f64d7645dae0e051a6498a";
|
||||
export class LetheanError extends Error {
|
||||
code;
|
||||
name;
|
||||
constructor(message, code) {
|
||||
super(message);
|
||||
this.name = "ZanoError";
|
||||
this.name = "LetheanError";
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
server/dist/utils.js.map
vendored
2
server/dist/utils.js.map
vendored
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,kEAAkE,CAAC;AAEhG,MAAM,OAAO,SAAU,SAAQ,KAAK;IAEzB,IAAI,CAAS;IACb,IAAI,CAAS;IAEpB,YAAY,OAAe,EAAE,IAAY;QACrC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;CACJ"}
|
||||
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,kEAAkE,CAAC;AAEhG,MAAM,OAAO,YAAa,SAAQ,KAAK;IAE5B,IAAI,CAAS;IACb,IAAI,CAAS;IAEpB,YAAY,OAAe,EAAE,IAAY;QACrC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;CACJ"}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import ServerWallet from "./server";
|
||||
import ServerWallet from "./server.js";
|
||||
export {ServerWallet};
|
||||
|
||||
export * from "./types";
|
||||
export * from "./types.js";
|
||||
|
|
@ -8,10 +8,10 @@ import {
|
|||
BalanceInfo,
|
||||
TxInfo,
|
||||
AliasDetails,
|
||||
} from "./types";
|
||||
} from "./types.js";
|
||||
|
||||
import { ZANO_ASSET_ID, ZanoError } from "./utils";
|
||||
import { APIAsset, APIBalance } from "./types";
|
||||
import { LTHN_ASSET_ID, LetheanError } from "./utils.js";
|
||||
import { APIAsset, APIBalance } from "./types.js";
|
||||
import forge from "node-forge";
|
||||
|
||||
interface ConstructorParams {
|
||||
|
|
@ -82,7 +82,7 @@ class ServerWallet {
|
|||
// Example payload
|
||||
const payload = {
|
||||
body_hash: bodyHash,
|
||||
user: "zano_extension",
|
||||
user: "lethean_extension",
|
||||
salt: this.generateRandomString(64),
|
||||
exp: Math.floor(Date.now() / 1000) + 60, // Expires in 1 minute
|
||||
};
|
||||
|
|
@ -103,7 +103,7 @@ class ServerWallet {
|
|||
|
||||
const headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Zano-Access-Token": this.generateAccessToken(JSON.stringify(data)),
|
||||
"Lethean-Access-Token": this.generateAccessToken(JSON.stringify(data)),
|
||||
};
|
||||
|
||||
return axios.post(this.daemonUrl, data, { headers });
|
||||
|
|
@ -120,7 +120,7 @@ class ServerWallet {
|
|||
|
||||
const headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Zano-Access-Token": this.generateAccessToken(JSON.stringify(data)),
|
||||
"Lethean-Access-Token": this.generateAccessToken(JSON.stringify(data)),
|
||||
};
|
||||
|
||||
return axios.post(this.walletUrl, data, { headers });
|
||||
|
|
@ -147,14 +147,14 @@ class ServerWallet {
|
|||
offset,
|
||||
});
|
||||
|
||||
const assets = response.data.result.assets;
|
||||
const assets: APIAsset[] = response.data.result.assets ?? [];
|
||||
if (assets.length < count) {
|
||||
keepFetching = false;
|
||||
}
|
||||
allAssets = allAssets.concat(assets);
|
||||
offset += count;
|
||||
} catch (error) {
|
||||
throw new ZanoError(
|
||||
throw new LetheanError(
|
||||
"Failed to fetch assets list",
|
||||
"ASSETS_FETCH_ERROR"
|
||||
);
|
||||
|
|
@ -169,7 +169,7 @@ class ServerWallet {
|
|||
const asset = assets.find((a) => a.asset_id === assetId);
|
||||
|
||||
if (!asset) {
|
||||
throw new ZanoError(
|
||||
throw new LetheanError(
|
||||
`Asset with ID ${assetId} not found`,
|
||||
"ASSET_NOT_FOUND"
|
||||
);
|
||||
|
|
@ -187,14 +187,14 @@ class ServerWallet {
|
|||
if (response.data.result) {
|
||||
return response.data.result;
|
||||
} else {
|
||||
throw new ZanoError(
|
||||
throw new LetheanError(
|
||||
`Error fetching info for asset ID ${assetId}`,
|
||||
"ASSET_INFO_ERROR"
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw new ZanoError(
|
||||
throw new LetheanError(
|
||||
"Failed to fetch asset info",
|
||||
"ASSET_INFO_FETCH_ERROR"
|
||||
);
|
||||
|
|
@ -205,7 +205,7 @@ class ServerWallet {
|
|||
let decimalPoint: number;
|
||||
let auditable: boolean;
|
||||
|
||||
if (assetId === ZANO_ASSET_ID) {
|
||||
if (assetId === LTHN_ASSET_ID) {
|
||||
decimalPoint = 12;
|
||||
} else {
|
||||
const asset = await this.getAssetDetails(assetId);
|
||||
|
|
@ -216,7 +216,7 @@ class ServerWallet {
|
|||
const response = await this.fetchWallet("getaddress", {});
|
||||
auditable = response.data.result.address.startsWith("a");
|
||||
} catch (error) {
|
||||
throw new ZanoError("Failed to fetch address", "ADDRESS_FETCH_ERROR");
|
||||
throw new LetheanError("Failed to fetch address", "ADDRESS_FETCH_ERROR");
|
||||
}
|
||||
|
||||
const bigAmount = new Big(amount)
|
||||
|
|
@ -236,15 +236,15 @@ class ServerWallet {
|
|||
response.data.error &&
|
||||
response.data.error.message === "WALLET_RPC_ERROR_CODE_NOT_ENOUGH_MONEY"
|
||||
) {
|
||||
throw new ZanoError("Not enough funds", "NOT_ENOUGH_FUNDS");
|
||||
throw new LetheanError("Not enough funds", "NOT_ENOUGH_FUNDS");
|
||||
} else {
|
||||
throw new ZanoError("Error sending transfer", "TRANSFER_ERROR");
|
||||
throw new LetheanError("Error sending transfer", "TRANSFER_ERROR");
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof ZanoError) {
|
||||
if (error instanceof LetheanError) {
|
||||
throw error;
|
||||
} else {
|
||||
throw new ZanoError("Failed to send transfer", "TRANSFER_SEND_ERROR");
|
||||
throw new LetheanError("Failed to send transfer", "TRANSFER_SEND_ERROR");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -256,13 +256,13 @@ class ServerWallet {
|
|||
if (response.data.result) {
|
||||
return response.data.result;
|
||||
} else {
|
||||
throw new ZanoError(
|
||||
throw new LetheanError(
|
||||
`Error fetching alias for address ${address}`,
|
||||
"ALIAS_FETCH_ERROR"
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
throw new ZanoError("Failed to fetch alias", "ALIAS_FETCH_ERROR");
|
||||
throw new LetheanError("Failed to fetch alias", "ALIAS_FETCH_ERROR");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -286,12 +286,12 @@ class ServerWallet {
|
|||
}));
|
||||
|
||||
return balances.sort((a, b) => {
|
||||
if (a.id === ZANO_ASSET_ID) return -1;
|
||||
if (b.id === ZANO_ASSET_ID) return 1;
|
||||
if (a.id === LTHN_ASSET_ID) return -1;
|
||||
if (b.id === LTHN_ASSET_ID) return 1;
|
||||
return 0;
|
||||
}) as BalanceInfo[];
|
||||
} catch (error) {
|
||||
throw new ZanoError("Failed to fetch balances", "BALANCES_FETCH_ERROR");
|
||||
throw new LetheanError("Failed to fetch balances", "BALANCES_FETCH_ERROR");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -365,13 +365,13 @@ class ServerWallet {
|
|||
if (response.data.result) {
|
||||
return response.data.result as AliasDetails;
|
||||
} else {
|
||||
throw new ZanoError(
|
||||
throw new LetheanError(
|
||||
`Error fetching alias ${alias}`,
|
||||
"ALIAS_FETCH_ERROR"
|
||||
);
|
||||
}
|
||||
} catch {
|
||||
throw new ZanoError("Failed to fetch alias", "ALIAS_FETCH_ERROR");
|
||||
throw new LetheanError("Failed to fetch alias", "ALIAS_FETCH_ERROR");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
export const ZANO_ASSET_ID = "d6329b5b1f7c0805b5c345f4957554002a2f557845f64d7645dae0e051a6498a";
|
||||
export const LTHN_ASSET_ID = "d6329b5b1f7c0805b5c345f4957554002a2f557845f64d7645dae0e051a6498a";
|
||||
|
||||
export class ZanoError extends Error {
|
||||
export class LetheanError extends Error {
|
||||
|
||||
public code: string;
|
||||
public name: string;
|
||||
|
||||
constructor(message: string, code: string) {
|
||||
super(message);
|
||||
this.name = "ZanoError";
|
||||
this.name = "LetheanError";
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
2
shared/dist/index.d.ts
vendored
2
shared/dist/index.d.ts
vendored
|
|
@ -1 +1 @@
|
|||
export * from "./utils";
|
||||
export * from "./utils.js";
|
||||
|
|
|
|||
2
shared/dist/index.js
vendored
2
shared/dist/index.js
vendored
|
|
@ -1,2 +1,2 @@
|
|||
export * from "./utils";
|
||||
export * from "./utils.js";
|
||||
//# sourceMappingURL=index.js.map
|
||||
2
shared/dist/index.js.map
vendored
2
shared/dist/index.js.map
vendored
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
||||
|
|
@ -1 +1 @@
|
|||
export * from "./utils";
|
||||
export * from "./utils.js";
|
||||
127
test-testnet.mjs
Normal file
127
test-testnet.mjs
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
/**
|
||||
* Live testnet connectivity test for lethean_web3
|
||||
* Daemon RPC: http://127.0.0.1:46941/json_rpc
|
||||
* Wallet RPC: http://127.0.0.1:46944/json_rpc
|
||||
*/
|
||||
import { ServerWallet } from './server/dist/index.js';
|
||||
import { validateTokensInput } from './shared/dist/index.js';
|
||||
// Node 22 ESM — imports now have .js extensions in built output
|
||||
|
||||
const DAEMON_URL = 'http://127.0.0.1:46941/json_rpc';
|
||||
const WALLET_URL = 'http://127.0.0.1:46944/json_rpc';
|
||||
|
||||
const api = new ServerWallet({
|
||||
walletUrl: WALLET_URL,
|
||||
daemonUrl: DAEMON_URL,
|
||||
});
|
||||
|
||||
let passed = 0;
|
||||
let failed = 0;
|
||||
|
||||
function ok(label, value) {
|
||||
console.log(` [PASS] ${label}:`, typeof value === 'object' ? JSON.stringify(value).slice(0, 120) : value);
|
||||
passed++;
|
||||
}
|
||||
|
||||
function fail(label, err) {
|
||||
console.error(` [FAIL] ${label}:`, err?.message || err);
|
||||
failed++;
|
||||
}
|
||||
|
||||
// ── Shared utils ─────────────────────────────────────────────────────────────
|
||||
console.log('\n=== shared: validateTokensInput ===');
|
||||
try {
|
||||
const r1 = validateTokensInput('100.5', 12);
|
||||
r1.valid ? ok('100.5 valid', r1) : fail('100.5 should be valid', r1.error);
|
||||
} catch (e) { fail('validateTokensInput 100.5', e); }
|
||||
|
||||
try {
|
||||
const r2 = validateTokensInput('18446744.073709551616', 12);
|
||||
!r2.valid ? ok('overflow rejected', r2) : fail('overflow should be rejected', r2);
|
||||
} catch (e) { fail('validateTokensInput overflow', e); }
|
||||
|
||||
try {
|
||||
const r3 = validateTokensInput('0.000000000001', 12);
|
||||
r3.valid ? ok('min unit valid', r3) : fail('min unit should be valid', r3.error);
|
||||
} catch (e) { fail('validateTokensInput min unit', e); }
|
||||
|
||||
// ── Daemon: fetchDaemon raw ───────────────────────────────────────────────────
|
||||
console.log('\n=== server: fetchDaemon("getinfo") ===');
|
||||
try {
|
||||
const resp = await api.fetchDaemon('getinfo', {});
|
||||
const result = resp.data.result;
|
||||
result && result.height > 0
|
||||
? ok('getinfo height', result.height)
|
||||
: fail('getinfo missing height', result);
|
||||
} catch (e) { fail('fetchDaemon getinfo', e); }
|
||||
|
||||
// ── Daemon: get_assets_list ───────────────────────────────────────────────────
|
||||
console.log('\n=== server: getAssetsList ===');
|
||||
let assetsList = [];
|
||||
try {
|
||||
assetsList = await api.getAssetsList();
|
||||
Array.isArray(assetsList)
|
||||
? ok(`got ${assetsList.length} assets`, assetsList.map(a => a.ticker))
|
||||
: fail('assets not an array', assetsList);
|
||||
} catch (e) { fail('getAssetsList', e); }
|
||||
|
||||
// ── Daemon: get_alias_details (no alias registered is fine) ──────────────────
|
||||
console.log('\n=== server: getAliasDetails("lthn") ===');
|
||||
try {
|
||||
const details = await api.getAliasDetails('lthn');
|
||||
ok('getAliasDetails returned', details);
|
||||
} catch (e) {
|
||||
// NOT_FOUND is acceptable on a fresh testnet
|
||||
e?.message?.includes('fetch alias') || e?.code === 'ALIAS_FETCH_ERROR'
|
||||
? ok('getAliasDetails NOT_FOUND (expected on empty testnet)', e.message)
|
||||
: fail('getAliasDetails unexpected error', e);
|
||||
}
|
||||
|
||||
// ── Wallet: fetchWallet("getaddress") ────────────────────────────────────────
|
||||
console.log('\n=== server: fetchWallet("getaddress") ===');
|
||||
let walletAddress = '';
|
||||
try {
|
||||
const resp = await api.fetchWallet('getaddress', {});
|
||||
walletAddress = resp.data?.result?.address;
|
||||
walletAddress && walletAddress.startsWith('iTHN')
|
||||
? ok('address starts with iTHN', walletAddress.slice(0, 24) + '…')
|
||||
: fail('address wrong prefix', walletAddress);
|
||||
} catch (e) { fail('fetchWallet getaddress', e); }
|
||||
|
||||
// ── Wallet: getBalances ───────────────────────────────────────────────────────
|
||||
console.log('\n=== server: getBalances ===');
|
||||
try {
|
||||
const balances = await api.getBalances();
|
||||
Array.isArray(balances)
|
||||
? ok(`balances (${balances.length})`, balances.map(b => `${b.ticker}=${b.amount}`))
|
||||
: fail('balances not array', balances);
|
||||
} catch (e) { fail('getBalances', e); }
|
||||
|
||||
// ── Wallet: getTxs ────────────────────────────────────────────────────────────
|
||||
console.log('\n=== server: getTxs(count=5, offset=0) ===');
|
||||
try {
|
||||
const txInfo = await api.getTxs({ count: 5, offset: 0 });
|
||||
typeof txInfo.total_transfers === 'number'
|
||||
? ok('total_transfers', txInfo.total_transfers)
|
||||
: fail('getTxs malformed result', txInfo);
|
||||
} catch (e) { fail('getTxs', e); }
|
||||
|
||||
// ── Wallet: validate_signature (dummy data — should return false) ─────────────
|
||||
console.log('\n=== server: validateWallet (dummy data, expect false) ===');
|
||||
try {
|
||||
const valid = await api.validateWallet({
|
||||
message: 'test nonce',
|
||||
address: 'iTHNdummy',
|
||||
signature: 'invalidsig',
|
||||
pkey: 'dummypkey',
|
||||
});
|
||||
valid === false
|
||||
? ok('bad sig correctly rejected', false)
|
||||
: fail('validateWallet should return false for bad sig', valid);
|
||||
} catch (e) { fail('validateWallet', e); }
|
||||
|
||||
// ── Summary ───────────────────────────────────────────────────────────────────
|
||||
console.log(`\n${'='.repeat(50)}`);
|
||||
console.log(`Results: ${passed} passed, ${failed} failed`);
|
||||
console.log('='.repeat(50));
|
||||
if (failed > 0) process.exit(1);
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
"module": "ESNext",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"moduleResolution": "node",
|
||||
"moduleResolution": "Bundler",
|
||||
"resolveJsonModule": true,
|
||||
"declaration": true,
|
||||
"lib": [
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
"outDir": "./server/dist",
|
||||
"declarationDir": "./server/dist",
|
||||
"rootDir": "./server/src",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler"
|
||||
},
|
||||
"include": ["server/src/**/*"],
|
||||
"exclude": ["node_modules"]
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
"outDir": "./shared/dist",
|
||||
"declarationDir": "./shared/dist",
|
||||
"rootDir": "./shared/src",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler"
|
||||
},
|
||||
"include": ["shared/src/**/*"],
|
||||
"exclude": ["node_modules"],
|
||||
|
|
|
|||
6
web/dist/hooks.d.ts
vendored
6
web/dist/hooks.d.ts
vendored
|
|
@ -1,3 +1,3 @@
|
|||
import ZanoWallet, { ZanoWalletParams } from './zanoWallet';
|
||||
declare function useZanoWallet(params: ZanoWalletParams): ZanoWallet | null;
|
||||
export { useZanoWallet };
|
||||
import LetheanWallet, { LetheanWalletParams } from './letheanWallet.js';
|
||||
declare function useLetheanWallet(params: LetheanWalletParams): LetheanWallet | null;
|
||||
export { useLetheanWallet };
|
||||
|
|
|
|||
12
web/dist/hooks.js
vendored
12
web/dist/hooks.js
vendored
|
|
@ -1,14 +1,14 @@
|
|||
import ZanoWallet from './zanoWallet';
|
||||
import LetheanWallet from './letheanWallet.js';
|
||||
import { useEffect, useState } from 'react';
|
||||
function useZanoWallet(params) {
|
||||
const [zanoWallet, setZanoWallet] = useState(null);
|
||||
function useLetheanWallet(params) {
|
||||
const [letheanWallet, setLetheanWallet] = useState(null);
|
||||
useEffect(() => {
|
||||
if (typeof window === 'undefined') {
|
||||
return;
|
||||
}
|
||||
setZanoWallet(new ZanoWallet(params));
|
||||
setLetheanWallet(new LetheanWallet(params));
|
||||
}, []);
|
||||
return zanoWallet;
|
||||
return letheanWallet;
|
||||
}
|
||||
export { useZanoWallet };
|
||||
export { useLetheanWallet };
|
||||
//# sourceMappingURL=hooks.js.map
|
||||
2
web/dist/hooks.js.map
vendored
2
web/dist/hooks.js.map
vendored
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,UAAgC,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,SAAS,aAAa,CAAC,MAAwB;IAC3C,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAoB,IAAI,CAAC,CAAC;IAEtE,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;YAChC,OAAO;QACX,CAAC;QAED,aAAa,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1C,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,UAAU,CAAC;AACtB,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
||||
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,aAAsC,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,SAAS,gBAAgB,CAAC,MAA2B;IACjD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAuB,IAAI,CAAC,CAAC;IAE/E,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;YAChC,OAAO;QACX,CAAC;QAED,gBAAgB,CAAC,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IAChD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,aAAa,CAAC;AACzB,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
||||
10
web/dist/index.d.ts
vendored
10
web/dist/index.d.ts
vendored
|
|
@ -1,5 +1,5 @@
|
|||
import zanoWallet from "./zanoWallet";
|
||||
import { useZanoWallet } from "./hooks";
|
||||
export { useZanoWallet };
|
||||
export * from "./types";
|
||||
export { zanoWallet };
|
||||
import letheanWallet from "./letheanWallet.js";
|
||||
import { useLetheanWallet } from "./hooks.js";
|
||||
export { useLetheanWallet };
|
||||
export * from "./types.js";
|
||||
export { letheanWallet };
|
||||
|
|
|
|||
10
web/dist/index.js
vendored
10
web/dist/index.js
vendored
|
|
@ -1,6 +1,6 @@
|
|||
import zanoWallet from "./zanoWallet";
|
||||
import { useZanoWallet } from "./hooks";
|
||||
export { useZanoWallet };
|
||||
export * from "./types";
|
||||
export { zanoWallet };
|
||||
import letheanWallet from "./letheanWallet.js";
|
||||
import { useLetheanWallet } from "./hooks.js";
|
||||
export { useLetheanWallet };
|
||||
export * from "./types.js";
|
||||
export { letheanWallet };
|
||||
//# sourceMappingURL=index.js.map
|
||||
2
web/dist/index.js.map
vendored
2
web/dist/index.js.map
vendored
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AACtC,OAAO,EAAC,aAAa,EAAC,CAAC;AAEvB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAC,UAAU,EAAC,CAAC"}
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAC,gBAAgB,EAAC,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAC,gBAAgB,EAAC,CAAC;AAE1B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAC,aAAa,EAAC,CAAC"}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import { Wallet } from './types';
|
||||
export interface ZanoWalletParams {
|
||||
import { Wallet } from './types.js';
|
||||
export interface LetheanWalletParams {
|
||||
authPath: string;
|
||||
useLocalStorage?: boolean;
|
||||
aliasRequired?: boolean;
|
||||
|
|
@ -19,12 +19,12 @@ interface WalletCredentials {
|
|||
publicKey: string;
|
||||
address: string;
|
||||
}
|
||||
declare class ZanoWallet {
|
||||
declare class LetheanWallet {
|
||||
private DEFAULT_LOCAL_STORAGE_KEY;
|
||||
private localStorageKey;
|
||||
private params;
|
||||
private zanoWallet;
|
||||
constructor(params: ZanoWalletParams);
|
||||
private letheanWallet;
|
||||
constructor(params: LetheanWalletParams);
|
||||
private handleError;
|
||||
getSavedWalletCredentials(): WalletCredentials | undefined;
|
||||
setWalletCredentials(credentials: WalletCredentials | undefined): void;
|
||||
|
|
@ -34,4 +34,4 @@ declare class ZanoWallet {
|
|||
getAddressByAlias(alias: string): Promise<string | undefined>;
|
||||
createAlias(alias: string): Promise<any>;
|
||||
}
|
||||
export default ZanoWallet;
|
||||
export default LetheanWallet;
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
import { v4 as uuidv4 } from 'uuid';
|
||||
class ZanoWallet {
|
||||
class LetheanWallet {
|
||||
DEFAULT_LOCAL_STORAGE_KEY = "wallet";
|
||||
localStorageKey;
|
||||
params;
|
||||
zanoWallet;
|
||||
letheanWallet;
|
||||
constructor(params) {
|
||||
if (typeof window === 'undefined') {
|
||||
throw new Error('ZanoWallet can only be used in the browser');
|
||||
throw new Error('LetheanWallet can only be used in the browser');
|
||||
}
|
||||
if (!window.zano) {
|
||||
console.error('ZanoWallet requires the ZanoWallet extension to be installed');
|
||||
if (!window.lethean) {
|
||||
console.error('LetheanWallet requires the LetheanWallet extension to be installed');
|
||||
}
|
||||
this.params = params;
|
||||
this.zanoWallet = window.zano;
|
||||
this.letheanWallet = window.lethean;
|
||||
this.localStorageKey = params.customLocalStorageKey || this.DEFAULT_LOCAL_STORAGE_KEY;
|
||||
}
|
||||
handleError({ message }) {
|
||||
|
|
@ -52,7 +52,7 @@ class ZanoWallet {
|
|||
if (this.params.onConnectStart) {
|
||||
this.params.onConnectStart();
|
||||
}
|
||||
const walletData = (await window.zano.request('GET_WALLET_DATA')).data;
|
||||
const walletData = (await window.lethean.request('GET_WALLET_DATA')).data;
|
||||
if (!walletData?.address) {
|
||||
return this.handleError({ message: 'Companion is offline' });
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ class ZanoWallet {
|
|||
}
|
||||
else {
|
||||
const generatedNonce = this.params.customNonce || uuidv4();
|
||||
const signResult = await this.zanoWallet.request('REQUEST_MESSAGE_SIGN', {
|
||||
const signResult = await this.letheanWallet.request('REQUEST_MESSAGE_SIGN', {
|
||||
message: generatedNonce
|
||||
}, null);
|
||||
if (!signResult?.data?.result) {
|
||||
|
|
@ -131,14 +131,14 @@ class ZanoWallet {
|
|||
return true;
|
||||
}
|
||||
async getWallet() {
|
||||
return (await this.zanoWallet.request('GET_WALLET_DATA'))?.data;
|
||||
return (await this.letheanWallet.request('GET_WALLET_DATA'))?.data;
|
||||
}
|
||||
async getAddressByAlias(alias) {
|
||||
return ((await this.zanoWallet.request('GET_ALIAS_DETAILS', { alias })) || undefined);
|
||||
return ((await this.letheanWallet.request('GET_ALIAS_DETAILS', { alias })) || undefined);
|
||||
}
|
||||
async createAlias(alias) {
|
||||
return ((await this.zanoWallet.request('CREATE_ALIAS', { alias })) || undefined).data;
|
||||
return ((await this.letheanWallet.request('CREATE_ALIAS', { alias })) || undefined).data;
|
||||
}
|
||||
}
|
||||
export default ZanoWallet;
|
||||
//# sourceMappingURL=zanoWallet.js.map
|
||||
export default LetheanWallet;
|
||||
//# sourceMappingURL=letheanWallet.js.map
|
||||
1
web/dist/letheanWallet.js.map
vendored
Normal file
1
web/dist/letheanWallet.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"letheanWallet.js","sourceRoot":"","sources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AAC;IAChB,CAAC;IAED,KAAK,CAAC,SAAS;QACX,OAAO,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,EAAE,IAAc,CAAC;IACjF,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,KAAa;QACjC,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,SAAS,CAAuB,CAAC;IACnH,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAAa;QAC3B,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,IAAI,CAAC;IAC7F,CAAC;CACJ;AAED,eAAe,aAAa,CAAC"}
|
||||
1
web/dist/zanoWallet.js.map
vendored
1
web/dist/zanoWallet.js.map
vendored
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"zanoWallet.js","sourceRoot":"","sources":["../src/zanoWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAqCpC,MAAM,UAAU;IAEJ,yBAAyB,GAAG,QAAQ,CAAC;IACrC,eAAe,CAAS;IAExB,MAAM,CAAmB;IACzB,UAAU,CAAmB;IAErC,YAAY,MAAwB;QAEhC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAClE,CAAC;QAED,IAAI,CAAG,MAAiC,CAAC,IAAI,EAAE,CAAC;YAC5C,OAAO,CAAC,KAAK,CAAC,8DAA8D,CAAC,CAAC;QAClF,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAK,MAAiC,CAAC,IAAI,CAAC;QAC3D,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U,CAAC"}
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
import ZanoWallet, { ZanoWalletParams } from './zanoWallet';
|
||||
import LetheanWallet, { LetheanWalletParams } from './letheanWallet.js';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
function useZanoWallet(params: ZanoWalletParams) {
|
||||
const [zanoWallet, setZanoWallet] = useState<ZanoWallet | null>(null);
|
||||
function useLetheanWallet(params: LetheanWalletParams) {
|
||||
const [letheanWallet, setLetheanWallet] = useState<LetheanWallet | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
setZanoWallet(new ZanoWallet(params));
|
||||
setLetheanWallet(new LetheanWallet(params));
|
||||
}, []);
|
||||
|
||||
return zanoWallet;
|
||||
return letheanWallet;
|
||||
}
|
||||
|
||||
export { useZanoWallet };
|
||||
export { useLetheanWallet };
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import zanoWallet from "./zanoWallet";
|
||||
import letheanWallet from "./letheanWallet.js";
|
||||
|
||||
import {useZanoWallet} from "./hooks";
|
||||
export {useZanoWallet};
|
||||
import {useLetheanWallet} from "./hooks.js";
|
||||
export {useLetheanWallet};
|
||||
|
||||
export * from "./types";
|
||||
export {zanoWallet};
|
||||
export * from "./types.js";
|
||||
export {letheanWallet};
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { Wallet } from './types';
|
||||
import { Wallet } from './types.js';
|
||||
|
||||
export interface ZanoWalletParams {
|
||||
export interface LetheanWalletParams {
|
||||
authPath: string;
|
||||
useLocalStorage?: boolean; // default: true
|
||||
aliasRequired?: boolean;
|
||||
|
|
@ -20,12 +20,12 @@ export interface ZanoWalletParams {
|
|||
|
||||
type GlobalWindow = Window & typeof globalThis;
|
||||
|
||||
interface ZanoWindowParams {
|
||||
interface LetheanWindowParams {
|
||||
request: (str: string, params?: any, timeoutMs?: number | null) => Promise<any>;
|
||||
}
|
||||
|
||||
type ZanoWindow = Omit<GlobalWindow, 'Infinity'> & {
|
||||
zano: ZanoWindowParams
|
||||
type LetheanWindow = Omit<GlobalWindow, 'Infinity'> & {
|
||||
lethean: LetheanWindowParams
|
||||
}
|
||||
|
||||
interface WalletCredentials {
|
||||
|
|
@ -35,26 +35,26 @@ interface WalletCredentials {
|
|||
address: string;
|
||||
}
|
||||
|
||||
class ZanoWallet {
|
||||
class LetheanWallet {
|
||||
|
||||
private DEFAULT_LOCAL_STORAGE_KEY = "wallet";
|
||||
private localStorageKey: string;
|
||||
|
||||
private params: ZanoWalletParams;
|
||||
private zanoWallet: ZanoWindowParams;
|
||||
private params: LetheanWalletParams;
|
||||
private letheanWallet: LetheanWindowParams;
|
||||
|
||||
constructor(params: ZanoWalletParams) {
|
||||
constructor(params: LetheanWalletParams) {
|
||||
|
||||
if (typeof window === 'undefined') {
|
||||
throw new Error('ZanoWallet can only be used in the browser');
|
||||
throw new Error('LetheanWallet can only be used in the browser');
|
||||
}
|
||||
|
||||
if (!((window as unknown) as ZanoWindow).zano) {
|
||||
console.error('ZanoWallet requires the ZanoWallet extension to be installed');
|
||||
if (!((window as unknown) as LetheanWindow).lethean) {
|
||||
console.error('LetheanWallet requires the LetheanWallet extension to be installed');
|
||||
}
|
||||
|
||||
this.params = params;
|
||||
this.zanoWallet = ((window as unknown) as ZanoWindow).zano;
|
||||
this.letheanWallet = ((window as unknown) as LetheanWindow).lethean;
|
||||
this.localStorageKey = params.customLocalStorageKey || this.DEFAULT_LOCAL_STORAGE_KEY;
|
||||
}
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ class ZanoWallet {
|
|||
this.params.onConnectStart();
|
||||
}
|
||||
|
||||
const walletData = (await ((window as unknown) as ZanoWindow).zano.request('GET_WALLET_DATA')).data;
|
||||
const walletData = (await ((window as unknown) as LetheanWindow).lethean.request('GET_WALLET_DATA')).data;
|
||||
|
||||
|
||||
if (!walletData?.address) {
|
||||
|
|
@ -130,7 +130,7 @@ class ZanoWallet {
|
|||
} else {
|
||||
const generatedNonce = this.params.customNonce || uuidv4();
|
||||
|
||||
const signResult = await this.zanoWallet.request(
|
||||
const signResult = await this.letheanWallet.request(
|
||||
'REQUEST_MESSAGE_SIGN',
|
||||
{
|
||||
message: generatedNonce
|
||||
|
|
@ -205,16 +205,16 @@ class ZanoWallet {
|
|||
}
|
||||
|
||||
async getWallet() {
|
||||
return (await this.zanoWallet.request('GET_WALLET_DATA'))?.data as Wallet;
|
||||
return (await this.letheanWallet.request('GET_WALLET_DATA'))?.data as Wallet;
|
||||
}
|
||||
|
||||
async getAddressByAlias(alias: string) {
|
||||
return ((await this.zanoWallet.request('GET_ALIAS_DETAILS', { alias })) || undefined) as string | undefined;
|
||||
return ((await this.letheanWallet.request('GET_ALIAS_DETAILS', { alias })) || undefined) as string | undefined;
|
||||
}
|
||||
|
||||
async createAlias(alias: string) {
|
||||
return ((await this.zanoWallet.request('CREATE_ALIAS', { alias })) || undefined).data;
|
||||
return ((await this.letheanWallet.request('CREATE_ALIAS', { alias })) || undefined).data;
|
||||
}
|
||||
}
|
||||
|
||||
export default ZanoWallet;
|
||||
export default LetheanWallet;
|
||||
Loading…
Add table
Reference in a new issue