@alien_org/contract 1.0.0-alpha → 1.0.0-alpha.3
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 +34 -14
- package/dist/index.cjs +17 -4
- package/dist/index.d.cts +43 -26
- package/dist/index.d.mts +43 -26
- package/dist/index.mjs +17 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@ import type {
|
|
|
33
33
|
// Launch parameters
|
|
34
34
|
LaunchParams, // Host-injected params (authToken, contractVersion, etc.)
|
|
35
35
|
Platform, // 'ios' | 'android'
|
|
36
|
+
DisplayMode, // 'standard' | 'fullscreen' | 'immersive'
|
|
36
37
|
|
|
37
38
|
// Utilities
|
|
38
39
|
Version, // Semantic version string type
|
|
@@ -42,10 +43,11 @@ import type {
|
|
|
42
43
|
### Constants
|
|
43
44
|
|
|
44
45
|
```typescript
|
|
45
|
-
import { PLATFORMS, releases } from '@alien_org/contract';
|
|
46
|
+
import { DISPLAY_MODES, PLATFORMS, releases } from '@alien_org/contract';
|
|
46
47
|
|
|
47
|
-
PLATFORMS
|
|
48
|
-
|
|
48
|
+
PLATFORMS // ['ios', 'android']
|
|
49
|
+
DISPLAY_MODES // ['standard', 'fullscreen', 'immersive']
|
|
50
|
+
releases // Record<Version, MethodName[]> - version to methods mapping
|
|
49
51
|
```
|
|
50
52
|
|
|
51
53
|
### Version Utilities
|
|
@@ -63,7 +65,7 @@ isMethodSupported('payment:request', '0.0.9'); // false
|
|
|
63
65
|
|
|
64
66
|
// Get minimum version that supports a method
|
|
65
67
|
getMethodMinVersion('app:ready'); // '0.0.9'
|
|
66
|
-
getMethodMinVersion('payment:request'); // '0.
|
|
68
|
+
getMethodMinVersion('payment:request'); // '0.1.1'
|
|
67
69
|
|
|
68
70
|
// Get version where a method was introduced
|
|
69
71
|
getReleaseVersion('app:ready'); // '0.0.9'
|
|
@@ -74,17 +76,33 @@ getReleaseVersion('app:ready'); // '0.0.9'
|
|
|
74
76
|
| Method | Since | Description |
|
|
75
77
|
|--------|-------|-------------|
|
|
76
78
|
| `app:ready` | 0.0.9 | Notify host that miniapp is ready |
|
|
77
|
-
| `
|
|
78
|
-
| `
|
|
79
|
-
| `
|
|
79
|
+
| `payment:request` | 0.1.1 | Request payment |
|
|
80
|
+
| `clipboard:write` | 0.1.1 | Write text to clipboard |
|
|
81
|
+
| `clipboard:read` | 0.1.1 | Read text from clipboard |
|
|
82
|
+
| `link:open` | 0.1.3 | Open a URL |
|
|
83
|
+
| `haptic:impact` | 0.2.4 | Trigger haptic impact feedback |
|
|
84
|
+
| `haptic:notification` | 0.2.4 | Trigger haptic notification feedback |
|
|
85
|
+
| `haptic:selection` | 0.2.4 | Trigger haptic selection feedback |
|
|
86
|
+
| `wallet.solana:connect` | 1.0.0 | Request Solana wallet connection |
|
|
87
|
+
| `wallet.solana:disconnect` | 1.0.0 | Disconnect from Solana wallet |
|
|
88
|
+
| `wallet.solana:sign.transaction` | 1.0.0 | Sign a Solana transaction |
|
|
89
|
+
| `wallet.solana:sign.message` | 1.0.0 | Sign a Solana message |
|
|
90
|
+
| `wallet.solana:sign.send` | 1.0.0 | Sign and send a Solana transaction |
|
|
91
|
+
| `app:close` | 1.0.0 | Request host to close the miniapp |
|
|
92
|
+
| `host.back.button:toggle` | 1.0.0 | Show/hide back button |
|
|
80
93
|
|
|
81
94
|
## Available Events
|
|
82
95
|
|
|
83
96
|
| Event | Since | Description |
|
|
84
97
|
|-------|-------|-------------|
|
|
85
98
|
| `miniapp:close` | 0.0.14 | Host is closing miniapp |
|
|
86
|
-
| `host.back.button:clicked` | 0.0
|
|
87
|
-
| `payment:response` | 0.
|
|
99
|
+
| `host.back.button:clicked` | 1.0.0 | Back button was clicked |
|
|
100
|
+
| `payment:response` | 0.1.1 | Payment result |
|
|
101
|
+
| `clipboard:response` | 0.1.1 | Clipboard read result |
|
|
102
|
+
| `wallet.solana:connect.response` | 1.0.0 | Wallet connection result |
|
|
103
|
+
| `wallet.solana:sign.transaction.response` | 1.0.0 | Transaction signing result |
|
|
104
|
+
| `wallet.solana:sign.message.response` | 1.0.0 | Message signing result |
|
|
105
|
+
| `wallet.solana:sign.send.response` | 1.0.0 | Sign and send result |
|
|
88
106
|
|
|
89
107
|
## LaunchParams
|
|
90
108
|
|
|
@@ -92,11 +110,13 @@ Parameters injected by the host app:
|
|
|
92
110
|
|
|
93
111
|
```typescript
|
|
94
112
|
interface LaunchParams {
|
|
95
|
-
authToken: string | undefined;
|
|
96
|
-
contractVersion: Version | undefined;
|
|
97
|
-
hostAppVersion: string | undefined;
|
|
98
|
-
platform: Platform | undefined;
|
|
99
|
-
|
|
113
|
+
authToken: string | undefined; // JWT auth token
|
|
114
|
+
contractVersion: Version | undefined; // Host's contract version
|
|
115
|
+
hostAppVersion: string | undefined; // Host app version
|
|
116
|
+
platform: Platform | undefined; // 'ios' | 'android'
|
|
117
|
+
safeAreaInsets: SafeAreaInsets | undefined; // System UI insets (CSS px)
|
|
118
|
+
startParam: string | undefined; // Custom param (referrals, etc.)
|
|
119
|
+
displayMode: DisplayMode; // 'standard' | 'fullscreen' | 'immersive'
|
|
100
120
|
}
|
|
101
121
|
```
|
|
102
122
|
|
package/dist/index.cjs
CHANGED
|
@@ -4,12 +4,22 @@
|
|
|
4
4
|
* Supported platforms for miniapps.
|
|
5
5
|
*/
|
|
6
6
|
const PLATFORMS = ["ios", "android"];
|
|
7
|
+
/**
|
|
8
|
+
* Supported display modes for miniapps.
|
|
9
|
+
* - `standard` — standard webview with native chrome
|
|
10
|
+
* - `fullscreen` — fullscreen webview, native controls still visible
|
|
11
|
+
* - `immersive` — no native UI elements at all (no close button, options, etc.)
|
|
12
|
+
*/
|
|
13
|
+
const DISPLAY_MODES = [
|
|
14
|
+
"standard",
|
|
15
|
+
"fullscreen",
|
|
16
|
+
"immersive"
|
|
17
|
+
];
|
|
7
18
|
|
|
8
19
|
//#endregion
|
|
9
20
|
//#region src/methods/versions/releases.ts
|
|
10
21
|
const releases = {
|
|
11
22
|
"0.0.9": ["app:ready"],
|
|
12
|
-
"0.0.14": ["miniapp:close.ack", "host.back.button:toggle"],
|
|
13
23
|
"0.1.1": [
|
|
14
24
|
"payment:request",
|
|
15
25
|
"clipboard:write",
|
|
@@ -21,12 +31,14 @@ const releases = {
|
|
|
21
31
|
"haptic:notification",
|
|
22
32
|
"haptic:selection"
|
|
23
33
|
],
|
|
24
|
-
"0.
|
|
34
|
+
"1.0.0": [
|
|
25
35
|
"wallet.solana:connect",
|
|
26
36
|
"wallet.solana:disconnect",
|
|
27
37
|
"wallet.solana:sign.transaction",
|
|
28
38
|
"wallet.solana:sign.message",
|
|
29
|
-
"wallet.solana:sign.send"
|
|
39
|
+
"wallet.solana:sign.send",
|
|
40
|
+
"app:close",
|
|
41
|
+
"host.back.button:toggle"
|
|
30
42
|
]
|
|
31
43
|
};
|
|
32
44
|
|
|
@@ -104,7 +116,7 @@ function getMethodMinVersion(method) {
|
|
|
104
116
|
* }
|
|
105
117
|
* ```
|
|
106
118
|
*
|
|
107
|
-
* @since 0.
|
|
119
|
+
* @since 1.0.0
|
|
108
120
|
*/
|
|
109
121
|
const WALLET_ERROR = {
|
|
110
122
|
USER_REJECTED: 5e3,
|
|
@@ -114,6 +126,7 @@ const WALLET_ERROR = {
|
|
|
114
126
|
};
|
|
115
127
|
|
|
116
128
|
//#endregion
|
|
129
|
+
exports.DISPLAY_MODES = DISPLAY_MODES;
|
|
117
130
|
exports.PLATFORMS = PLATFORMS;
|
|
118
131
|
exports.WALLET_ERROR = WALLET_ERROR;
|
|
119
132
|
exports.getMethodMinVersion = getMethodMinVersion;
|
package/dist/index.d.cts
CHANGED
|
@@ -116,7 +116,7 @@ type HapticNotificationType = 'success' | 'warning' | 'error';
|
|
|
116
116
|
* | `-32603` | Internal error (send failed, unexpected error) | JSON-RPC standard |
|
|
117
117
|
* | `8000` | Request expired / timed out | `sessionRequestExpired` |
|
|
118
118
|
*
|
|
119
|
-
* @since 0.
|
|
119
|
+
* @since 1.0.0
|
|
120
120
|
* @schema
|
|
121
121
|
*/
|
|
122
122
|
type WalletSolanaErrorCode = 5000 | -32602 | -32603 | 8000;
|
|
@@ -132,7 +132,7 @@ type WalletSolanaErrorCode = 5000 | -32602 | -32603 | 8000;
|
|
|
132
132
|
* }
|
|
133
133
|
* ```
|
|
134
134
|
*
|
|
135
|
-
* @since 0.
|
|
135
|
+
* @since 1.0.0
|
|
136
136
|
*/
|
|
137
137
|
declare const WALLET_ERROR: {
|
|
138
138
|
/** User rejected the request (cancelled approval screen). */
|
|
@@ -146,7 +146,7 @@ declare const WALLET_ERROR: {
|
|
|
146
146
|
};
|
|
147
147
|
/**
|
|
148
148
|
* Solana commitment levels for send options.
|
|
149
|
-
* @since 0.
|
|
149
|
+
* @since 1.0.0
|
|
150
150
|
* @schema
|
|
151
151
|
*/
|
|
152
152
|
type SolanaCommitment = 'processed' | 'confirmed' | 'finalized';
|
|
@@ -154,7 +154,7 @@ type SolanaCommitment = 'processed' | 'confirmed' | 'finalized';
|
|
|
154
154
|
* Solana chain identifiers (wallet-standard format).
|
|
155
155
|
* Used by `wallet.solana:sign.send` to tell the host app
|
|
156
156
|
* which cluster to broadcast to.
|
|
157
|
-
* @since 0.
|
|
157
|
+
* @since 1.0.0
|
|
158
158
|
* @schema
|
|
159
159
|
*/
|
|
160
160
|
type SolanaChain = 'solana:mainnet' | 'solana:devnet' | 'solana:testnet';
|
|
@@ -182,7 +182,7 @@ interface Events {
|
|
|
182
182
|
'miniapp:close': CreateEventPayload<Empty>;
|
|
183
183
|
/**
|
|
184
184
|
* Host app's back button clicked event.
|
|
185
|
-
* @since 0.0
|
|
185
|
+
* @since 1.0.0
|
|
186
186
|
* @schema
|
|
187
187
|
*/
|
|
188
188
|
'host.back.button:clicked': CreateEventPayload<Empty>;
|
|
@@ -253,7 +253,7 @@ interface Events {
|
|
|
253
253
|
}>>;
|
|
254
254
|
/**
|
|
255
255
|
* Solana wallet connection response.
|
|
256
|
-
* @since 0.
|
|
256
|
+
* @since 1.0.0
|
|
257
257
|
* @schema
|
|
258
258
|
*/
|
|
259
259
|
'wallet.solana:connect.response': CreateEventPayload<WithReqId<{
|
|
@@ -266,7 +266,7 @@ interface Events {
|
|
|
266
266
|
}>>;
|
|
267
267
|
/**
|
|
268
268
|
* Solana transaction signing response.
|
|
269
|
-
* @since 0.
|
|
269
|
+
* @since 1.0.0
|
|
270
270
|
* @schema
|
|
271
271
|
*/
|
|
272
272
|
'wallet.solana:sign.transaction.response': CreateEventPayload<WithReqId<{
|
|
@@ -279,7 +279,7 @@ interface Events {
|
|
|
279
279
|
}>>;
|
|
280
280
|
/**
|
|
281
281
|
* Solana message signing response.
|
|
282
|
-
* @since 0.
|
|
282
|
+
* @since 1.0.0
|
|
283
283
|
* @schema
|
|
284
284
|
*/
|
|
285
285
|
'wallet.solana:sign.message.response': CreateEventPayload<WithReqId<{
|
|
@@ -294,7 +294,7 @@ interface Events {
|
|
|
294
294
|
}>>;
|
|
295
295
|
/**
|
|
296
296
|
* Solana sign-and-send transaction response.
|
|
297
|
-
* @since 0.
|
|
297
|
+
* @since 1.0.0
|
|
298
298
|
* @schema
|
|
299
299
|
*/
|
|
300
300
|
'wallet.solana:sign.send.response': CreateEventPayload<WithReqId<{
|
|
@@ -320,6 +320,17 @@ declare const PLATFORMS: readonly ["ios", "android"];
|
|
|
320
320
|
* Platform the miniapp is running on.
|
|
321
321
|
*/
|
|
322
322
|
type Platform = (typeof PLATFORMS)[number];
|
|
323
|
+
/**
|
|
324
|
+
* Supported display modes for miniapps.
|
|
325
|
+
* - `standard` — standard webview with native chrome
|
|
326
|
+
* - `fullscreen` — fullscreen webview, native controls still visible
|
|
327
|
+
* - `immersive` — no native UI elements at all (no close button, options, etc.)
|
|
328
|
+
*/
|
|
329
|
+
declare const DISPLAY_MODES: readonly ["standard", "fullscreen", "immersive"];
|
|
330
|
+
/**
|
|
331
|
+
* Display mode for the miniapp webview.
|
|
332
|
+
*/
|
|
333
|
+
type DisplayMode = (typeof DISPLAY_MODES)[number];
|
|
323
334
|
/**
|
|
324
335
|
* Safe area insets in CSS pixels, injected by the host app.
|
|
325
336
|
* Accounts for system UI (status bar, notch, home indicator, nav bar).
|
|
@@ -349,6 +360,12 @@ interface LaunchParams {
|
|
|
349
360
|
* Used for referral codes, campaign tracking, or custom routing.
|
|
350
361
|
*/
|
|
351
362
|
startParam: string | undefined;
|
|
363
|
+
/**
|
|
364
|
+
* Display mode for the miniapp webview.
|
|
365
|
+
* Defaults to `'standard'` when not provided by the host app.
|
|
366
|
+
* @since 1.0.0
|
|
367
|
+
*/
|
|
368
|
+
displayMode: DisplayMode;
|
|
352
369
|
}
|
|
353
370
|
//#endregion
|
|
354
371
|
//#region src/methods/types/payload.d.ts
|
|
@@ -369,27 +386,27 @@ interface Methods {
|
|
|
369
386
|
/**
|
|
370
387
|
* Miniapp ready method.
|
|
371
388
|
* Sent by the miniapp to notify the host app that it has loaded and is ready to be displayed.
|
|
372
|
-
* @since 0.0.
|
|
389
|
+
* @since 0.0.9
|
|
373
390
|
* @schema
|
|
374
391
|
*/
|
|
375
392
|
'app:ready': CreateMethodPayload<Empty>;
|
|
376
393
|
/**
|
|
377
|
-
*
|
|
378
|
-
* Sent by the miniapp to
|
|
379
|
-
*
|
|
380
|
-
* @since 0.0
|
|
394
|
+
* Close the miniapp.
|
|
395
|
+
* Sent by the miniapp to request the host app to close it.
|
|
396
|
+
* Fire-and-forget — no response expected.
|
|
397
|
+
* @since 1.0.0
|
|
381
398
|
* @schema
|
|
382
399
|
*/
|
|
383
|
-
'
|
|
400
|
+
'app:close': CreateMethodPayload<Empty>;
|
|
384
401
|
/**
|
|
385
402
|
* Toggle host app's back button visibility.
|
|
386
|
-
* @since 0.0
|
|
403
|
+
* @since 1.0.0
|
|
387
404
|
* @schema
|
|
388
405
|
*/
|
|
389
406
|
'host.back.button:toggle': CreateMethodPayload<{
|
|
390
407
|
/**
|
|
391
408
|
* Whether to show or hide the back button.
|
|
392
|
-
* @since 0.0
|
|
409
|
+
* @since 1.0.0
|
|
393
410
|
* @schema
|
|
394
411
|
*/
|
|
395
412
|
visible: boolean;
|
|
@@ -401,8 +418,8 @@ interface Methods {
|
|
|
401
418
|
* Your backend receives a webhook when user pays - fulfill the order
|
|
402
419
|
* immediately without waiting for chain confirmation.
|
|
403
420
|
*
|
|
404
|
-
* Optional
|
|
405
|
-
*
|
|
421
|
+
* Optional `item` object (`title`, `iconUrl`, `quantity`)
|
|
422
|
+
* is shown on the payment approval screen.
|
|
406
423
|
*
|
|
407
424
|
* Set `test` to a scenario string (e.g. `'paid'`, `'error:insufficient_balance'`)
|
|
408
425
|
* for test mode - no real payment is made, but the specified scenario is
|
|
@@ -594,21 +611,21 @@ interface Methods {
|
|
|
594
611
|
/**
|
|
595
612
|
* Request Solana wallet connection.
|
|
596
613
|
* Returns the wallet's public key on success.
|
|
597
|
-
* @since 0.
|
|
614
|
+
* @since 1.0.0
|
|
598
615
|
* @schema
|
|
599
616
|
*/
|
|
600
617
|
'wallet.solana:connect': CreateMethodPayload<WithReqId<Empty>>;
|
|
601
618
|
/**
|
|
602
619
|
* Disconnect from Solana wallet.
|
|
603
620
|
* Fire-and-forget — no response expected.
|
|
604
|
-
* @since 0.
|
|
621
|
+
* @since 1.0.0
|
|
605
622
|
* @schema
|
|
606
623
|
*/
|
|
607
624
|
'wallet.solana:disconnect': CreateMethodPayload<Empty>;
|
|
608
625
|
/**
|
|
609
626
|
* Request Solana transaction signing.
|
|
610
627
|
* Returns the signed transaction bytes.
|
|
611
|
-
* @since 0.
|
|
628
|
+
* @since 1.0.0
|
|
612
629
|
* @schema
|
|
613
630
|
*/
|
|
614
631
|
'wallet.solana:sign.transaction': CreateMethodPayload<WithReqId<{
|
|
@@ -618,7 +635,7 @@ interface Methods {
|
|
|
618
635
|
/**
|
|
619
636
|
* Request Solana message signing.
|
|
620
637
|
* Returns the Ed25519 signature.
|
|
621
|
-
* @since 0.
|
|
638
|
+
* @since 1.0.0
|
|
622
639
|
* @schema
|
|
623
640
|
*/
|
|
624
641
|
'wallet.solana:sign.message': CreateMethodPayload<WithReqId<{
|
|
@@ -629,7 +646,7 @@ interface Methods {
|
|
|
629
646
|
* Request Solana transaction signing and sending.
|
|
630
647
|
* The host app signs and broadcasts the transaction.
|
|
631
648
|
* Returns the transaction signature.
|
|
632
|
-
* @since 0.
|
|
649
|
+
* @since 1.0.0
|
|
633
650
|
* @schema
|
|
634
651
|
*/
|
|
635
652
|
'wallet.solana:sign.send': CreateMethodPayload<WithReqId<{
|
|
@@ -640,7 +657,7 @@ interface Methods {
|
|
|
640
657
|
* In bridge mode the host app can infer this from miniapp config,
|
|
641
658
|
* but in relay mode (QR/WebSocket) this is required so the host
|
|
642
659
|
* app knows which RPC to broadcast to.
|
|
643
|
-
* @since 0.
|
|
660
|
+
* @since 1.0.0
|
|
644
661
|
* @schema
|
|
645
662
|
*/
|
|
646
663
|
chain?: SolanaChain;
|
|
@@ -712,4 +729,4 @@ declare function isMethodSupported(method: MethodName, version: Version): boolea
|
|
|
712
729
|
*/
|
|
713
730
|
declare function getMethodMinVersion(method: MethodName): Version | undefined;
|
|
714
731
|
//#endregion
|
|
715
|
-
export { type CreateEventPayload, type CreateMethodPayload, type EventName, type EventPayload, type Events, type HapticImpactStyle, type HapticNotificationType, type LaunchParams, type MethodName, type MethodNameWithVersionedPayload, type MethodPayload, type MethodVersionedPayload, type Methods, PLATFORMS, type PaymentErrorCode, type PaymentTestScenario, type PaymentWebhookStatus, type Platform, type SafeAreaInsets, type SolanaChain, type SolanaCommitment, type Version, WALLET_ERROR, type WalletSolanaErrorCode, getMethodMinVersion, getReleaseVersion, isMethodSupported, releases };
|
|
732
|
+
export { type CreateEventPayload, type CreateMethodPayload, DISPLAY_MODES, type DisplayMode, type EventName, type EventPayload, type Events, type HapticImpactStyle, type HapticNotificationType, type LaunchParams, type MethodName, type MethodNameWithVersionedPayload, type MethodPayload, type MethodVersionedPayload, type Methods, PLATFORMS, type PaymentErrorCode, type PaymentTestScenario, type PaymentWebhookStatus, type Platform, type SafeAreaInsets, type SolanaChain, type SolanaCommitment, type Version, WALLET_ERROR, type WalletSolanaErrorCode, getMethodMinVersion, getReleaseVersion, isMethodSupported, releases };
|
package/dist/index.d.mts
CHANGED
|
@@ -116,7 +116,7 @@ type HapticNotificationType = 'success' | 'warning' | 'error';
|
|
|
116
116
|
* | `-32603` | Internal error (send failed, unexpected error) | JSON-RPC standard |
|
|
117
117
|
* | `8000` | Request expired / timed out | `sessionRequestExpired` |
|
|
118
118
|
*
|
|
119
|
-
* @since 0.
|
|
119
|
+
* @since 1.0.0
|
|
120
120
|
* @schema
|
|
121
121
|
*/
|
|
122
122
|
type WalletSolanaErrorCode = 5000 | -32602 | -32603 | 8000;
|
|
@@ -132,7 +132,7 @@ type WalletSolanaErrorCode = 5000 | -32602 | -32603 | 8000;
|
|
|
132
132
|
* }
|
|
133
133
|
* ```
|
|
134
134
|
*
|
|
135
|
-
* @since 0.
|
|
135
|
+
* @since 1.0.0
|
|
136
136
|
*/
|
|
137
137
|
declare const WALLET_ERROR: {
|
|
138
138
|
/** User rejected the request (cancelled approval screen). */
|
|
@@ -146,7 +146,7 @@ declare const WALLET_ERROR: {
|
|
|
146
146
|
};
|
|
147
147
|
/**
|
|
148
148
|
* Solana commitment levels for send options.
|
|
149
|
-
* @since 0.
|
|
149
|
+
* @since 1.0.0
|
|
150
150
|
* @schema
|
|
151
151
|
*/
|
|
152
152
|
type SolanaCommitment = 'processed' | 'confirmed' | 'finalized';
|
|
@@ -154,7 +154,7 @@ type SolanaCommitment = 'processed' | 'confirmed' | 'finalized';
|
|
|
154
154
|
* Solana chain identifiers (wallet-standard format).
|
|
155
155
|
* Used by `wallet.solana:sign.send` to tell the host app
|
|
156
156
|
* which cluster to broadcast to.
|
|
157
|
-
* @since 0.
|
|
157
|
+
* @since 1.0.0
|
|
158
158
|
* @schema
|
|
159
159
|
*/
|
|
160
160
|
type SolanaChain = 'solana:mainnet' | 'solana:devnet' | 'solana:testnet';
|
|
@@ -182,7 +182,7 @@ interface Events {
|
|
|
182
182
|
'miniapp:close': CreateEventPayload<Empty>;
|
|
183
183
|
/**
|
|
184
184
|
* Host app's back button clicked event.
|
|
185
|
-
* @since 0.0
|
|
185
|
+
* @since 1.0.0
|
|
186
186
|
* @schema
|
|
187
187
|
*/
|
|
188
188
|
'host.back.button:clicked': CreateEventPayload<Empty>;
|
|
@@ -253,7 +253,7 @@ interface Events {
|
|
|
253
253
|
}>>;
|
|
254
254
|
/**
|
|
255
255
|
* Solana wallet connection response.
|
|
256
|
-
* @since 0.
|
|
256
|
+
* @since 1.0.0
|
|
257
257
|
* @schema
|
|
258
258
|
*/
|
|
259
259
|
'wallet.solana:connect.response': CreateEventPayload<WithReqId<{
|
|
@@ -266,7 +266,7 @@ interface Events {
|
|
|
266
266
|
}>>;
|
|
267
267
|
/**
|
|
268
268
|
* Solana transaction signing response.
|
|
269
|
-
* @since 0.
|
|
269
|
+
* @since 1.0.0
|
|
270
270
|
* @schema
|
|
271
271
|
*/
|
|
272
272
|
'wallet.solana:sign.transaction.response': CreateEventPayload<WithReqId<{
|
|
@@ -279,7 +279,7 @@ interface Events {
|
|
|
279
279
|
}>>;
|
|
280
280
|
/**
|
|
281
281
|
* Solana message signing response.
|
|
282
|
-
* @since 0.
|
|
282
|
+
* @since 1.0.0
|
|
283
283
|
* @schema
|
|
284
284
|
*/
|
|
285
285
|
'wallet.solana:sign.message.response': CreateEventPayload<WithReqId<{
|
|
@@ -294,7 +294,7 @@ interface Events {
|
|
|
294
294
|
}>>;
|
|
295
295
|
/**
|
|
296
296
|
* Solana sign-and-send transaction response.
|
|
297
|
-
* @since 0.
|
|
297
|
+
* @since 1.0.0
|
|
298
298
|
* @schema
|
|
299
299
|
*/
|
|
300
300
|
'wallet.solana:sign.send.response': CreateEventPayload<WithReqId<{
|
|
@@ -320,6 +320,17 @@ declare const PLATFORMS: readonly ["ios", "android"];
|
|
|
320
320
|
* Platform the miniapp is running on.
|
|
321
321
|
*/
|
|
322
322
|
type Platform = (typeof PLATFORMS)[number];
|
|
323
|
+
/**
|
|
324
|
+
* Supported display modes for miniapps.
|
|
325
|
+
* - `standard` — standard webview with native chrome
|
|
326
|
+
* - `fullscreen` — fullscreen webview, native controls still visible
|
|
327
|
+
* - `immersive` — no native UI elements at all (no close button, options, etc.)
|
|
328
|
+
*/
|
|
329
|
+
declare const DISPLAY_MODES: readonly ["standard", "fullscreen", "immersive"];
|
|
330
|
+
/**
|
|
331
|
+
* Display mode for the miniapp webview.
|
|
332
|
+
*/
|
|
333
|
+
type DisplayMode = (typeof DISPLAY_MODES)[number];
|
|
323
334
|
/**
|
|
324
335
|
* Safe area insets in CSS pixels, injected by the host app.
|
|
325
336
|
* Accounts for system UI (status bar, notch, home indicator, nav bar).
|
|
@@ -349,6 +360,12 @@ interface LaunchParams {
|
|
|
349
360
|
* Used for referral codes, campaign tracking, or custom routing.
|
|
350
361
|
*/
|
|
351
362
|
startParam: string | undefined;
|
|
363
|
+
/**
|
|
364
|
+
* Display mode for the miniapp webview.
|
|
365
|
+
* Defaults to `'standard'` when not provided by the host app.
|
|
366
|
+
* @since 1.0.0
|
|
367
|
+
*/
|
|
368
|
+
displayMode: DisplayMode;
|
|
352
369
|
}
|
|
353
370
|
//#endregion
|
|
354
371
|
//#region src/methods/types/payload.d.ts
|
|
@@ -369,27 +386,27 @@ interface Methods {
|
|
|
369
386
|
/**
|
|
370
387
|
* Miniapp ready method.
|
|
371
388
|
* Sent by the miniapp to notify the host app that it has loaded and is ready to be displayed.
|
|
372
|
-
* @since 0.0.
|
|
389
|
+
* @since 0.0.9
|
|
373
390
|
* @schema
|
|
374
391
|
*/
|
|
375
392
|
'app:ready': CreateMethodPayload<Empty>;
|
|
376
393
|
/**
|
|
377
|
-
*
|
|
378
|
-
* Sent by the miniapp to
|
|
379
|
-
*
|
|
380
|
-
* @since 0.0
|
|
394
|
+
* Close the miniapp.
|
|
395
|
+
* Sent by the miniapp to request the host app to close it.
|
|
396
|
+
* Fire-and-forget — no response expected.
|
|
397
|
+
* @since 1.0.0
|
|
381
398
|
* @schema
|
|
382
399
|
*/
|
|
383
|
-
'
|
|
400
|
+
'app:close': CreateMethodPayload<Empty>;
|
|
384
401
|
/**
|
|
385
402
|
* Toggle host app's back button visibility.
|
|
386
|
-
* @since 0.0
|
|
403
|
+
* @since 1.0.0
|
|
387
404
|
* @schema
|
|
388
405
|
*/
|
|
389
406
|
'host.back.button:toggle': CreateMethodPayload<{
|
|
390
407
|
/**
|
|
391
408
|
* Whether to show or hide the back button.
|
|
392
|
-
* @since 0.0
|
|
409
|
+
* @since 1.0.0
|
|
393
410
|
* @schema
|
|
394
411
|
*/
|
|
395
412
|
visible: boolean;
|
|
@@ -401,8 +418,8 @@ interface Methods {
|
|
|
401
418
|
* Your backend receives a webhook when user pays - fulfill the order
|
|
402
419
|
* immediately without waiting for chain confirmation.
|
|
403
420
|
*
|
|
404
|
-
* Optional
|
|
405
|
-
*
|
|
421
|
+
* Optional `item` object (`title`, `iconUrl`, `quantity`)
|
|
422
|
+
* is shown on the payment approval screen.
|
|
406
423
|
*
|
|
407
424
|
* Set `test` to a scenario string (e.g. `'paid'`, `'error:insufficient_balance'`)
|
|
408
425
|
* for test mode - no real payment is made, but the specified scenario is
|
|
@@ -594,21 +611,21 @@ interface Methods {
|
|
|
594
611
|
/**
|
|
595
612
|
* Request Solana wallet connection.
|
|
596
613
|
* Returns the wallet's public key on success.
|
|
597
|
-
* @since 0.
|
|
614
|
+
* @since 1.0.0
|
|
598
615
|
* @schema
|
|
599
616
|
*/
|
|
600
617
|
'wallet.solana:connect': CreateMethodPayload<WithReqId<Empty>>;
|
|
601
618
|
/**
|
|
602
619
|
* Disconnect from Solana wallet.
|
|
603
620
|
* Fire-and-forget — no response expected.
|
|
604
|
-
* @since 0.
|
|
621
|
+
* @since 1.0.0
|
|
605
622
|
* @schema
|
|
606
623
|
*/
|
|
607
624
|
'wallet.solana:disconnect': CreateMethodPayload<Empty>;
|
|
608
625
|
/**
|
|
609
626
|
* Request Solana transaction signing.
|
|
610
627
|
* Returns the signed transaction bytes.
|
|
611
|
-
* @since 0.
|
|
628
|
+
* @since 1.0.0
|
|
612
629
|
* @schema
|
|
613
630
|
*/
|
|
614
631
|
'wallet.solana:sign.transaction': CreateMethodPayload<WithReqId<{
|
|
@@ -618,7 +635,7 @@ interface Methods {
|
|
|
618
635
|
/**
|
|
619
636
|
* Request Solana message signing.
|
|
620
637
|
* Returns the Ed25519 signature.
|
|
621
|
-
* @since 0.
|
|
638
|
+
* @since 1.0.0
|
|
622
639
|
* @schema
|
|
623
640
|
*/
|
|
624
641
|
'wallet.solana:sign.message': CreateMethodPayload<WithReqId<{
|
|
@@ -629,7 +646,7 @@ interface Methods {
|
|
|
629
646
|
* Request Solana transaction signing and sending.
|
|
630
647
|
* The host app signs and broadcasts the transaction.
|
|
631
648
|
* Returns the transaction signature.
|
|
632
|
-
* @since 0.
|
|
649
|
+
* @since 1.0.0
|
|
633
650
|
* @schema
|
|
634
651
|
*/
|
|
635
652
|
'wallet.solana:sign.send': CreateMethodPayload<WithReqId<{
|
|
@@ -640,7 +657,7 @@ interface Methods {
|
|
|
640
657
|
* In bridge mode the host app can infer this from miniapp config,
|
|
641
658
|
* but in relay mode (QR/WebSocket) this is required so the host
|
|
642
659
|
* app knows which RPC to broadcast to.
|
|
643
|
-
* @since 0.
|
|
660
|
+
* @since 1.0.0
|
|
644
661
|
* @schema
|
|
645
662
|
*/
|
|
646
663
|
chain?: SolanaChain;
|
|
@@ -712,4 +729,4 @@ declare function isMethodSupported(method: MethodName, version: Version): boolea
|
|
|
712
729
|
*/
|
|
713
730
|
declare function getMethodMinVersion(method: MethodName): Version | undefined;
|
|
714
731
|
//#endregion
|
|
715
|
-
export { type CreateEventPayload, type CreateMethodPayload, type EventName, type EventPayload, type Events, type HapticImpactStyle, type HapticNotificationType, type LaunchParams, type MethodName, type MethodNameWithVersionedPayload, type MethodPayload, type MethodVersionedPayload, type Methods, PLATFORMS, type PaymentErrorCode, type PaymentTestScenario, type PaymentWebhookStatus, type Platform, type SafeAreaInsets, type SolanaChain, type SolanaCommitment, type Version, WALLET_ERROR, type WalletSolanaErrorCode, getMethodMinVersion, getReleaseVersion, isMethodSupported, releases };
|
|
732
|
+
export { type CreateEventPayload, type CreateMethodPayload, DISPLAY_MODES, type DisplayMode, type EventName, type EventPayload, type Events, type HapticImpactStyle, type HapticNotificationType, type LaunchParams, type MethodName, type MethodNameWithVersionedPayload, type MethodPayload, type MethodVersionedPayload, type Methods, PLATFORMS, type PaymentErrorCode, type PaymentTestScenario, type PaymentWebhookStatus, type Platform, type SafeAreaInsets, type SolanaChain, type SolanaCommitment, type Version, WALLET_ERROR, type WalletSolanaErrorCode, getMethodMinVersion, getReleaseVersion, isMethodSupported, releases };
|
package/dist/index.mjs
CHANGED
|
@@ -3,12 +3,22 @@
|
|
|
3
3
|
* Supported platforms for miniapps.
|
|
4
4
|
*/
|
|
5
5
|
const PLATFORMS = ["ios", "android"];
|
|
6
|
+
/**
|
|
7
|
+
* Supported display modes for miniapps.
|
|
8
|
+
* - `standard` — standard webview with native chrome
|
|
9
|
+
* - `fullscreen` — fullscreen webview, native controls still visible
|
|
10
|
+
* - `immersive` — no native UI elements at all (no close button, options, etc.)
|
|
11
|
+
*/
|
|
12
|
+
const DISPLAY_MODES = [
|
|
13
|
+
"standard",
|
|
14
|
+
"fullscreen",
|
|
15
|
+
"immersive"
|
|
16
|
+
];
|
|
6
17
|
|
|
7
18
|
//#endregion
|
|
8
19
|
//#region src/methods/versions/releases.ts
|
|
9
20
|
const releases = {
|
|
10
21
|
"0.0.9": ["app:ready"],
|
|
11
|
-
"0.0.14": ["miniapp:close.ack", "host.back.button:toggle"],
|
|
12
22
|
"0.1.1": [
|
|
13
23
|
"payment:request",
|
|
14
24
|
"clipboard:write",
|
|
@@ -20,12 +30,14 @@ const releases = {
|
|
|
20
30
|
"haptic:notification",
|
|
21
31
|
"haptic:selection"
|
|
22
32
|
],
|
|
23
|
-
"0.
|
|
33
|
+
"1.0.0": [
|
|
24
34
|
"wallet.solana:connect",
|
|
25
35
|
"wallet.solana:disconnect",
|
|
26
36
|
"wallet.solana:sign.transaction",
|
|
27
37
|
"wallet.solana:sign.message",
|
|
28
|
-
"wallet.solana:sign.send"
|
|
38
|
+
"wallet.solana:sign.send",
|
|
39
|
+
"app:close",
|
|
40
|
+
"host.back.button:toggle"
|
|
29
41
|
]
|
|
30
42
|
};
|
|
31
43
|
|
|
@@ -103,7 +115,7 @@ function getMethodMinVersion(method) {
|
|
|
103
115
|
* }
|
|
104
116
|
* ```
|
|
105
117
|
*
|
|
106
|
-
* @since 0.
|
|
118
|
+
* @since 1.0.0
|
|
107
119
|
*/
|
|
108
120
|
const WALLET_ERROR = {
|
|
109
121
|
USER_REJECTED: 5e3,
|
|
@@ -113,4 +125,4 @@ const WALLET_ERROR = {
|
|
|
113
125
|
};
|
|
114
126
|
|
|
115
127
|
//#endregion
|
|
116
|
-
export { PLATFORMS, WALLET_ERROR, getMethodMinVersion, getReleaseVersion, isMethodSupported, releases };
|
|
128
|
+
export { DISPLAY_MODES, PLATFORMS, WALLET_ERROR, getMethodMinVersion, getReleaseVersion, isMethodSupported, releases };
|