@orbi-wallet/sdk 0.1.0 → 0.1.1
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/client.d.ts +17 -2
- package/dist/client.js +36 -2
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +10 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/dist/client.d.ts
CHANGED
|
@@ -8,12 +8,15 @@
|
|
|
8
8
|
* const { walletAddress } = await orbi.connect();
|
|
9
9
|
* const { signedXdr } = await orbi.signTransaction({ xdr });
|
|
10
10
|
*/
|
|
11
|
-
import type { ConnectedWallet, OrbiClientConfig, SignResult } from './types';
|
|
11
|
+
import type { ConnectedWallet, EvmSignResult, OrbiChain, OrbiClientConfig, SignResult } from './types';
|
|
12
12
|
export declare class OrbiClient {
|
|
13
13
|
private network;
|
|
14
|
+
private chain;
|
|
14
15
|
constructor(config?: OrbiClientConfig);
|
|
15
16
|
/** Wallet address from a previous `connect()`, restored from local storage. */
|
|
16
17
|
getAddress(): string | null;
|
|
18
|
+
/** Chain of the cached session, if any. */
|
|
19
|
+
getChain(): OrbiChain | null;
|
|
17
20
|
/** Forget the cached session. The next `connect()` reopens the Orbi popup. */
|
|
18
21
|
disconnect(): void;
|
|
19
22
|
private getSession;
|
|
@@ -22,7 +25,9 @@ export declare class OrbiClient {
|
|
|
22
25
|
* session if one exists; otherwise opens the Orbi connect popup and
|
|
23
26
|
* resolves once the user approves.
|
|
24
27
|
*/
|
|
25
|
-
connect(
|
|
28
|
+
connect(opts?: {
|
|
29
|
+
chain?: OrbiChain;
|
|
30
|
+
}): Promise<ConnectedWallet>;
|
|
26
31
|
/**
|
|
27
32
|
* Ask the user to review and approve a transaction with their passkey.
|
|
28
33
|
*
|
|
@@ -34,5 +39,15 @@ export declare class OrbiClient {
|
|
|
34
39
|
xdr: string;
|
|
35
40
|
walletAddress?: string;
|
|
36
41
|
}): Promise<SignResult>;
|
|
42
|
+
/**
|
|
43
|
+
* Ask the user to review and approve a native-token (BOT) transfer on
|
|
44
|
+
* BotChain. Signing and submission happen inside the Orbi popup — where the
|
|
45
|
+
* passkey lives — so the dApp never touches a key. Returns the tx hash.
|
|
46
|
+
*/
|
|
47
|
+
signEvmTransaction(params: {
|
|
48
|
+
to: string;
|
|
49
|
+
value: string;
|
|
50
|
+
walletAddress?: string;
|
|
51
|
+
}): Promise<EvmSignResult>;
|
|
37
52
|
private openPopup;
|
|
38
53
|
}
|
package/dist/client.js
CHANGED
|
@@ -22,12 +22,17 @@ const POPUP_HEIGHT = 640;
|
|
|
22
22
|
class OrbiClient {
|
|
23
23
|
constructor(config = {}) {
|
|
24
24
|
this.network = config.network ?? 'testnet';
|
|
25
|
+
this.chain = config.chain ?? 'stellar';
|
|
25
26
|
}
|
|
26
27
|
// ── Session ─────────────────────────────────────────────────────────────────
|
|
27
28
|
/** Wallet address from a previous `connect()`, restored from local storage. */
|
|
28
29
|
getAddress() {
|
|
29
30
|
return this.getSession()?.walletAddress ?? null;
|
|
30
31
|
}
|
|
32
|
+
/** Chain of the cached session, if any. */
|
|
33
|
+
getChain() {
|
|
34
|
+
return this.getSession()?.chain ?? null;
|
|
35
|
+
}
|
|
31
36
|
/** Forget the cached session. The next `connect()` reopens the Orbi popup. */
|
|
32
37
|
disconnect() {
|
|
33
38
|
if (typeof window === 'undefined')
|
|
@@ -46,17 +51,23 @@ class OrbiClient {
|
|
|
46
51
|
* session if one exists; otherwise opens the Orbi connect popup and
|
|
47
52
|
* resolves once the user approves.
|
|
48
53
|
*/
|
|
49
|
-
async connect() {
|
|
54
|
+
async connect(opts = {}) {
|
|
55
|
+
const chain = opts.chain ?? this.chain;
|
|
56
|
+
// A cached session only satisfies a connect for the *same* chain — the
|
|
57
|
+
// address differs per chain, so a Stellar session can't stand in for a
|
|
58
|
+
// BotChain connect (or vice versa).
|
|
50
59
|
const cached = this.getSession();
|
|
51
|
-
if (cached)
|
|
60
|
+
if (cached && cached.chain === chain)
|
|
52
61
|
return cached;
|
|
53
62
|
const wallet = await this.openPopup({
|
|
54
63
|
path: '/connect',
|
|
64
|
+
params: { chain },
|
|
55
65
|
successType: 'orbi_connected',
|
|
56
66
|
mapSuccess: (msg) => ({
|
|
57
67
|
walletAddress: msg.address,
|
|
58
68
|
credentialId: msg.credentialId ?? '',
|
|
59
69
|
passkeyId: msg.passkeyId ?? '',
|
|
70
|
+
chain: (msg.chain ?? chain),
|
|
60
71
|
}),
|
|
61
72
|
});
|
|
62
73
|
localStorage.setItem(SESSION_KEY, JSON.stringify(wallet));
|
|
@@ -86,6 +97,29 @@ class OrbiClient {
|
|
|
86
97
|
}),
|
|
87
98
|
});
|
|
88
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Ask the user to review and approve a native-token (BOT) transfer on
|
|
102
|
+
* BotChain. Signing and submission happen inside the Orbi popup — where the
|
|
103
|
+
* passkey lives — so the dApp never touches a key. Returns the tx hash.
|
|
104
|
+
*/
|
|
105
|
+
signEvmTransaction(params) {
|
|
106
|
+
const walletAddress = params.walletAddress ?? this.getAddress() ?? undefined;
|
|
107
|
+
return this.openPopup({
|
|
108
|
+
path: '/sign',
|
|
109
|
+
params: {
|
|
110
|
+
chain: 'botchain',
|
|
111
|
+
to: params.to,
|
|
112
|
+
value: params.value,
|
|
113
|
+
network: this.network,
|
|
114
|
+
...(walletAddress ? { walletAddress } : {}),
|
|
115
|
+
},
|
|
116
|
+
successType: 'orbi_evm_sent',
|
|
117
|
+
mapSuccess: (msg) => ({
|
|
118
|
+
txHash: msg.txHash,
|
|
119
|
+
walletAddress: msg.walletAddress,
|
|
120
|
+
}),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
89
123
|
// ── Popup + postMessage handshake ───────────────────────────────────────────
|
|
90
124
|
openPopup(req) {
|
|
91
125
|
if (typeof window === 'undefined') {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { OrbiClient } from './client';
|
|
2
|
-
export type { ConnectedWallet, OrbiClientConfig, OrbiNetwork, SignResult } from './types';
|
|
2
|
+
export type { ConnectedWallet, EvmSignResult, OrbiChain, OrbiClientConfig, OrbiNetwork, SignResult } from './types';
|
package/dist/types.d.ts
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
export type OrbiNetwork = 'testnet' | 'mainnet';
|
|
2
|
+
/** Which chain the wallet operates on. One passkey backs every chain. */
|
|
3
|
+
export type OrbiChain = 'stellar' | 'botchain';
|
|
2
4
|
export interface OrbiClientConfig {
|
|
3
|
-
/**
|
|
5
|
+
/** Network the dApp is operating on. Defaults to 'testnet'. */
|
|
4
6
|
network?: OrbiNetwork;
|
|
7
|
+
/** Chain to connect on. Defaults to 'stellar'. */
|
|
8
|
+
chain?: OrbiChain;
|
|
5
9
|
}
|
|
6
10
|
export interface ConnectedWallet {
|
|
7
11
|
walletAddress: string;
|
|
8
12
|
credentialId: string;
|
|
9
13
|
passkeyId: string;
|
|
14
|
+
chain: OrbiChain;
|
|
10
15
|
}
|
|
11
16
|
export interface SignResult {
|
|
12
17
|
signedXdr: string;
|
|
13
18
|
walletAddress: string;
|
|
14
19
|
}
|
|
20
|
+
export interface EvmSignResult {
|
|
21
|
+
txHash: string;
|
|
22
|
+
walletAddress: string;
|
|
23
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const SDK_NAME = "@orbi-wallet/sdk";
|
|
2
|
-
export declare const SDK_VERSION = "0.1.
|
|
2
|
+
export declare const SDK_VERSION = "0.1.1";
|
package/dist/version.js
CHANGED
|
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SDK_VERSION = exports.SDK_NAME = void 0;
|
|
4
4
|
// Generated by scripts/generate-version.js from package.json — do not edit.
|
|
5
5
|
exports.SDK_NAME = "@orbi-wallet/sdk";
|
|
6
|
-
exports.SDK_VERSION = "0.1.
|
|
6
|
+
exports.SDK_VERSION = "0.1.1";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbi-wallet/sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Orbi Smart Wallet SDK — connect any Stellar dApp to Orbi passkey wallets",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Orbi Smart Wallet SDK — connect any Stellar or BotChain dApp to Orbi passkey wallets",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|