@orbi-wallet/sdk 0.1.0 → 0.1.2
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 +47 -3
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +16 -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,33 @@ 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;
|
|
50
56
|
const cached = this.getSession();
|
|
51
|
-
if (cached)
|
|
52
|
-
|
|
57
|
+
if (cached) {
|
|
58
|
+
// Already on the requested chain — nothing to do.
|
|
59
|
+
if (cached.chain === chain)
|
|
60
|
+
return cached;
|
|
61
|
+
// Switching chains: if a prior connect already derived this chain's
|
|
62
|
+
// address (the popup returns both at once), switch instantly with no
|
|
63
|
+
// re-prompt — just re-point the active chain/address.
|
|
64
|
+
const known = cached.addresses?.[chain];
|
|
65
|
+
if (known) {
|
|
66
|
+
const switched = { ...cached, walletAddress: known, chain };
|
|
67
|
+
localStorage.setItem(SESSION_KEY, JSON.stringify(switched));
|
|
68
|
+
return switched;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
53
71
|
const wallet = await this.openPopup({
|
|
54
72
|
path: '/connect',
|
|
73
|
+
params: { chain },
|
|
55
74
|
successType: 'orbi_connected',
|
|
56
75
|
mapSuccess: (msg) => ({
|
|
57
76
|
walletAddress: msg.address,
|
|
58
77
|
credentialId: msg.credentialId ?? '',
|
|
59
78
|
passkeyId: msg.passkeyId ?? '',
|
|
79
|
+
chain: (msg.chain ?? chain),
|
|
80
|
+
addresses: msg.addresses,
|
|
60
81
|
}),
|
|
61
82
|
});
|
|
62
83
|
localStorage.setItem(SESSION_KEY, JSON.stringify(wallet));
|
|
@@ -86,6 +107,29 @@ class OrbiClient {
|
|
|
86
107
|
}),
|
|
87
108
|
});
|
|
88
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Ask the user to review and approve a native-token (BOT) transfer on
|
|
112
|
+
* BotChain. Signing and submission happen inside the Orbi popup — where the
|
|
113
|
+
* passkey lives — so the dApp never touches a key. Returns the tx hash.
|
|
114
|
+
*/
|
|
115
|
+
signEvmTransaction(params) {
|
|
116
|
+
const walletAddress = params.walletAddress ?? this.getAddress() ?? undefined;
|
|
117
|
+
return this.openPopup({
|
|
118
|
+
path: '/sign',
|
|
119
|
+
params: {
|
|
120
|
+
chain: 'botchain',
|
|
121
|
+
to: params.to,
|
|
122
|
+
value: params.value,
|
|
123
|
+
network: this.network,
|
|
124
|
+
...(walletAddress ? { walletAddress } : {}),
|
|
125
|
+
},
|
|
126
|
+
successType: 'orbi_evm_sent',
|
|
127
|
+
mapSuccess: (msg) => ({
|
|
128
|
+
txHash: msg.txHash,
|
|
129
|
+
walletAddress: msg.walletAddress,
|
|
130
|
+
}),
|
|
131
|
+
});
|
|
132
|
+
}
|
|
89
133
|
// ── Popup + postMessage handshake ───────────────────────────────────────────
|
|
90
134
|
openPopup(req) {
|
|
91
135
|
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,29 @@
|
|
|
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;
|
|
15
|
+
/**
|
|
16
|
+
* All per-chain addresses derived from this passkey, when the wallet
|
|
17
|
+
* provided them. Lets `connect()` switch chains without re-prompting once an
|
|
18
|
+
* address is known.
|
|
19
|
+
*/
|
|
20
|
+
addresses?: Partial<Record<OrbiChain, string>>;
|
|
10
21
|
}
|
|
11
22
|
export interface SignResult {
|
|
12
23
|
signedXdr: string;
|
|
13
24
|
walletAddress: string;
|
|
14
25
|
}
|
|
26
|
+
export interface EvmSignResult {
|
|
27
|
+
txHash: string;
|
|
28
|
+
walletAddress: string;
|
|
29
|
+
}
|
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.2";
|
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.2";
|
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.2",
|
|
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": [
|