@sip-protocol/sdk 0.3.2 → 0.5.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/dist/browser.d.mts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +2881 -295
- package/dist/browser.mjs +62 -2
- package/dist/chunk-AOZIY3GU.mjs +12995 -0
- package/dist/chunk-BCLIX5T2.mjs +12940 -0
- package/dist/chunk-DMHBKRWV.mjs +14712 -0
- package/dist/chunk-FKXPHKYD.mjs +12955 -0
- package/dist/chunk-HGU6HZRC.mjs +231 -0
- package/dist/chunk-J4Q4NJ2U.mjs +13544 -0
- package/dist/chunk-OPQ2GQIO.mjs +13013 -0
- package/dist/chunk-W2B7T6WU.mjs +14714 -0
- package/dist/index-5jAdWMA-.d.ts +8973 -0
- package/dist/index-B9Vkpaao.d.mts +8973 -0
- package/dist/index-BcWNakUD.d.ts +7990 -0
- package/dist/index-BsKY3Hr0.d.mts +7990 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2852 -266
- package/dist/index.mjs +62 -2
- package/dist/proofs/noir.mjs +1 -1
- package/package.json +2 -1
- package/src/adapters/near-intents.ts +8 -0
- package/src/bitcoin/index.ts +51 -0
- package/src/bitcoin/silent-payments.ts +865 -0
- package/src/bitcoin/taproot.ts +590 -0
- package/src/compliance/compliance-manager.ts +87 -0
- package/src/compliance/conditional-threshold.ts +379 -0
- package/src/compliance/conditional.ts +382 -0
- package/src/compliance/derivation.ts +489 -0
- package/src/compliance/index.ts +50 -8
- package/src/compliance/pdf.ts +365 -0
- package/src/compliance/reports.ts +644 -0
- package/src/compliance/threshold.ts +529 -0
- package/src/compliance/types.ts +223 -0
- package/src/cosmos/ibc-stealth.ts +825 -0
- package/src/cosmos/index.ts +83 -0
- package/src/cosmos/stealth.ts +487 -0
- package/src/errors.ts +8 -0
- package/src/index.ts +80 -1
- package/src/move/aptos.ts +369 -0
- package/src/move/index.ts +35 -0
- package/src/move/sui.ts +367 -0
- package/src/oracle/types.ts +8 -0
- package/src/settlement/backends/direct-chain.ts +8 -0
- package/src/stealth.ts +3 -3
- package/src/validation.ts +42 -1
- package/src/wallet/aptos/adapter.ts +422 -0
- package/src/wallet/aptos/index.ts +10 -0
- package/src/wallet/aptos/mock.ts +410 -0
- package/src/wallet/aptos/types.ts +278 -0
- package/src/wallet/bitcoin/adapter.ts +470 -0
- package/src/wallet/bitcoin/index.ts +38 -0
- package/src/wallet/bitcoin/mock.ts +516 -0
- package/src/wallet/bitcoin/types.ts +274 -0
- package/src/wallet/cosmos/adapter.ts +484 -0
- package/src/wallet/cosmos/index.ts +63 -0
- package/src/wallet/cosmos/mock.ts +596 -0
- package/src/wallet/cosmos/types.ts +462 -0
- package/src/wallet/index.ts +127 -0
- package/src/wallet/sui/adapter.ts +471 -0
- package/src/wallet/sui/index.ts +10 -0
- package/src/wallet/sui/mock.ts +439 -0
- package/src/wallet/sui/types.ts +245 -0
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cosmos Wallet Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for Cosmos ecosystem wallet integration.
|
|
5
|
+
* Supports Keplr, Leap, and other Cosmos wallets using standard interfaces.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { HexString } from '@sip-protocol/types'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Cosmos account data interface
|
|
12
|
+
* Represents a Cosmos account with address and public key
|
|
13
|
+
*/
|
|
14
|
+
export interface CosmosAccountData {
|
|
15
|
+
/** Bech32 encoded address (e.g., cosmos1...) */
|
|
16
|
+
address: string
|
|
17
|
+
/** Algorithm used for key generation (typically secp256k1) */
|
|
18
|
+
algo: 'secp256k1' | 'eth-secp256k1' | 'ed25519'
|
|
19
|
+
/** Public key bytes */
|
|
20
|
+
pubkey: Uint8Array
|
|
21
|
+
/** Whether this is an Ethereum-compatible account (ethermint) */
|
|
22
|
+
isEthermintAccount?: boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Cosmos signature algorithm
|
|
27
|
+
*/
|
|
28
|
+
export type CosmosAlgo = 'secp256k1' | 'eth-secp256k1' | 'ed25519'
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Amino sign doc (legacy signing)
|
|
32
|
+
* Used for compatibility with older Cosmos SDK versions
|
|
33
|
+
*/
|
|
34
|
+
export interface StdSignDoc {
|
|
35
|
+
chain_id: string
|
|
36
|
+
account_number: string
|
|
37
|
+
sequence: string
|
|
38
|
+
fee: StdFee
|
|
39
|
+
msgs: readonly CosmosMsg[]
|
|
40
|
+
memo: string
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Standard fee structure
|
|
45
|
+
*/
|
|
46
|
+
export interface StdFee {
|
|
47
|
+
amount: readonly Coin[]
|
|
48
|
+
gas: string
|
|
49
|
+
granter?: string
|
|
50
|
+
payer?: string
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Cosmos coin denomination
|
|
55
|
+
*/
|
|
56
|
+
export interface Coin {
|
|
57
|
+
denom: string
|
|
58
|
+
amount: string
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Generic Cosmos message
|
|
63
|
+
*/
|
|
64
|
+
export interface CosmosMsg {
|
|
65
|
+
type: string
|
|
66
|
+
value: unknown
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Amino signing response
|
|
71
|
+
*/
|
|
72
|
+
export interface AminoSignResponse {
|
|
73
|
+
/** Signed document */
|
|
74
|
+
signed: StdSignDoc
|
|
75
|
+
/** Signature */
|
|
76
|
+
signature: StdSignature
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Standard signature
|
|
81
|
+
*/
|
|
82
|
+
export interface StdSignature {
|
|
83
|
+
pub_key: PubKey
|
|
84
|
+
signature: string // Base64 encoded
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Public key structure
|
|
89
|
+
*/
|
|
90
|
+
export interface PubKey {
|
|
91
|
+
type: string
|
|
92
|
+
value: string // Base64 encoded
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Direct sign doc (protobuf signing)
|
|
97
|
+
* Used for newer Cosmos SDK versions with protobuf transactions
|
|
98
|
+
*/
|
|
99
|
+
export interface DirectSignDoc {
|
|
100
|
+
/** Serialized body bytes */
|
|
101
|
+
bodyBytes: Uint8Array
|
|
102
|
+
/** Serialized auth info bytes */
|
|
103
|
+
authInfoBytes: Uint8Array
|
|
104
|
+
/** Chain ID */
|
|
105
|
+
chainId: string
|
|
106
|
+
/** Account number */
|
|
107
|
+
accountNumber: bigint
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Direct signing response
|
|
112
|
+
*/
|
|
113
|
+
export interface DirectSignResponse {
|
|
114
|
+
/** Signed document */
|
|
115
|
+
signed: DirectSignDoc
|
|
116
|
+
/** Signature bytes */
|
|
117
|
+
signature: StdSignature
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Keplr window interface
|
|
122
|
+
* Injected by Keplr browser extension
|
|
123
|
+
*/
|
|
124
|
+
export interface Keplr {
|
|
125
|
+
/** Enable connection to a chain */
|
|
126
|
+
enable(chainId: string | string[]): Promise<void>
|
|
127
|
+
|
|
128
|
+
/** Get account for a chain */
|
|
129
|
+
getKey(chainId: string): Promise<Key>
|
|
130
|
+
|
|
131
|
+
/** Sign using Amino */
|
|
132
|
+
signAmino(
|
|
133
|
+
chainId: string,
|
|
134
|
+
signer: string,
|
|
135
|
+
signDoc: StdSignDoc,
|
|
136
|
+
signOptions?: KeplrSignOptions
|
|
137
|
+
): Promise<AminoSignResponse>
|
|
138
|
+
|
|
139
|
+
/** Sign using Direct (protobuf) */
|
|
140
|
+
signDirect(
|
|
141
|
+
chainId: string,
|
|
142
|
+
signer: string,
|
|
143
|
+
signDoc: {
|
|
144
|
+
bodyBytes?: Uint8Array | null
|
|
145
|
+
authInfoBytes?: Uint8Array | null
|
|
146
|
+
chainId?: string | null
|
|
147
|
+
accountNumber?: bigint | null
|
|
148
|
+
},
|
|
149
|
+
signOptions?: KeplrSignOptions
|
|
150
|
+
): Promise<DirectSignResponse>
|
|
151
|
+
|
|
152
|
+
/** Sign arbitrary data */
|
|
153
|
+
signArbitrary(
|
|
154
|
+
chainId: string,
|
|
155
|
+
signer: string,
|
|
156
|
+
data: string | Uint8Array
|
|
157
|
+
): Promise<StdSignature>
|
|
158
|
+
|
|
159
|
+
/** Verify arbitrary data signature */
|
|
160
|
+
verifyArbitrary(
|
|
161
|
+
chainId: string,
|
|
162
|
+
signer: string,
|
|
163
|
+
data: string | Uint8Array,
|
|
164
|
+
signature: StdSignature
|
|
165
|
+
): Promise<boolean>
|
|
166
|
+
|
|
167
|
+
/** Get offline signer for Amino */
|
|
168
|
+
getOfflineSignerAuto(chainId: string): Promise<OfflineSigner>
|
|
169
|
+
|
|
170
|
+
/** Get offline signer only for Amino */
|
|
171
|
+
getOfflineSignerOnlyAmino(chainId: string): Promise<OfflineAminoSigner>
|
|
172
|
+
|
|
173
|
+
/** Get offline direct signer */
|
|
174
|
+
getOfflineSigner(chainId: string): Promise<OfflineSigner>
|
|
175
|
+
|
|
176
|
+
/** Suggest adding a chain */
|
|
177
|
+
experimentalSuggestChain(chainInfo: ChainInfo): Promise<void>
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Key information from Keplr
|
|
182
|
+
*/
|
|
183
|
+
export interface Key {
|
|
184
|
+
/** Account name */
|
|
185
|
+
name: string
|
|
186
|
+
/** Algorithm used */
|
|
187
|
+
algo: CosmosAlgo
|
|
188
|
+
/** Public key bytes */
|
|
189
|
+
pubKey: Uint8Array
|
|
190
|
+
/** Bech32 address */
|
|
191
|
+
address: string
|
|
192
|
+
/** Bech32 prefix */
|
|
193
|
+
bech32Address: string
|
|
194
|
+
/** Whether this is a NanoLedger */
|
|
195
|
+
isNanoLedger?: boolean
|
|
196
|
+
/** Whether this is a keystone */
|
|
197
|
+
isKeystone?: boolean
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Keplr signing options
|
|
202
|
+
*/
|
|
203
|
+
export interface KeplrSignOptions {
|
|
204
|
+
/** Prefer no set fee */
|
|
205
|
+
preferNoSetFee?: boolean
|
|
206
|
+
/** Prefer no set memo */
|
|
207
|
+
preferNoSetMemo?: boolean
|
|
208
|
+
/** Disable balance check */
|
|
209
|
+
disableBalanceCheck?: boolean
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Offline signer interface
|
|
214
|
+
*/
|
|
215
|
+
export interface OfflineSigner {
|
|
216
|
+
getAccounts(): Promise<readonly CosmosAccountData[]>
|
|
217
|
+
signDirect(signerAddress: string, signDoc: DirectSignDoc): Promise<DirectSignResponse>
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Offline Amino signer interface
|
|
222
|
+
*/
|
|
223
|
+
export interface OfflineAminoSigner {
|
|
224
|
+
getAccounts(): Promise<readonly CosmosAccountData[]>
|
|
225
|
+
signAmino(signerAddress: string, signDoc: StdSignDoc): Promise<AminoSignResponse>
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Chain info for suggesting chains to Keplr
|
|
230
|
+
*/
|
|
231
|
+
export interface ChainInfo {
|
|
232
|
+
chainId: string
|
|
233
|
+
chainName: string
|
|
234
|
+
rpc: string
|
|
235
|
+
rest: string
|
|
236
|
+
bip44: {
|
|
237
|
+
coinType: number
|
|
238
|
+
}
|
|
239
|
+
bech32Config: {
|
|
240
|
+
bech32PrefixAccAddr: string
|
|
241
|
+
bech32PrefixAccPub: string
|
|
242
|
+
bech32PrefixValAddr: string
|
|
243
|
+
bech32PrefixValPub: string
|
|
244
|
+
bech32PrefixConsAddr: string
|
|
245
|
+
bech32PrefixConsPub: string
|
|
246
|
+
}
|
|
247
|
+
currencies: Currency[]
|
|
248
|
+
feeCurrencies: Currency[]
|
|
249
|
+
stakeCurrency: Currency
|
|
250
|
+
coinType?: number
|
|
251
|
+
gasPriceStep?: {
|
|
252
|
+
low: number
|
|
253
|
+
average: number
|
|
254
|
+
high: number
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Currency information
|
|
260
|
+
*/
|
|
261
|
+
export interface Currency {
|
|
262
|
+
coinDenom: string
|
|
263
|
+
coinMinimalDenom: string
|
|
264
|
+
coinDecimals: number
|
|
265
|
+
coinGeckoId?: string
|
|
266
|
+
coinImageUrl?: string
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Cosmos wallet name/type
|
|
271
|
+
*/
|
|
272
|
+
export type CosmosWalletName = 'keplr' | 'leap' | 'cosmostation' | 'generic'
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Cosmos chain IDs
|
|
276
|
+
*/
|
|
277
|
+
export const CosmosChainId = {
|
|
278
|
+
COSMOSHUB: 'cosmoshub-4',
|
|
279
|
+
OSMOSIS: 'osmosis-1',
|
|
280
|
+
JUNO: 'juno-1',
|
|
281
|
+
STARGAZE: 'stargaze-1',
|
|
282
|
+
AKASH: 'akashnet-2',
|
|
283
|
+
// Testnets
|
|
284
|
+
COSMOSHUB_TESTNET: 'theta-testnet-001',
|
|
285
|
+
OSMOSIS_TESTNET: 'osmo-test-5',
|
|
286
|
+
} as const
|
|
287
|
+
|
|
288
|
+
export type CosmosChainIdType = typeof CosmosChainId[keyof typeof CosmosChainId]
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Cosmos adapter configuration
|
|
292
|
+
*/
|
|
293
|
+
export interface CosmosAdapterConfig {
|
|
294
|
+
/** Wallet to connect to */
|
|
295
|
+
wallet?: CosmosWalletName
|
|
296
|
+
/** Chain ID to connect to */
|
|
297
|
+
chainId?: string
|
|
298
|
+
/** RPC endpoint URL */
|
|
299
|
+
rpcEndpoint?: string
|
|
300
|
+
/** REST endpoint URL */
|
|
301
|
+
restEndpoint?: string
|
|
302
|
+
/** Custom Keplr provider (for testing) */
|
|
303
|
+
provider?: Keplr
|
|
304
|
+
/** Bech32 address prefix (default: 'cosmos') */
|
|
305
|
+
bech32Prefix?: string
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Cosmos-specific unsigned transaction
|
|
310
|
+
*/
|
|
311
|
+
export interface CosmosUnsignedTransaction {
|
|
312
|
+
/** Sign doc for Amino signing */
|
|
313
|
+
aminoSignDoc?: StdSignDoc
|
|
314
|
+
/** Sign doc for Direct signing */
|
|
315
|
+
directSignDoc?: DirectSignDoc
|
|
316
|
+
/** Preferred signing method */
|
|
317
|
+
signMethod?: 'amino' | 'direct'
|
|
318
|
+
/** Chain ID */
|
|
319
|
+
chainId: string
|
|
320
|
+
/** Signer address */
|
|
321
|
+
signerAddress?: string
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Extended signature with Cosmos-specific data
|
|
326
|
+
*/
|
|
327
|
+
export interface CosmosSignature {
|
|
328
|
+
/** Raw signature bytes as hex */
|
|
329
|
+
signature: HexString
|
|
330
|
+
/** Public key as hex */
|
|
331
|
+
publicKey: HexString
|
|
332
|
+
/** Base64 encoded signature (Cosmos standard) */
|
|
333
|
+
base64Signature?: string
|
|
334
|
+
/** Standard signature structure */
|
|
335
|
+
stdSignature?: StdSignature
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Get the injected Cosmos wallet provider
|
|
340
|
+
*/
|
|
341
|
+
export function getCosmosProvider(wallet: CosmosWalletName = 'keplr'): Keplr | undefined {
|
|
342
|
+
if (typeof window === 'undefined') return undefined
|
|
343
|
+
|
|
344
|
+
const win = window as unknown as {
|
|
345
|
+
keplr?: Keplr
|
|
346
|
+
leap?: Keplr
|
|
347
|
+
cosmostation?: { providers?: { keplr?: Keplr } }
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
switch (wallet) {
|
|
351
|
+
case 'keplr':
|
|
352
|
+
return win.keplr
|
|
353
|
+
case 'leap':
|
|
354
|
+
return win.leap
|
|
355
|
+
case 'cosmostation':
|
|
356
|
+
return win.cosmostation?.providers?.keplr
|
|
357
|
+
case 'generic':
|
|
358
|
+
default:
|
|
359
|
+
// Try to find any available provider
|
|
360
|
+
return win.keplr ?? win.leap ?? win.cosmostation?.providers?.keplr
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Detect which Cosmos wallets are installed
|
|
366
|
+
*/
|
|
367
|
+
export function detectCosmosWallets(): CosmosWalletName[] {
|
|
368
|
+
if (typeof window === 'undefined') return []
|
|
369
|
+
|
|
370
|
+
const detected: CosmosWalletName[] = []
|
|
371
|
+
const win = window as unknown as {
|
|
372
|
+
keplr?: Keplr
|
|
373
|
+
leap?: Keplr
|
|
374
|
+
cosmostation?: { providers?: { keplr?: Keplr } }
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (win.keplr) detected.push('keplr')
|
|
378
|
+
if (win.leap) detected.push('leap')
|
|
379
|
+
if (win.cosmostation?.providers?.keplr) detected.push('cosmostation')
|
|
380
|
+
|
|
381
|
+
return detected
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Convert Cosmos public key bytes to hex string
|
|
386
|
+
*/
|
|
387
|
+
export function cosmosPublicKeyToHex(pubkey: Uint8Array): HexString {
|
|
388
|
+
return ('0x' + Buffer.from(pubkey).toString('hex')) as HexString
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Convert bech32 address to hex
|
|
393
|
+
*/
|
|
394
|
+
export function bech32ToHex(bech32Address: string): HexString {
|
|
395
|
+
// Simple bech32 decoding
|
|
396
|
+
const CHARSET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l'
|
|
397
|
+
const GENERATOR = [0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3]
|
|
398
|
+
|
|
399
|
+
const decoded = bech32Address.toLowerCase()
|
|
400
|
+
const pos = decoded.lastIndexOf('1')
|
|
401
|
+
if (pos < 1) throw new Error('Invalid bech32 address')
|
|
402
|
+
|
|
403
|
+
const data = decoded.slice(pos + 1)
|
|
404
|
+
const values: number[] = []
|
|
405
|
+
|
|
406
|
+
for (const char of data) {
|
|
407
|
+
const value = CHARSET.indexOf(char)
|
|
408
|
+
if (value === -1) throw new Error(`Invalid bech32 character: ${char}`)
|
|
409
|
+
values.push(value)
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// Convert from 5-bit to 8-bit
|
|
413
|
+
const bytes: number[] = []
|
|
414
|
+
let buffer = 0
|
|
415
|
+
let bits = 0
|
|
416
|
+
|
|
417
|
+
for (const value of values.slice(0, -6)) {
|
|
418
|
+
buffer = (buffer << 5) | value
|
|
419
|
+
bits += 5
|
|
420
|
+
if (bits >= 8) {
|
|
421
|
+
bits -= 8
|
|
422
|
+
bytes.push((buffer >> bits) & 0xff)
|
|
423
|
+
buffer &= (1 << bits) - 1
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return ('0x' + Buffer.from(bytes).toString('hex')) as HexString
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Get default RPC endpoint for Cosmos chains
|
|
432
|
+
*/
|
|
433
|
+
export function getDefaultRpcEndpoint(chainId: string): string {
|
|
434
|
+
const endpoints: Record<string, string> = {
|
|
435
|
+
[CosmosChainId.COSMOSHUB]: 'https://rpc.cosmos.network',
|
|
436
|
+
[CosmosChainId.OSMOSIS]: 'https://rpc.osmosis.zone',
|
|
437
|
+
[CosmosChainId.JUNO]: 'https://rpc.juno.strange.love',
|
|
438
|
+
[CosmosChainId.STARGAZE]: 'https://rpc.stargaze-apis.com',
|
|
439
|
+
[CosmosChainId.AKASH]: 'https://rpc.akash.forbole.com',
|
|
440
|
+
[CosmosChainId.COSMOSHUB_TESTNET]: 'https://rpc.sentry-01.theta-testnet.polypore.xyz',
|
|
441
|
+
[CosmosChainId.OSMOSIS_TESTNET]: 'https://rpc.testnet.osmosis.zone',
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
return endpoints[chainId] ?? 'https://rpc.cosmos.network'
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Get default REST endpoint for Cosmos chains
|
|
449
|
+
*/
|
|
450
|
+
export function getDefaultRestEndpoint(chainId: string): string {
|
|
451
|
+
const endpoints: Record<string, string> = {
|
|
452
|
+
[CosmosChainId.COSMOSHUB]: 'https://api.cosmos.network',
|
|
453
|
+
[CosmosChainId.OSMOSIS]: 'https://lcd.osmosis.zone',
|
|
454
|
+
[CosmosChainId.JUNO]: 'https://api.juno.strange.love',
|
|
455
|
+
[CosmosChainId.STARGAZE]: 'https://rest.stargaze-apis.com',
|
|
456
|
+
[CosmosChainId.AKASH]: 'https://api.akash.forbole.com',
|
|
457
|
+
[CosmosChainId.COSMOSHUB_TESTNET]: 'https://rest.sentry-01.theta-testnet.polypore.xyz',
|
|
458
|
+
[CosmosChainId.OSMOSIS_TESTNET]: 'https://lcd.testnet.osmosis.zone',
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
return endpoints[chainId] ?? 'https://api.cosmos.network'
|
|
462
|
+
}
|
package/src/wallet/index.ts
CHANGED
|
@@ -84,6 +84,133 @@ export type {
|
|
|
84
84
|
MockEthereumAdapterConfig,
|
|
85
85
|
} from './ethereum'
|
|
86
86
|
|
|
87
|
+
// Cosmos adapter
|
|
88
|
+
export {
|
|
89
|
+
CosmosWalletAdapter,
|
|
90
|
+
createCosmosAdapter,
|
|
91
|
+
MockCosmosAdapter,
|
|
92
|
+
createMockCosmosAdapter,
|
|
93
|
+
createMockCosmosProvider,
|
|
94
|
+
getCosmosProvider,
|
|
95
|
+
detectCosmosWallets,
|
|
96
|
+
cosmosPublicKeyToHex,
|
|
97
|
+
bech32ToHex,
|
|
98
|
+
getDefaultRpcEndpoint as getCosmosDefaultRpcEndpoint,
|
|
99
|
+
getDefaultRestEndpoint,
|
|
100
|
+
CosmosChainId,
|
|
101
|
+
} from './cosmos'
|
|
102
|
+
|
|
103
|
+
export type {
|
|
104
|
+
CosmosAccountData,
|
|
105
|
+
CosmosAlgo,
|
|
106
|
+
Key,
|
|
107
|
+
PubKey,
|
|
108
|
+
StdSignDoc,
|
|
109
|
+
StdFee,
|
|
110
|
+
Coin,
|
|
111
|
+
CosmosMsg,
|
|
112
|
+
AminoSignResponse,
|
|
113
|
+
StdSignature,
|
|
114
|
+
DirectSignDoc,
|
|
115
|
+
DirectSignResponse,
|
|
116
|
+
Keplr,
|
|
117
|
+
KeplrSignOptions,
|
|
118
|
+
OfflineSigner,
|
|
119
|
+
OfflineAminoSigner,
|
|
120
|
+
ChainInfo,
|
|
121
|
+
Currency,
|
|
122
|
+
CosmosWalletName,
|
|
123
|
+
CosmosChainIdType,
|
|
124
|
+
CosmosAdapterConfig,
|
|
125
|
+
CosmosUnsignedTransaction,
|
|
126
|
+
CosmosSignature,
|
|
127
|
+
MockCosmosAdapterConfig,
|
|
128
|
+
} from './cosmos'
|
|
129
|
+
|
|
130
|
+
// Bitcoin adapter
|
|
131
|
+
export {
|
|
132
|
+
BitcoinWalletAdapter,
|
|
133
|
+
createBitcoinAdapter,
|
|
134
|
+
MockBitcoinAdapter,
|
|
135
|
+
createMockBitcoinAdapter,
|
|
136
|
+
createMockBitcoinProvider,
|
|
137
|
+
getBitcoinProvider,
|
|
138
|
+
detectBitcoinWallets,
|
|
139
|
+
bitcoinAddressToHex,
|
|
140
|
+
bitcoinPublicKeyToHex,
|
|
141
|
+
isValidTaprootAddress,
|
|
142
|
+
} from './bitcoin'
|
|
143
|
+
|
|
144
|
+
export type {
|
|
145
|
+
BitcoinAddressType,
|
|
146
|
+
BitcoinNetwork,
|
|
147
|
+
BitcoinAddress,
|
|
148
|
+
BitcoinBalance,
|
|
149
|
+
SignPsbtOptions,
|
|
150
|
+
ToSignInput,
|
|
151
|
+
BitcoinWalletName,
|
|
152
|
+
BitcoinAdapterConfig,
|
|
153
|
+
UnisatAPI,
|
|
154
|
+
MockBitcoinAdapterConfig,
|
|
155
|
+
} from './bitcoin'
|
|
156
|
+
|
|
157
|
+
// Aptos adapter
|
|
158
|
+
export {
|
|
159
|
+
AptosWalletAdapter,
|
|
160
|
+
createAptosAdapter,
|
|
161
|
+
MockAptosAdapter,
|
|
162
|
+
createMockAptosAdapter,
|
|
163
|
+
createMockAptosProvider,
|
|
164
|
+
getAptosProvider,
|
|
165
|
+
aptosPublicKeyToHex,
|
|
166
|
+
getDefaultAptosRpcEndpoint,
|
|
167
|
+
DEFAULT_APTOS_RPC_ENDPOINTS,
|
|
168
|
+
} from './aptos'
|
|
169
|
+
|
|
170
|
+
export type {
|
|
171
|
+
AptosWalletName,
|
|
172
|
+
AptosNetwork,
|
|
173
|
+
AptosAccountInfo,
|
|
174
|
+
AptosTransactionPayload,
|
|
175
|
+
AptosTransactionOptions,
|
|
176
|
+
AptosTransaction,
|
|
177
|
+
SignedAptosTransaction,
|
|
178
|
+
AptosSignMessagePayload,
|
|
179
|
+
AptosSignMessageResponse,
|
|
180
|
+
PetraAPI,
|
|
181
|
+
MartianAPI,
|
|
182
|
+
AptosWalletProvider,
|
|
183
|
+
AptosAdapterConfig,
|
|
184
|
+
MockAptosAdapterConfig,
|
|
185
|
+
} from './aptos'
|
|
186
|
+
|
|
187
|
+
// Sui adapter
|
|
188
|
+
export {
|
|
189
|
+
SuiWalletAdapter,
|
|
190
|
+
createSuiAdapter,
|
|
191
|
+
MockSuiAdapter,
|
|
192
|
+
createMockSuiAdapter,
|
|
193
|
+
createMockSuiProvider,
|
|
194
|
+
getSuiProvider,
|
|
195
|
+
suiPublicKeyToHex,
|
|
196
|
+
getDefaultSuiRpcEndpoint,
|
|
197
|
+
DEFAULT_SUI_RPC_ENDPOINTS,
|
|
198
|
+
} from './sui'
|
|
199
|
+
|
|
200
|
+
export type {
|
|
201
|
+
SuiWalletName,
|
|
202
|
+
SuiAccountInfo,
|
|
203
|
+
SuiTransactionBlock,
|
|
204
|
+
SignedSuiTransaction,
|
|
205
|
+
SuiSignMessageInput,
|
|
206
|
+
SuiSignMessageResponse,
|
|
207
|
+
SuiWalletAPI,
|
|
208
|
+
EthosAPI,
|
|
209
|
+
SuiWalletProvider,
|
|
210
|
+
SuiAdapterConfig,
|
|
211
|
+
MockSuiAdapterConfig,
|
|
212
|
+
} from './sui'
|
|
213
|
+
|
|
87
214
|
// Hardware wallet adapters
|
|
88
215
|
export {
|
|
89
216
|
// Types
|