@n1xyz/nord-ts 0.0.1 → 0.0.4
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/.eslintrc.js +11 -0
- package/README.md +148 -65
- package/dist/bridge/NordUser.d.ts +78 -0
- package/dist/bridge/NordUser.js +196 -0
- package/dist/bridge/client.d.ts +150 -0
- package/dist/bridge/client.js +394 -0
- package/dist/bridge/const.d.ts +23 -0
- package/dist/bridge/const.js +47 -0
- package/dist/bridge/index.d.ts +5 -0
- package/dist/bridge/index.js +23 -0
- package/dist/bridge/types.d.ts +118 -0
- package/dist/bridge/types.js +16 -0
- package/dist/bridge/utils.d.ts +64 -0
- package/dist/bridge/utils.js +131 -0
- package/dist/client.d.ts +70 -0
- package/dist/client.js +129 -0
- package/dist/const.d.ts +2 -5
- package/dist/const.js +18 -22
- package/dist/constants/endpoints.d.ts +65 -0
- package/dist/constants/endpoints.js +68 -0
- package/dist/gen/common.d.ts +6 -1
- package/dist/gen/common.js +19 -9
- package/dist/gen/nord.d.ts +75 -17
- package/dist/gen/nord.js +987 -423
- package/dist/idl/bridge.d.ts +2 -0
- package/dist/idl/bridge.js +703 -0
- package/dist/index.d.ts +8 -5
- package/dist/index.js +18 -2
- package/dist/models/account.d.ts +58 -0
- package/dist/models/account.js +6 -0
- package/dist/models/index.d.ts +8 -0
- package/dist/models/index.js +28 -0
- package/dist/models/market.d.ts +137 -0
- package/dist/models/market.js +6 -0
- package/dist/models/order.d.ts +211 -0
- package/dist/models/order.js +6 -0
- package/dist/models/token.d.ts +50 -0
- package/dist/models/token.js +6 -0
- package/dist/nord/Nord.d.ts +222 -49
- package/dist/nord/Nord.js +290 -278
- package/dist/nord/NordError.d.ts +23 -0
- package/dist/nord/NordError.js +48 -0
- package/dist/nord/NordImpl.d.ts +6 -2
- package/dist/nord/NordImpl.js +21 -1
- package/dist/nord/NordUser.d.ts +208 -42
- package/dist/nord/NordUser.js +389 -157
- package/dist/nord/Subscriber.d.ts +37 -0
- package/dist/nord/Subscriber.js +29 -0
- package/dist/nord/api/actions.d.ts +101 -0
- package/dist/nord/api/actions.js +250 -0
- package/dist/nord/api/core.d.ts +49 -0
- package/dist/nord/api/core.js +121 -0
- package/dist/nord/api/index.d.ts +1 -0
- package/dist/nord/api/index.js +17 -0
- package/dist/nord/api/market.d.ts +36 -0
- package/dist/nord/api/market.js +98 -0
- package/dist/nord/api/metrics.d.ts +67 -0
- package/dist/nord/api/metrics.js +132 -0
- package/dist/nord/api/orderFunctions.d.ts +168 -0
- package/dist/nord/api/orderFunctions.js +133 -0
- package/dist/nord/api/queries.d.ts +81 -0
- package/dist/nord/api/queries.js +187 -0
- package/dist/nord/client/Nord.d.ts +335 -0
- package/dist/nord/client/Nord.js +532 -0
- package/dist/nord/client/NordUser.d.ts +320 -0
- package/dist/nord/client/NordUser.js +701 -0
- package/dist/nord/core.d.ts +48 -0
- package/dist/nord/core.js +97 -0
- package/dist/nord/index.d.ts +9 -2
- package/dist/nord/index.js +30 -6
- package/dist/nord/market.d.ts +36 -0
- package/dist/nord/market.js +90 -0
- package/dist/nord/metrics.d.ts +67 -0
- package/dist/nord/metrics.js +124 -0
- package/dist/nord/models/Subscriber.d.ts +37 -0
- package/dist/nord/models/Subscriber.js +29 -0
- package/dist/nord/queries.d.ts +81 -0
- package/dist/nord/queries.js +181 -0
- package/dist/nord/types.d.ts +88 -0
- package/dist/nord/types.js +2 -0
- package/dist/nord/utils/NordError.d.ts +35 -0
- package/dist/nord/utils/NordError.js +46 -0
- package/dist/nord/websocket.d.ts +49 -0
- package/dist/nord/websocket.js +107 -0
- package/dist/operations/account.d.ts +58 -0
- package/dist/operations/account.js +112 -0
- package/dist/operations/market.d.ts +65 -0
- package/dist/operations/market.js +131 -0
- package/dist/operations/orders.d.ts +57 -0
- package/dist/operations/orders.js +129 -0
- package/dist/solana/NordUser.d.ts +78 -0
- package/dist/solana/NordUser.js +196 -0
- package/dist/solana/client.d.ts +139 -0
- package/dist/solana/client.js +360 -0
- package/dist/solana/const.d.ts +23 -0
- package/dist/solana/const.js +47 -0
- package/dist/solana/index.d.ts +5 -0
- package/dist/solana/index.js +23 -0
- package/dist/solana/types.d.ts +118 -0
- package/dist/solana/types.js +16 -0
- package/dist/solana/utils.d.ts +64 -0
- package/dist/solana/utils.js +131 -0
- package/dist/types/api.d.ts +152 -0
- package/dist/types/api.js +6 -0
- package/dist/types/config.d.ts +34 -0
- package/dist/types/config.js +6 -0
- package/dist/types.d.ts +144 -87
- package/dist/types.js +13 -2
- package/dist/utils/errors.d.ts +96 -0
- package/dist/utils/errors.js +132 -0
- package/dist/utils/http.d.ts +35 -0
- package/dist/utils/http.js +105 -0
- package/dist/utils.d.ts +14 -5
- package/dist/utils.js +26 -7
- package/dist/websocket/NordWebSocketClient.d.ts +71 -0
- package/dist/websocket/NordWebSocketClient.js +343 -0
- package/dist/websocket/client.d.ts +93 -0
- package/dist/websocket/client.js +222 -0
- package/dist/websocket/events.d.ts +19 -0
- package/dist/websocket/events.js +2 -0
- package/dist/websocket/index.d.ts +2 -0
- package/dist/websocket/index.js +5 -0
- package/dist/websocket.d.ts +55 -0
- package/dist/websocket.js +211 -0
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Nord.html +2 -15
- package/docs/classes/NordUser.html +4 -4
- package/docs/enums/FillMode.html +2 -2
- package/docs/enums/KeyType.html +2 -2
- package/docs/enums/PeakTpsPeriodUnit.html +2 -2
- package/docs/enums/Side.html +2 -2
- package/docs/functions/assert.html +1 -1
- package/docs/functions/bigIntToProtoU128.html +1 -1
- package/docs/functions/checkPubKeyLength.html +1 -1
- package/docs/functions/checkedFetch.html +1 -1
- package/docs/functions/decodeLengthDelimited.html +1 -1
- package/docs/functions/encodeLengthDelimited.html +1 -1
- package/docs/functions/fillModeToProtoFillMode.html +1 -1
- package/docs/functions/findMarket.html +1 -1
- package/docs/functions/findToken.html +1 -1
- package/docs/functions/makeWalletSignFn.html +1 -1
- package/docs/functions/optExpect.html +1 -1
- package/docs/functions/optMap.html +1 -1
- package/docs/functions/optUnwrap.html +1 -1
- package/docs/functions/panic.html +1 -1
- package/docs/functions/signAction.html +1 -1
- package/docs/functions/toScaledU128.html +1 -1
- package/docs/functions/toScaledU64.html +1 -1
- package/docs/interfaces/Account.html +2 -2
- package/docs/interfaces/ActionInfo.html +2 -2
- package/docs/interfaces/ActionQuery.html +2 -2
- package/docs/interfaces/ActionResponse.html +2 -2
- package/docs/interfaces/ActionsExtendedInfo.html +2 -2
- package/docs/interfaces/ActionsQuery.html +2 -2
- package/docs/interfaces/ActionsResponse.html +2 -2
- package/docs/interfaces/AggregateMetrics.html +2 -2
- package/docs/interfaces/BlockQuery.html +2 -2
- package/docs/interfaces/BlockResponse.html +2 -2
- package/docs/interfaces/BlockSummary.html +2 -2
- package/docs/interfaces/BlockSummaryResponse.html +2 -2
- package/docs/interfaces/DeltaEvent.html +2 -2
- package/docs/interfaces/ERC20TokenInfo.html +2 -2
- package/docs/interfaces/Info.html +2 -2
- package/docs/interfaces/Market.html +2 -2
- package/docs/interfaces/MarketStats.html +2 -2
- package/docs/interfaces/MarketsStatsResponse.html +2 -2
- package/docs/interfaces/NordConfig.html +2 -2
- package/docs/interfaces/Order.html +2 -2
- package/docs/interfaces/OrderInfo.html +2 -2
- package/docs/interfaces/PerpMarketStats.html +2 -2
- package/docs/interfaces/RollmanActionExtendedInfo.html +2 -2
- package/docs/interfaces/RollmanActionInfo.html +2 -2
- package/docs/interfaces/RollmanActionResponse.html +2 -2
- package/docs/interfaces/RollmanActionsResponse.html +2 -2
- package/docs/interfaces/RollmanBlockResponse.html +2 -2
- package/docs/interfaces/SubscriberConfig.html +2 -2
- package/docs/interfaces/Token.html +2 -2
- package/docs/interfaces/Trade.html +2 -2
- package/docs/interfaces/Trades.html +2 -2
- package/docs/modules.html +0 -7
- package/docs/types/BigIntValue.html +1 -1
- package/docs/variables/DEBUG_KEYS.html +1 -1
- package/docs/variables/DEFAULT_FUNDING_AMOUNTS.html +1 -1
- package/docs/variables/DEV_CONTRACT_ADDRESS.html +1 -1
- package/docs/variables/DEV_TOKEN_INFOS.html +1 -1
- package/docs/variables/DEV_URL.html +1 -1
- package/docs/variables/ERC20_ABI.html +1 -1
- package/docs/variables/EVM_DEV_URL.html +1 -1
- package/docs/variables/FAUCET_PRIVATE_ADDRESS.html +1 -1
- package/docs/variables/MAX_BUFFER_LEN.html +1 -1
- package/docs/variables/NORD_GETTERS_FACET_ABI.html +1 -1
- package/docs/variables/NORD_RAMP_FACET_ABI.html +1 -1
- package/docs/variables/SESSION_TTL.html +1 -1
- package/docs/variables/WEBSERVER_DEV_URL.html +1 -1
- package/docs/variables/ZERO_DECIMAL.html +1 -1
- package/package.json +10 -12
- package/src/bridge/client.ts +487 -0
- package/src/bridge/const.ts +53 -0
- package/src/bridge/index.ts +7 -0
- package/src/bridge/types.ts +127 -0
- package/src/bridge/utils.ts +140 -0
- package/src/const.ts +20 -25
- package/src/gen/common.ts +27 -10
- package/src/gen/nord.ts +1044 -483
- package/src/idl/bridge.ts +702 -0
- package/src/index.ts +24 -5
- package/src/nord/{actions.ts → api/actions.ts} +33 -37
- package/src/nord/api/core.ts +130 -0
- package/src/nord/api/market.ts +125 -0
- package/src/nord/api/metrics.ts +154 -0
- package/src/nord/api/queries.ts +236 -0
- package/src/nord/client/Nord.ts +652 -0
- package/src/nord/client/NordUser.ts +1105 -0
- package/src/nord/index.ts +16 -2
- package/src/nord/models/Subscriber.ts +57 -0
- package/src/nord/utils/NordError.ts +72 -0
- package/src/types.ts +170 -99
- package/src/utils.ts +40 -19
- package/src/websocket/NordWebSocketClient.ts +432 -0
- package/src/websocket/events.ts +31 -0
- package/src/websocket/index.ts +2 -0
- package/tests/utils.spec.ts +24 -24
- package/docs/classes/Subscriber.html +0 -6
- package/docs/functions/createWebSocketSubscription.html +0 -12
- package/docs/interfaces/OrderbookOrder.html +0 -6
- package/docs/interfaces/OrderbookResponse.html +0 -10
- package/docs/interfaces/TradeInfo.html +0 -20
- package/docs/interfaces/TradesQueryParams.html +0 -10
- package/docs/interfaces/TradesResponse.html +0 -12
- package/src/abis/ERC20_ABI.ts +0 -310
- package/src/abis/NORD_GETTERS_FACET_ABI.ts +0 -192
- package/src/abis/NORD_RAMP_FACET_ABI.ts +0 -141
- package/src/abis/index.ts +0 -3
- package/src/nord/Nord.ts +0 -504
- package/src/nord/NordImpl.ts +0 -8
- package/src/nord/NordUser.ts +0 -469
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NordError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Custom error class for Nord-related errors
|
|
6
|
+
* Extends the standard Error class with additional context
|
|
7
|
+
*/
|
|
8
|
+
class NordError extends Error {
|
|
9
|
+
/**
|
|
10
|
+
* Create a new NordError
|
|
11
|
+
*
|
|
12
|
+
* @param message - Error message
|
|
13
|
+
* @param options - Additional error options
|
|
14
|
+
*/
|
|
15
|
+
constructor(message, options) {
|
|
16
|
+
super(message);
|
|
17
|
+
// Set the prototype explicitly to ensure instanceof works correctly
|
|
18
|
+
Object.setPrototypeOf(this, NordError.prototype);
|
|
19
|
+
// Set the name to the class name for better error messages
|
|
20
|
+
this.name = 'NordError';
|
|
21
|
+
// Store the cause if provided
|
|
22
|
+
if (options?.cause) {
|
|
23
|
+
this.cause = options.cause;
|
|
24
|
+
}
|
|
25
|
+
// Capture stack trace
|
|
26
|
+
if (Error.captureStackTrace) {
|
|
27
|
+
Error.captureStackTrace(this, NordError);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get a string representation of the error including the cause if available
|
|
32
|
+
*
|
|
33
|
+
* @returns String representation of the error
|
|
34
|
+
*/
|
|
35
|
+
toString() {
|
|
36
|
+
let result = `${this.name}: ${this.message}`;
|
|
37
|
+
if (this.cause) {
|
|
38
|
+
if (this.cause instanceof Error) {
|
|
39
|
+
result += `\nCaused by: ${this.cause.toString()}`;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
result += `\nCaused by: ${String(this.cause)}`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.NordError = NordError;
|
package/dist/nord/NordImpl.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { Nord } from "./Nord";
|
|
1
2
|
/**
|
|
2
3
|
* Implementation of some functions backing Nord and NordUser as interface,
|
|
3
4
|
* for mocking reasons
|
|
4
5
|
*/
|
|
5
|
-
export
|
|
6
|
-
|
|
6
|
+
export declare class NordImpl {
|
|
7
|
+
private nord;
|
|
8
|
+
constructor(nord: Nord);
|
|
9
|
+
getTimestamp(): Promise<bigint>;
|
|
10
|
+
getActionNonce(): Promise<number>;
|
|
7
11
|
}
|
package/dist/nord/NordImpl.js
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NordImpl = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
2
5
|
/**
|
|
3
6
|
* Implementation of some functions backing Nord and NordUser as interface,
|
|
4
7
|
* for mocking reasons
|
|
5
8
|
*/
|
|
6
|
-
|
|
9
|
+
class NordImpl {
|
|
10
|
+
constructor(nord) {
|
|
11
|
+
this.nord = nord;
|
|
12
|
+
}
|
|
13
|
+
async getTimestamp() {
|
|
14
|
+
const url = new URL(`${this.nord.webServerUrl}/api/v1/timestamp`);
|
|
15
|
+
const response = await (0, utils_1.checkedFetch)(url.toString());
|
|
16
|
+
const json = await response.json();
|
|
17
|
+
return BigInt(json.timestamp);
|
|
18
|
+
}
|
|
19
|
+
async getActionNonce() {
|
|
20
|
+
const url = new URL(`${this.nord.webServerUrl}/api/v1/action_nonce`);
|
|
21
|
+
const response = await (0, utils_1.checkedFetch)(url.toString());
|
|
22
|
+
const json = await response.json();
|
|
23
|
+
return json.nonce;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.NordImpl = NordImpl;
|
package/dist/nord/NordUser.d.ts
CHANGED
|
@@ -1,13 +1,87 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import Decimal from "decimal.js";
|
|
2
|
+
import { Connection, Keypair, PublicKey } from '@solana/web3.js';
|
|
3
3
|
import { FillMode, Order, Side } from "../types";
|
|
4
|
+
import { BigIntValue } from "../utils";
|
|
4
5
|
import { Nord } from "./Nord";
|
|
5
|
-
import
|
|
6
|
-
|
|
6
|
+
import { SolanaBridgeClient } from '../bridge/client';
|
|
7
|
+
import { SPLTokenInfo } from '../bridge/types';
|
|
8
|
+
/**
|
|
9
|
+
* Parameters for creating a NordUser instance
|
|
10
|
+
*/
|
|
11
|
+
export interface NordUserParams {
|
|
12
|
+
/** Nord client instance */
|
|
7
13
|
nord: Nord;
|
|
14
|
+
/** User's blockchain address */
|
|
8
15
|
address: string;
|
|
16
|
+
/** Function to sign messages with the user's wallet */
|
|
9
17
|
walletSignFn: (message: Uint8Array | string) => Promise<string>;
|
|
18
|
+
/** Function to sign messages with the user's session key */
|
|
10
19
|
sessionSignFn: (message: Uint8Array) => Promise<Uint8Array>;
|
|
20
|
+
/** Solana public key (optional) */
|
|
21
|
+
solanaPublicKey?: PublicKey | string;
|
|
22
|
+
/** Solana keypair (optional) */
|
|
23
|
+
keypair?: Keypair;
|
|
24
|
+
/** Solana connection (optional) */
|
|
25
|
+
connection?: Connection;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Parameters for placing an order
|
|
29
|
+
*/
|
|
30
|
+
export interface PlaceOrderParams {
|
|
31
|
+
/** Market ID */
|
|
32
|
+
marketId: number;
|
|
33
|
+
/** Order side (bid or ask) */
|
|
34
|
+
side: Side;
|
|
35
|
+
/** Fill mode (limit, market, etc.) */
|
|
36
|
+
fillMode: FillMode;
|
|
37
|
+
/** Whether the order is reduce-only */
|
|
38
|
+
isReduceOnly: boolean;
|
|
39
|
+
/** Order size */
|
|
40
|
+
size?: Decimal.Value;
|
|
41
|
+
/** Order price */
|
|
42
|
+
price?: Decimal.Value;
|
|
43
|
+
/** Quote size (for market orders) */
|
|
44
|
+
quoteSize?: Decimal.Value;
|
|
45
|
+
/** Account ID to place the order from */
|
|
46
|
+
accountId?: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Parameters for transferring tokens between accounts
|
|
50
|
+
*/
|
|
51
|
+
export interface TransferParams {
|
|
52
|
+
/** Recipient user */
|
|
53
|
+
to: NordUser;
|
|
54
|
+
/** Token ID to transfer */
|
|
55
|
+
tokenId: number;
|
|
56
|
+
/** Amount to transfer */
|
|
57
|
+
amount: Decimal.Value;
|
|
58
|
+
/** Source account ID */
|
|
59
|
+
fromAccountId: number;
|
|
60
|
+
/** Destination account ID */
|
|
61
|
+
toAccountId: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Parameters for creating a new account
|
|
65
|
+
*/
|
|
66
|
+
export interface CreateAccountParams {
|
|
67
|
+
/** Token ID for initial funding */
|
|
68
|
+
tokenId: number;
|
|
69
|
+
/** Initial funding amount */
|
|
70
|
+
amount: Decimal.Value;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* User class for interacting with the Nord protocol
|
|
74
|
+
*/
|
|
75
|
+
export declare class NordUser {
|
|
76
|
+
/** Nord client instance */
|
|
77
|
+
readonly nord: Nord;
|
|
78
|
+
/** User's blockchain address */
|
|
79
|
+
readonly address: string;
|
|
80
|
+
/** Function to sign messages with the user's wallet */
|
|
81
|
+
readonly walletSignFn: (message: Uint8Array | string) => Promise<string>;
|
|
82
|
+
/** Function to sign messages with the user's session key */
|
|
83
|
+
readonly sessionSignFn: (message: Uint8Array) => Promise<Uint8Array>;
|
|
84
|
+
/** User balances by token symbol */
|
|
11
85
|
balances: {
|
|
12
86
|
[key: string]: {
|
|
13
87
|
accountId: number;
|
|
@@ -15,63 +89,155 @@ export declare class NordUser {
|
|
|
15
89
|
symbol: string;
|
|
16
90
|
}[];
|
|
17
91
|
};
|
|
92
|
+
/** User orders by market symbol */
|
|
18
93
|
orders: {
|
|
19
94
|
[key: string]: Order[];
|
|
20
95
|
};
|
|
96
|
+
/** User's account IDs */
|
|
21
97
|
accountIds?: number[];
|
|
98
|
+
/** Current session ID */
|
|
22
99
|
sessionId?: bigint;
|
|
100
|
+
/** User's public key */
|
|
23
101
|
publicKey: Uint8Array | undefined;
|
|
102
|
+
/** Last timestamp used */
|
|
24
103
|
lastTs: number;
|
|
104
|
+
/** Last nonce used */
|
|
25
105
|
lastNonce: number;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
106
|
+
/** Solana public key */
|
|
107
|
+
solanaPublicKey?: PublicKey;
|
|
108
|
+
/** Solana keypair */
|
|
109
|
+
keypair?: Keypair;
|
|
110
|
+
/** Solana bridge client */
|
|
111
|
+
bridgeClient?: SolanaBridgeClient;
|
|
112
|
+
/** Solana connection */
|
|
113
|
+
connection?: Connection;
|
|
114
|
+
/** SPL token information */
|
|
115
|
+
splTokenInfos: SPLTokenInfo[];
|
|
116
|
+
/**
|
|
117
|
+
* Create a new NordUser instance
|
|
118
|
+
*
|
|
119
|
+
* @param params - Parameters for creating a NordUser
|
|
120
|
+
* @throws {NordError} If required parameters are missing
|
|
121
|
+
*/
|
|
122
|
+
constructor(params: NordUserParams);
|
|
123
|
+
/**
|
|
124
|
+
* Create a clone of this NordUser instance
|
|
125
|
+
*
|
|
126
|
+
* @returns A new NordUser instance with the same properties
|
|
127
|
+
*/
|
|
32
128
|
clone(): NordUser;
|
|
33
129
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
130
|
+
* Initialize the Solana bridge client
|
|
131
|
+
*
|
|
132
|
+
* @private
|
|
133
|
+
* @throws {NordError} If required parameters are missing
|
|
134
|
+
*/
|
|
135
|
+
private initBridgeClient;
|
|
136
|
+
/**
|
|
137
|
+
* Create a NordUser from a private key
|
|
138
|
+
*
|
|
139
|
+
* @param nord - Nord instance
|
|
140
|
+
* @param privateKey - Private key as string or Uint8Array
|
|
141
|
+
* @param connection - Solana connection (optional)
|
|
142
|
+
* @returns NordUser instance
|
|
143
|
+
* @throws {NordError} If the private key is invalid
|
|
144
|
+
*/
|
|
145
|
+
static fromPrivateKey(nord: Nord, privateKey: string | Uint8Array, connection?: Connection): NordUser;
|
|
146
|
+
/**
|
|
147
|
+
* Get the associated token account for a token mint
|
|
148
|
+
*
|
|
149
|
+
* @param mint - Token mint address
|
|
150
|
+
* @returns Associated token account address
|
|
151
|
+
* @throws {NordError} If required parameters are missing or operation fails
|
|
152
|
+
*/
|
|
153
|
+
getAssociatedTokenAccount(mint: PublicKey): Promise<PublicKey>;
|
|
154
|
+
/**
|
|
155
|
+
* Deposit SPL tokens to the bridge
|
|
156
|
+
*
|
|
157
|
+
* @param amount - Amount to deposit
|
|
158
|
+
* @param tokenId - Token ID
|
|
159
|
+
* @returns Transaction signature
|
|
160
|
+
* @throws {NordError} If required parameters are missing or operation fails
|
|
161
|
+
*/
|
|
162
|
+
depositSpl(amount: number, tokenId: number): Promise<string>;
|
|
163
|
+
/**
|
|
164
|
+
* Withdraw SPL tokens from the bridge
|
|
165
|
+
*
|
|
166
|
+
* @param claim - Claim data
|
|
167
|
+
* @returns Transaction signature
|
|
168
|
+
* @throws {NordError} If required parameters are missing or operation fails
|
|
169
|
+
*/
|
|
170
|
+
withdrawSpl(claim: any): Promise<string>;
|
|
171
|
+
/**
|
|
172
|
+
* Get a new nonce for actions
|
|
173
|
+
*
|
|
174
|
+
* @returns Nonce as number
|
|
36
175
|
*/
|
|
37
176
|
getNonce(): number;
|
|
177
|
+
/**
|
|
178
|
+
* Update account IDs for this user
|
|
179
|
+
*
|
|
180
|
+
* @throws {NordError} If the operation fails
|
|
181
|
+
*/
|
|
38
182
|
updateAccountId(): Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* Fetch user information including balances and orders
|
|
185
|
+
*
|
|
186
|
+
* @throws {NordError} If the operation fails
|
|
187
|
+
*/
|
|
39
188
|
fetchInfo(): Promise<void>;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
189
|
+
/**
|
|
190
|
+
* Refresh the user's session
|
|
191
|
+
*
|
|
192
|
+
* @param sessionPk - Session public key
|
|
193
|
+
* @throws {NordError} If the operation fails
|
|
194
|
+
*/
|
|
43
195
|
refreshSession(sessionPk: Uint8Array): Promise<void>;
|
|
44
196
|
/**
|
|
45
|
-
*
|
|
197
|
+
* Revoke a session
|
|
46
198
|
*
|
|
47
|
-
* @param sessionId -
|
|
199
|
+
* @param sessionId - Session ID to revoke
|
|
200
|
+
* @throws {NordError} If the operation fails
|
|
48
201
|
*/
|
|
49
202
|
revokeSession(sessionId: BigIntValue): Promise<void>;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
203
|
+
/**
|
|
204
|
+
* Withdraw tokens from the exchange
|
|
205
|
+
*
|
|
206
|
+
* @param tokenId - Token ID to withdraw
|
|
207
|
+
* @param amount - Amount to withdraw
|
|
208
|
+
* @throws {NordError} If the operation fails
|
|
209
|
+
*/
|
|
54
210
|
withdraw(tokenId: number, amount: number): Promise<void>;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
211
|
+
/**
|
|
212
|
+
* Place an order on the exchange
|
|
213
|
+
*
|
|
214
|
+
* @param params - Order parameters
|
|
215
|
+
* @returns Order ID if successful
|
|
216
|
+
* @throws {NordError} If the operation fails
|
|
217
|
+
*/
|
|
218
|
+
placeOrder(params: PlaceOrderParams): Promise<bigint | undefined>;
|
|
219
|
+
/**
|
|
220
|
+
* Cancel an order
|
|
221
|
+
*
|
|
222
|
+
* @param orderId - Order ID to cancel
|
|
223
|
+
* @param accountId - Account ID that placed the order
|
|
224
|
+
* @returns Action ID if successful
|
|
225
|
+
* @throws {NordError} If the operation fails
|
|
226
|
+
*/
|
|
65
227
|
cancelOrder(orderId: BigIntValue, accountId: number): Promise<bigint>;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
228
|
+
/**
|
|
229
|
+
* Transfer tokens to another account
|
|
230
|
+
*
|
|
231
|
+
* @param params - Transfer parameters
|
|
232
|
+
* @throws {NordError} If the operation fails
|
|
233
|
+
*/
|
|
234
|
+
transferToAccount(params: TransferParams): Promise<void>;
|
|
235
|
+
/**
|
|
236
|
+
* Create a new account
|
|
237
|
+
*
|
|
238
|
+
* @param params - Account creation parameters
|
|
239
|
+
* @returns New NordUser instance
|
|
240
|
+
* @throws {NordError} If the operation fails
|
|
241
|
+
*/
|
|
242
|
+
createAccount(params: CreateAccountParams): Promise<NordUser>;
|
|
77
243
|
}
|