@stableops/wallet-sdk 0.1.0
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/LICENSE +184 -0
- package/README.md +148 -0
- package/README.zh-CN.md +133 -0
- package/dist/index.d.mts +131 -0
- package/dist/index.d.ts +131 -0
- package/dist/index.js +655 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +610 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +58 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Transaction, Connection } from '@solana/web3.js';
|
|
2
|
+
|
|
3
|
+
type ChainId = 'ethereum' | 'base' | 'base-sepolia' | 'arbitrum' | 'polygon' | 'tron' | 'solana' | 'ethereum-sepolia' | 'arbitrum-sepolia' | 'polygon-amoy' | 'solana-devnet' | 'tron-nile';
|
|
4
|
+
type Asset = 'USDC' | 'USDT';
|
|
5
|
+
type EvmWalletChainId = Exclude<ChainId, 'tron' | 'solana' | 'tron-nile' | 'solana-devnet'>;
|
|
6
|
+
type Eip1193Provider = {
|
|
7
|
+
request<T = unknown>(args: {
|
|
8
|
+
method: string;
|
|
9
|
+
params?: unknown[] | Record<string, unknown>;
|
|
10
|
+
}): Promise<T>;
|
|
11
|
+
};
|
|
12
|
+
type TronWalletProvider = TronWebLike | {
|
|
13
|
+
tronWeb?: TronWebLike;
|
|
14
|
+
tronLink?: {
|
|
15
|
+
request: <T = unknown>(args: {
|
|
16
|
+
method: string;
|
|
17
|
+
params?: unknown;
|
|
18
|
+
}) => Promise<T>;
|
|
19
|
+
};
|
|
20
|
+
request?<T = unknown>(args: {
|
|
21
|
+
method: string;
|
|
22
|
+
params?: unknown;
|
|
23
|
+
}): Promise<T>;
|
|
24
|
+
};
|
|
25
|
+
type SolanaWalletProvider = {
|
|
26
|
+
publicKey?: SolanaPublicKeyLike | string | null;
|
|
27
|
+
connect?(): Promise<{
|
|
28
|
+
publicKey?: SolanaPublicKeyLike | string | null;
|
|
29
|
+
} | void>;
|
|
30
|
+
signAndSendTransaction?(transaction: Transaction): Promise<string | {
|
|
31
|
+
signature?: string;
|
|
32
|
+
}>;
|
|
33
|
+
signTransaction?(transaction: Transaction): Promise<Transaction>;
|
|
34
|
+
};
|
|
35
|
+
type WalletProvider = Eip1193Provider | TronWalletProvider | SolanaWalletProvider;
|
|
36
|
+
type TronWebLike = {
|
|
37
|
+
defaultAddress?: {
|
|
38
|
+
base58?: string;
|
|
39
|
+
};
|
|
40
|
+
transactionBuilder: {
|
|
41
|
+
triggerSmartContract(contractAddress: string, functionSelector: string, options: Record<string, unknown>, parameters: Array<{
|
|
42
|
+
type: string;
|
|
43
|
+
value: string | bigint;
|
|
44
|
+
}>, issuerAddress?: string): Promise<{
|
|
45
|
+
transaction?: unknown;
|
|
46
|
+
result?: {
|
|
47
|
+
result?: boolean;
|
|
48
|
+
message?: string;
|
|
49
|
+
};
|
|
50
|
+
}>;
|
|
51
|
+
};
|
|
52
|
+
trx: {
|
|
53
|
+
sign(transaction: unknown): Promise<unknown>;
|
|
54
|
+
sendRawTransaction(transaction: unknown): Promise<{
|
|
55
|
+
txid?: string;
|
|
56
|
+
transaction?: {
|
|
57
|
+
txID?: string;
|
|
58
|
+
};
|
|
59
|
+
result?: boolean;
|
|
60
|
+
}>;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
type SolanaPublicKeyLike = {
|
|
64
|
+
toBase58(): string;
|
|
65
|
+
};
|
|
66
|
+
type WalletPaymentInstruction = {
|
|
67
|
+
chain: ChainId;
|
|
68
|
+
asset: Asset;
|
|
69
|
+
address: string;
|
|
70
|
+
};
|
|
71
|
+
type WalletPaymentOrder = {
|
|
72
|
+
amount: string;
|
|
73
|
+
paymentInstructions: WalletPaymentInstruction[];
|
|
74
|
+
};
|
|
75
|
+
type EvmWalletChainConfig = {
|
|
76
|
+
chainId: EvmWalletChainId;
|
|
77
|
+
eip155ChainId: number;
|
|
78
|
+
chainName: string;
|
|
79
|
+
nativeCurrency: {
|
|
80
|
+
name: string;
|
|
81
|
+
symbol: string;
|
|
82
|
+
decimals: number;
|
|
83
|
+
};
|
|
84
|
+
rpcUrls: string[];
|
|
85
|
+
blockExplorerUrls?: string[];
|
|
86
|
+
};
|
|
87
|
+
type SendWalletPaymentInput = {
|
|
88
|
+
provider: WalletProvider;
|
|
89
|
+
instruction: WalletPaymentInstruction | null;
|
|
90
|
+
amount: string;
|
|
91
|
+
fromAddress?: string;
|
|
92
|
+
chainConfigs?: Partial<Record<EvmWalletChainId, EvmWalletChainConfig>>;
|
|
93
|
+
solanaRpcUrl?: string;
|
|
94
|
+
solanaConnection?: Pick<Connection, 'getLatestBlockhash' | 'sendRawTransaction'>;
|
|
95
|
+
};
|
|
96
|
+
type WalletProviderByChain = Partial<Record<ChainId, WalletProvider | undefined>>;
|
|
97
|
+
type SendOrderWalletPaymentInput = Omit<SendWalletPaymentInput, 'provider' | 'instruction' | 'amount'> & {
|
|
98
|
+
order: WalletPaymentOrder;
|
|
99
|
+
providers: WalletProviderByChain;
|
|
100
|
+
preferredChains?: ChainId[];
|
|
101
|
+
};
|
|
102
|
+
type SentWalletPayment = {
|
|
103
|
+
txHash: string;
|
|
104
|
+
chain: ChainId;
|
|
105
|
+
asset: Asset;
|
|
106
|
+
fromAddress: string;
|
|
107
|
+
toAddress: string;
|
|
108
|
+
tokenContract: string;
|
|
109
|
+
amount: string;
|
|
110
|
+
amountUnits: string;
|
|
111
|
+
};
|
|
112
|
+
declare class StableOpsWalletError extends Error {
|
|
113
|
+
readonly code: string;
|
|
114
|
+
readonly details?: unknown | undefined;
|
|
115
|
+
constructor(message: string, code: string, details?: unknown | undefined);
|
|
116
|
+
}
|
|
117
|
+
declare const EvmWalletChainConfigs: Readonly<Record<EvmWalletChainId, EvmWalletChainConfig>>;
|
|
118
|
+
declare function getInjectedEthereumProvider(): Eip1193Provider | undefined;
|
|
119
|
+
declare function getInjectedTronProvider(): TronWalletProvider | undefined;
|
|
120
|
+
declare function getInjectedSolanaProvider(): SolanaWalletProvider | undefined;
|
|
121
|
+
declare function getInjectedWalletProviders(): WalletProviderByChain;
|
|
122
|
+
declare function selectWalletPaymentInstruction(instructions: readonly WalletPaymentInstruction[], providers: WalletProviderByChain, preferredChains?: readonly ChainId[]): {
|
|
123
|
+
instruction: WalletPaymentInstruction;
|
|
124
|
+
provider: WalletProvider;
|
|
125
|
+
};
|
|
126
|
+
declare function sendOrderWalletPayment(input: SendOrderWalletPaymentInput): Promise<SentWalletPayment>;
|
|
127
|
+
declare function sendWalletPayment(input: SendWalletPaymentInput): Promise<SentWalletPayment>;
|
|
128
|
+
declare function encodeErc20Transfer(toAddress: string, amountUnits: bigint): string;
|
|
129
|
+
declare function parseTokenAmount(amount: string, decimals: number): bigint;
|
|
130
|
+
|
|
131
|
+
export { type Asset, type ChainId, type Eip1193Provider, type EvmWalletChainConfig, EvmWalletChainConfigs, type SendOrderWalletPaymentInput, type SendWalletPaymentInput, type SentWalletPayment, type SolanaWalletProvider, StableOpsWalletError, type TronWalletProvider, type WalletPaymentInstruction, type WalletPaymentOrder, type WalletProvider, type WalletProviderByChain, encodeErc20Transfer, getInjectedEthereumProvider, getInjectedSolanaProvider, getInjectedTronProvider, getInjectedWalletProviders, parseTokenAmount, selectWalletPaymentInstruction, sendOrderWalletPayment, sendWalletPayment };
|