@sodax/types 2.0.0-rc.11 → 2.0.0-rc.12
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/dist/bitcoin/bitcoin.d.ts +18 -0
- package/dist/bitcoin/bitcoin.js +13 -0
- package/dist/chains/chains.d.ts +2 -2
- package/dist/chains/chains.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/near/near.d.ts +5 -1
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.js +1 -0
- package/dist/shared/logger.d.ts +27 -0
- package/dist/shared/logger.js +1 -0
- package/dist/sodax-config/sodax-config.d.ts +16 -2
- package/package.json +1 -1
|
@@ -6,6 +6,17 @@ export declare function isSupportedBitcoinAddressType(addressType: string): addr
|
|
|
6
6
|
* Shared utility — use this instead of duplicating prefix checks.
|
|
7
7
|
*/
|
|
8
8
|
export declare function detectBitcoinAddressType(address: string): BtcAddressType;
|
|
9
|
+
/**
|
|
10
|
+
* Off-chain message-signing scheme a Bitcoin address type must use: BIP-322 vs ECDSA (BIP-137).
|
|
11
|
+
*
|
|
12
|
+
* - **P2WPKH / P2TR → BIP-322.** Taproot keys are Schnorr/x-only, so ECDSA cannot sign for them
|
|
13
|
+
* (and wallets like Xverse default to Taproot).
|
|
14
|
+
* - **P2SH / P2PKH → ECDSA (BIP-137).** Browser wallets (UniSat/OKX) reject BIP-322 on
|
|
15
|
+
* nested-segwit/legacy addresses — they throw "Not support address type to sign".
|
|
16
|
+
*
|
|
17
|
+
* No single scheme works for every address type, so signers AND verifiers must branch on this.
|
|
18
|
+
*/
|
|
19
|
+
export declare function usesBip322MessageSigning(addressType: BtcAddressType): boolean;
|
|
9
20
|
export declare const BTC_WALLET_ADDRESS_TYPES: readonly ["taproot", "segwit"];
|
|
10
21
|
/** User-friendly Bitcoin address type for wallet connection. */
|
|
11
22
|
export type BtcWalletAddressType = (typeof BTC_WALLET_ADDRESS_TYPES)[number];
|
|
@@ -86,6 +97,13 @@ export interface IBitcoinWalletProvider extends ICoreWallet {
|
|
|
86
97
|
signTransaction(psbt: string, finalize?: boolean): Promise<string>;
|
|
87
98
|
signEcdsaMessage(message: string): Promise<string>;
|
|
88
99
|
signBip322Message(message: string): Promise<string>;
|
|
100
|
+
/**
|
|
101
|
+
* Get the signer's public key as a hex string. Optional capability: required only for the
|
|
102
|
+
* money-market on-demand (borrow/withdraw) flow, where the relay needs the key to verify a
|
|
103
|
+
* BIP-322 (Schnorr/Taproot) signature — which is not public-key-recoverable. Wallets that
|
|
104
|
+
* cannot expose it omit this method; callers guard before use.
|
|
105
|
+
*/
|
|
106
|
+
getPublicKey?(): Promise<string>;
|
|
89
107
|
/**
|
|
90
108
|
* Send Bitcoin to an address
|
|
91
109
|
* @param toAddress - Destination Bitcoin address
|
package/dist/bitcoin/bitcoin.js
CHANGED
|
@@ -17,6 +17,19 @@ export function detectBitcoinAddressType(address) {
|
|
|
17
17
|
return 'P2PKH';
|
|
18
18
|
throw new Error(`Unknown Bitcoin address type: ${address}`);
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Off-chain message-signing scheme a Bitcoin address type must use: BIP-322 vs ECDSA (BIP-137).
|
|
22
|
+
*
|
|
23
|
+
* - **P2WPKH / P2TR → BIP-322.** Taproot keys are Schnorr/x-only, so ECDSA cannot sign for them
|
|
24
|
+
* (and wallets like Xverse default to Taproot).
|
|
25
|
+
* - **P2SH / P2PKH → ECDSA (BIP-137).** Browser wallets (UniSat/OKX) reject BIP-322 on
|
|
26
|
+
* nested-segwit/legacy addresses — they throw "Not support address type to sign".
|
|
27
|
+
*
|
|
28
|
+
* No single scheme works for every address type, so signers AND verifiers must branch on this.
|
|
29
|
+
*/
|
|
30
|
+
export function usesBip322MessageSigning(addressType) {
|
|
31
|
+
return addressType === 'P2WPKH' || addressType === 'P2TR';
|
|
32
|
+
}
|
|
20
33
|
export const BTC_WALLET_ADDRESS_TYPES = ['taproot', 'segwit'];
|
|
21
34
|
/** Address types that Sodax supports for transactions. */
|
|
22
35
|
const BTC_ADDRESS_TYPES = ['P2PKH', 'P2SH', 'P2WPKH', 'P2TR'];
|
package/dist/chains/chains.d.ts
CHANGED
|
@@ -2417,9 +2417,9 @@ export declare const spokeChainConfig: {
|
|
|
2417
2417
|
};
|
|
2418
2418
|
readonly radfi: {
|
|
2419
2419
|
readonly walletMode: "TRADING";
|
|
2420
|
-
readonly apiUrl: "https://api.
|
|
2420
|
+
readonly apiUrl: "https://api.bound.exchange/api";
|
|
2421
2421
|
readonly apiKey: "";
|
|
2422
|
-
readonly umsUrl: "https://ums.
|
|
2422
|
+
readonly umsUrl: "https://api.ums.bound.exchange/api";
|
|
2423
2423
|
readonly accessToken: "";
|
|
2424
2424
|
readonly refreshToken: "";
|
|
2425
2425
|
};
|
package/dist/chains/chains.js
CHANGED
|
@@ -519,9 +519,9 @@ export const spokeChainConfig = {
|
|
|
519
519
|
supportedTokens: bitcoinSupportedTokens,
|
|
520
520
|
radfi: {
|
|
521
521
|
walletMode: 'TRADING',
|
|
522
|
-
apiUrl: 'https://api.
|
|
522
|
+
apiUrl: 'https://api.bound.exchange/api',
|
|
523
523
|
apiKey: '',
|
|
524
|
-
umsUrl: 'https://ums.
|
|
524
|
+
umsUrl: 'https://api.ums.bound.exchange/api',
|
|
525
525
|
accessToken: '',
|
|
526
526
|
refreshToken: '',
|
|
527
527
|
},
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -17,4 +17,4 @@ export * from './sui/index.js';
|
|
|
17
17
|
export * from './swap/index.js';
|
|
18
18
|
export * from './utils/index.js';
|
|
19
19
|
export * from './wallet/index.js';
|
|
20
|
-
export const CONFIG_VERSION =
|
|
20
|
+
export const CONFIG_VERSION = 210; // this value should be incremented (inside release/sdk branch) each time @sodax/types package is updated
|
package/dist/near/near.d.ts
CHANGED
|
@@ -37,6 +37,10 @@ export interface FTTransferCallArgs {
|
|
|
37
37
|
memo?: string;
|
|
38
38
|
msg?: string;
|
|
39
39
|
}
|
|
40
|
+
export interface StorageDepositArgs {
|
|
41
|
+
account_id: string;
|
|
42
|
+
registration_only?: boolean;
|
|
43
|
+
}
|
|
40
44
|
export interface NearTransferArgs {
|
|
41
45
|
to: Array<number>;
|
|
42
46
|
amount: string;
|
|
@@ -52,7 +56,7 @@ export interface SetHubConfig {
|
|
|
52
56
|
hub_chain_id: number;
|
|
53
57
|
hub_asset_manager: number[];
|
|
54
58
|
}
|
|
55
|
-
export type ContractArgs = TransferArgs | InitArgs | SetHubConfig | FTTransferCallArgs | NearTransferArgs | SendMsgArgs | FillIntentArgs;
|
|
59
|
+
export type ContractArgs = TransferArgs | InitArgs | SetHubConfig | FTTransferCallArgs | StorageDepositArgs | NearTransferArgs | SendMsgArgs | FillIntentArgs;
|
|
56
60
|
export interface CallContractParams {
|
|
57
61
|
contractId: string;
|
|
58
62
|
method: string;
|
package/dist/shared/index.d.ts
CHANGED
package/dist/shared/index.js
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified logging interface for the SDK.
|
|
3
|
+
*
|
|
4
|
+
* The SDK routes all of its internal diagnostics through a `SodaxLogger` instead of
|
|
5
|
+
* calling `console.*` directly, so consumers can redirect or silence SDK output and
|
|
6
|
+
* forward it to a structured sink (Sentry, Pino, Datadog, etc.).
|
|
7
|
+
*
|
|
8
|
+
* Pass one to `new Sodax({ logger })` via {@link SodaxLoggerOption}:
|
|
9
|
+
* - `'console'` — default; mirrors the SDK's historical `console.*` behavior.
|
|
10
|
+
* - `'silent'` — drop all SDK logs.
|
|
11
|
+
* - a custom `SodaxLogger` — forward to your own sink.
|
|
12
|
+
*
|
|
13
|
+
* `error()` receives the thrown value separately from structured `data` so adapters
|
|
14
|
+
* can attach it as the exception (e.g. `Sentry.captureException(error, { extra: data })`).
|
|
15
|
+
* SDK errors are `SodaxError` instances whose `toJSON()` is the canonical serialization surface.
|
|
16
|
+
*/
|
|
17
|
+
export interface SodaxLogger {
|
|
18
|
+
debug(message: string, data?: Record<string, unknown>): void;
|
|
19
|
+
info(message: string, data?: Record<string, unknown>): void;
|
|
20
|
+
warn(message: string, data?: Record<string, unknown>): void;
|
|
21
|
+
error(message: string, error?: unknown, data?: Record<string, unknown>): void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Logger configuration accepted by `new Sodax(...)`. Either a built-in preset name or a
|
|
25
|
+
* custom {@link SodaxLogger} implementation. Resolved to a concrete `SodaxLogger` by the SDK.
|
|
26
|
+
*/
|
|
27
|
+
export type SodaxLoggerOption = SodaxLogger | 'console' | 'silent';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { TxPollingConfig } from '../shared/shared.js';
|
|
2
|
+
import type { SodaxLoggerOption } from '../shared/logger.js';
|
|
3
|
+
import type { DeepPartial } from '../utils/deep-partial.js';
|
|
2
4
|
import { type ApiConfig, type SolverConfig, type RelayConfig } from '../common/constants.js';
|
|
3
5
|
import type { MoneyMarketConfig, PartnerFee } from '../common/common.js';
|
|
4
6
|
import { type DexConfig } from '../dex/dex.js';
|
|
@@ -42,6 +44,18 @@ export type SodaxConfig = {
|
|
|
42
44
|
solver: SolverConfig;
|
|
43
45
|
relay: RelayConfig;
|
|
44
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Options accepted by `new Sodax(...)`. A deep-partial override of the {@link SodaxConfig} data
|
|
49
|
+
* contract, plus the client-side `logger` runtime option which is deliberately kept OUT of
|
|
50
|
+
* `SodaxConfig` itself: `SodaxConfig` is the data shape fetched from / merged with the backend,
|
|
51
|
+
* whereas `logger` is a local sink that is resolved once and never fetched or overwritten.
|
|
52
|
+
*
|
|
53
|
+
* Keeping `logger` here (rather than on `SodaxConfig`) means `DeepPartial<SodaxConfig>` no longer
|
|
54
|
+
* makes the logger's methods optional, so the SDK can resolve `options.logger` without casting.
|
|
55
|
+
*/
|
|
56
|
+
export type SodaxOptions = DeepPartial<SodaxConfig> & {
|
|
57
|
+
logger?: SodaxLoggerOption;
|
|
58
|
+
};
|
|
45
59
|
export declare const sodaxConfig: {
|
|
46
60
|
fee: undefined;
|
|
47
61
|
chains: {
|
|
@@ -1958,9 +1972,9 @@ export declare const sodaxConfig: {
|
|
|
1958
1972
|
};
|
|
1959
1973
|
readonly radfi: {
|
|
1960
1974
|
readonly walletMode: "TRADING";
|
|
1961
|
-
readonly apiUrl: "https://api.
|
|
1975
|
+
readonly apiUrl: "https://api.bound.exchange/api";
|
|
1962
1976
|
readonly apiKey: "";
|
|
1963
|
-
readonly umsUrl: "https://ums.
|
|
1977
|
+
readonly umsUrl: "https://api.ums.bound.exchange/api";
|
|
1964
1978
|
readonly accessToken: "";
|
|
1965
1979
|
readonly refreshToken: "";
|
|
1966
1980
|
};
|
package/package.json
CHANGED