@0xmonaco/core 1.0.91 → 1.0.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -21
- package/dist/api/compliance/api.d.ts +20 -0
- package/dist/api/compliance/api.js +23 -0
- package/dist/api/compliance/index.d.ts +1 -0
- package/dist/api/compliance/index.js +1 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/websocket/websocket.js +2 -2
- package/dist/coverage.d.ts +1 -0
- package/dist/coverage.js +1 -0
- package/dist/sdk.d.ts +2 -1
- package/dist/sdk.js +4 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -50,26 +50,12 @@ npm install viem@^2.31.7
|
|
|
50
50
|
|
|
51
51
|
## Network Support
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
**Preset Networks:**
|
|
56
|
-
- `"staging"` - Staging environment (https://staging.apimonaco.xyz)
|
|
57
|
-
- `"mainnet"` - Production environment (https://apimonaco.xyz)
|
|
58
|
-
|
|
59
|
-
WebSocket URLs are automatically resolved per network.
|
|
53
|
+
Configure the network by providing the `network` and `seiRpcUrl` parameters. Use the `"mainnet"` preset, which connects to Sei mainnet and the production API (https://apimonaco.xyz). WebSocket URLs are resolved automatically.
|
|
60
54
|
|
|
61
55
|
```typescript
|
|
62
56
|
import { MonacoSDK } from "@0xmonaco/core";
|
|
63
57
|
|
|
64
|
-
|
|
65
|
-
const stagingSdk = new MonacoSDK({
|
|
66
|
-
walletClient,
|
|
67
|
-
network: "staging",
|
|
68
|
-
seiRpcUrl: "https://evm-rpc-testnet.sei-apis.com",
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// Mainnet configuration
|
|
72
|
-
const mainnetSdk = new MonacoSDK({
|
|
58
|
+
const sdk = new MonacoSDK({
|
|
73
59
|
walletClient,
|
|
74
60
|
network: "mainnet",
|
|
75
61
|
seiRpcUrl: "https://evm-rpc.sei-apis.com",
|
|
@@ -82,19 +68,20 @@ const mainnetSdk = new MonacoSDK({
|
|
|
82
68
|
import { MonacoSDK } from "@0xmonaco/core";
|
|
83
69
|
import { createWalletClient, http } from "viem";
|
|
84
70
|
import { privateKeyToAccount } from "viem/accounts";
|
|
71
|
+
import { sei } from "viem/chains";
|
|
85
72
|
|
|
86
73
|
// Initialize the SDK with wallet client
|
|
87
74
|
const account = privateKeyToAccount("0x...");
|
|
88
75
|
const walletClient = createWalletClient({
|
|
89
76
|
account,
|
|
90
|
-
chain: sei,
|
|
91
|
-
transport: http("https://evm-rpc.sei-apis.com")
|
|
77
|
+
chain: sei,
|
|
78
|
+
transport: http("https://evm-rpc.sei-apis.com")
|
|
92
79
|
});
|
|
93
80
|
|
|
94
81
|
const monaco = new MonacoSDK({
|
|
95
82
|
walletClient,
|
|
96
|
-
network: "
|
|
97
|
-
seiRpcUrl: "https://evm-rpc
|
|
83
|
+
network: "mainnet",
|
|
84
|
+
seiRpcUrl: "https://evm-rpc.sei-apis.com", // public RPC; use a dedicated provider in production
|
|
98
85
|
});
|
|
99
86
|
|
|
100
87
|
// Authentication
|
|
@@ -230,7 +217,7 @@ interface SDKConfig {
|
|
|
230
217
|
/** Wallet client for signing operations (optional - can be set later via setWalletClient) */
|
|
231
218
|
walletClient?: WalletClient;
|
|
232
219
|
|
|
233
|
-
/** Use "
|
|
220
|
+
/** Use "mainnet" (Sei mainnet, production API). */
|
|
234
221
|
network: Network;
|
|
235
222
|
|
|
236
223
|
/** RPC URL for Sei blockchain interactions */
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compliance API Implementation
|
|
3
|
+
*
|
|
4
|
+
* Reports whether Monaco is available in the caller's region. Every other
|
|
5
|
+
* endpoint refuses callers from a restricted region with HTTP 451
|
|
6
|
+
* `REGION_RESTRICTED`; this one always answers. Public — no authentication
|
|
7
|
+
* required.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const { restricted } = await sdk.compliance.getRegionStatus();
|
|
12
|
+
* if (restricted) showRegionNotice();
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
import type { ComplianceAPI, GetRegionStatusResponse } from "@0xmonaco/types";
|
|
16
|
+
import { BaseAPI } from "../base";
|
|
17
|
+
export declare class ComplianceAPIImpl extends BaseAPI implements ComplianceAPI {
|
|
18
|
+
/** Get the caller's region status (public, no auth headers). */
|
|
19
|
+
getRegionStatus(): Promise<GetRegionStatusResponse>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compliance API Implementation
|
|
3
|
+
*
|
|
4
|
+
* Reports whether Monaco is available in the caller's region. Every other
|
|
5
|
+
* endpoint refuses callers from a restricted region with HTTP 451
|
|
6
|
+
* `REGION_RESTRICTED`; this one always answers. Public — no authentication
|
|
7
|
+
* required.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const { restricted } = await sdk.compliance.getRegionStatus();
|
|
12
|
+
* if (restricted) showRegionNotice();
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
import { BaseAPI } from "../base";
|
|
16
|
+
export class ComplianceAPIImpl extends BaseAPI {
|
|
17
|
+
/** Get the caller's region status (public, no auth headers). */
|
|
18
|
+
async getRegionStatus() {
|
|
19
|
+
return await this.makePublicRequest("/api/v1/compliance/region", {
|
|
20
|
+
method: "GET",
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ComplianceAPIImpl } from "./api";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ComplianceAPIImpl } from "./api";
|
package/dist/api/index.d.ts
CHANGED
package/dist/api/index.js
CHANGED
|
@@ -1301,7 +1301,7 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
|
|
|
1301
1301
|
if (msg.code === "AUTH_FAILED") {
|
|
1302
1302
|
lastAuthError = { code: msg.code, message: msg.message, session: pendingAuthSessions.shift() };
|
|
1303
1303
|
}
|
|
1304
|
-
else if (msg.code === "ACCOUNT_DEACTIVATED") {
|
|
1304
|
+
else if (msg.code === "ACCOUNT_DEACTIVATED" || msg.code === "ACCOUNT_RESTRICTED") {
|
|
1305
1305
|
lastAuthError = { code: msg.code, message: msg.message, session: pendingAuthSessions.shift() ?? confirmedSession };
|
|
1306
1306
|
}
|
|
1307
1307
|
else if (msg.code === "SESSION_INVALID") {
|
|
@@ -1489,7 +1489,7 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
|
|
|
1489
1489
|
const authLoss = !skewRetry &&
|
|
1490
1490
|
authError !== null &&
|
|
1491
1491
|
authError.session !== undefined &&
|
|
1492
|
-
(authError.code === "AUTH_FAILED" || authError.code === "ACCOUNT_DEACTIVATED" || event.code === 1008);
|
|
1492
|
+
(authError.code === "AUTH_FAILED" || authError.code === "ACCOUNT_DEACTIVATED" || authError.code === "ACCOUNT_RESTRICTED" || event.code === 1008);
|
|
1493
1493
|
const terminalAuthLoss = authLoss && session === authError.session;
|
|
1494
1494
|
if (terminalAuthLoss) {
|
|
1495
1495
|
session = undefined;
|
package/dist/coverage.d.ts
CHANGED
|
@@ -57,6 +57,7 @@ export declare const COVERED: {
|
|
|
57
57
|
get_market_stats: string;
|
|
58
58
|
get_my_fee_tier: string;
|
|
59
59
|
get_pulse: string;
|
|
60
|
+
get_region_status: string;
|
|
60
61
|
list_managed_market_assignments: string;
|
|
61
62
|
claim_managed_market_lease: string;
|
|
62
63
|
refresh_managed_market_quotes: string;
|
package/dist/coverage.js
CHANGED
|
@@ -57,6 +57,7 @@ export const COVERED = {
|
|
|
57
57
|
get_market_stats: "getMarketStats",
|
|
58
58
|
get_my_fee_tier: "getMyFeeTier",
|
|
59
59
|
get_pulse: "pulse.getPulse",
|
|
60
|
+
get_region_status: "compliance.getRegionStatus",
|
|
60
61
|
list_managed_market_assignments: "managedMarkets.listAssignments",
|
|
61
62
|
claim_managed_market_lease: "managedMarkets.claimLease",
|
|
62
63
|
refresh_managed_market_quotes: "managedMarkets.refreshQuotes",
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApplicationsAPI, AuthAPI, AuthState, BuildercodesAPI, CopyTradingAPI, DelegatedAgentsAPI, FaucetAPI, FeesAPI, ManagedMarketsAPI, MarginAccountsAPI, MarketAPI, MonacoSDK, Network, PortfolioAPI, PositionsAPI, ProfileAPI, PulseAPI, SDKConfig, SubAccountsAPI, SweeperAPI, TraderCodesAPI, TradingAPI, VaultAPI, WhitelistAPI, WithdrawalsAPI } from "@0xmonaco/types";
|
|
1
|
+
import type { ApplicationsAPI, AuthAPI, AuthState, BuildercodesAPI, ComplianceAPI, CopyTradingAPI, DelegatedAgentsAPI, FaucetAPI, FeesAPI, ManagedMarketsAPI, MarginAccountsAPI, MarketAPI, MonacoSDK, Network, PortfolioAPI, PositionsAPI, ProfileAPI, PulseAPI, SDKConfig, SubAccountsAPI, SweeperAPI, TraderCodesAPI, TradingAPI, VaultAPI, WhitelistAPI, WithdrawalsAPI } from "@0xmonaco/types";
|
|
2
2
|
import { type Address, type PublicClient, type TransactionReceipt, type WalletClient } from "viem";
|
|
3
3
|
import { type MonacoWebSocket, OrderbookAPIImpl, TradesAPIImpl } from "./api";
|
|
4
4
|
export declare class MonacoSDKImpl implements MonacoSDK {
|
|
@@ -23,6 +23,7 @@ export declare class MonacoSDKImpl implements MonacoSDK {
|
|
|
23
23
|
whitelist: WhitelistAPI;
|
|
24
24
|
profile: ProfileAPI;
|
|
25
25
|
pulse: PulseAPI;
|
|
26
|
+
compliance: ComplianceAPI;
|
|
26
27
|
orderbook: OrderbookAPIImpl;
|
|
27
28
|
trades: TradesAPIImpl;
|
|
28
29
|
ws: MonacoWebSocket;
|
package/dist/sdk.js
CHANGED
|
@@ -4,6 +4,7 @@ import { sei, seiTestnet } from "viem/chains";
|
|
|
4
4
|
import { ApplicationsAPIImpl, createMonacoWebSocket, OrderbookAPIImpl, TradesAPIImpl } from "./api";
|
|
5
5
|
import { AuthAPIImpl } from "./api/auth";
|
|
6
6
|
import { BuildercodesAPIImpl } from "./api/buildercodes";
|
|
7
|
+
import { ComplianceAPIImpl } from "./api/compliance";
|
|
7
8
|
import { CopyTradingAPIImpl } from "./api/copy-trading";
|
|
8
9
|
import { DelegatedAgentsAPIImpl } from "./api/delegated-agents";
|
|
9
10
|
import { FaucetAPIImpl } from "./api/faucet";
|
|
@@ -64,6 +65,7 @@ export class MonacoSDKImpl {
|
|
|
64
65
|
whitelist;
|
|
65
66
|
profile;
|
|
66
67
|
pulse;
|
|
68
|
+
compliance;
|
|
67
69
|
orderbook;
|
|
68
70
|
trades;
|
|
69
71
|
ws;
|
|
@@ -97,6 +99,7 @@ export class MonacoSDKImpl {
|
|
|
97
99
|
this.managedMarkets.setSessionKeypair(credentials);
|
|
98
100
|
this.whitelist.setSessionKeypair(credentials);
|
|
99
101
|
this.pulse.setSessionKeypair(credentials);
|
|
102
|
+
this.compliance.setSessionKeypair(credentials);
|
|
100
103
|
this.profile.setSessionKeypair(credentials);
|
|
101
104
|
this.orderbook.setSessionKeypair(credentials);
|
|
102
105
|
this.trades.setSessionKeypair(credentials);
|
|
@@ -168,6 +171,7 @@ export class MonacoSDKImpl {
|
|
|
168
171
|
this.managedMarkets = configureSigning(new ManagedMarketsAPIImpl(apiUrl));
|
|
169
172
|
this.whitelist = configureSigning(new WhitelistAPIImpl(apiUrl));
|
|
170
173
|
this.pulse = configureSigning(new PulseAPIImpl(apiUrl));
|
|
174
|
+
this.compliance = configureSigning(new ComplianceAPIImpl(apiUrl));
|
|
171
175
|
this.auth = configureSigning(new AuthAPIImpl(this.walletClient, this.chain, apiUrl));
|
|
172
176
|
this.delegatedAgents = configureSigning(new DelegatedAgentsAPIImpl(apiUrl));
|
|
173
177
|
this.fees = configureSigning(new FeesAPIImpl(apiUrl));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xmonaco/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.92",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"homepage": "https://docs.0xmonaco.com/sdk/typescript",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"viem": "^2.45.2"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@0xmonaco/contracts": "1.0.
|
|
23
|
-
"@0xmonaco/types": "1.0.
|
|
22
|
+
"@0xmonaco/contracts": "1.0.92",
|
|
23
|
+
"@0xmonaco/types": "1.0.92",
|
|
24
24
|
"@noble/curves": "^1.9.1",
|
|
25
25
|
"@noble/hashes": "^2.4.0",
|
|
26
26
|
"http-status-codes": "^2.3.0"
|