@orbi-wallet/sdk 0.1.1 → 0.1.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/dist/client.d.ts +24 -8
- package/dist/client.js +74 -10
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +20 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
* const { walletAddress } = await orbi.connect();
|
|
9
9
|
* const { signedXdr } = await orbi.signTransaction({ xdr });
|
|
10
10
|
*/
|
|
11
|
-
import type { ConnectedWallet, EvmSignResult, OrbiChain, OrbiClientConfig, SignResult } from './types';
|
|
11
|
+
import type { ConnectedWallet, EvmSignatureResult, EvmSignResult, EvmTxParams, OrbiChain, OrbiClientConfig, SignResult } from './types';
|
|
12
12
|
export declare class OrbiClient {
|
|
13
13
|
private network;
|
|
14
14
|
private chain;
|
|
15
|
+
private chainId?;
|
|
15
16
|
constructor(config?: OrbiClientConfig);
|
|
16
17
|
/** Wallet address from a previous `connect()`, restored from local storage. */
|
|
17
18
|
getAddress(): string | null;
|
|
@@ -40,14 +41,29 @@ export declare class OrbiClient {
|
|
|
40
41
|
walletAddress?: string;
|
|
41
42
|
}): Promise<SignResult>;
|
|
42
43
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
44
|
+
* Review and approve an EVM transaction — native transfer or contract call.
|
|
45
|
+
* Signing and submission happen inside the Orbi popup (where the passkey
|
|
46
|
+
* lives), so the dApp never touches a key. Returns the tx hash.
|
|
47
|
+
* `value` is wei (decimal string); `data` is 0x calldata for contract calls.
|
|
46
48
|
*/
|
|
47
|
-
signEvmTransaction(params:
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
signEvmTransaction(params: EvmTxParams): Promise<EvmSignResult>;
|
|
50
|
+
/**
|
|
51
|
+
* Sign an arbitrary message (EIP-191 / personal_sign). This is what dApp
|
|
52
|
+
* login ("Sign-In With Ethereum") uses. Returns the 65-byte signature.
|
|
53
|
+
*/
|
|
54
|
+
signMessage(params: {
|
|
55
|
+
message: string;
|
|
56
|
+
chainId?: number;
|
|
57
|
+
walletAddress?: string;
|
|
58
|
+
}): Promise<EvmSignatureResult>;
|
|
59
|
+
/**
|
|
60
|
+
* Sign EIP-712 typed data (eth_signTypedData_v4) — permits, listings, etc.
|
|
61
|
+
* `typedData` is the standard { domain, types, primaryType, message } object.
|
|
62
|
+
*/
|
|
63
|
+
signTypedData(params: {
|
|
64
|
+
typedData: unknown;
|
|
65
|
+
chainId?: number;
|
|
50
66
|
walletAddress?: string;
|
|
51
|
-
}): Promise<
|
|
67
|
+
}): Promise<EvmSignatureResult>;
|
|
52
68
|
private openPopup;
|
|
53
69
|
}
|
package/dist/client.js
CHANGED
|
@@ -23,6 +23,7 @@ class OrbiClient {
|
|
|
23
23
|
constructor(config = {}) {
|
|
24
24
|
this.network = config.network ?? 'testnet';
|
|
25
25
|
this.chain = config.chain ?? 'stellar';
|
|
26
|
+
this.chainId = config.chainId;
|
|
26
27
|
}
|
|
27
28
|
// ── Session ─────────────────────────────────────────────────────────────────
|
|
28
29
|
/** Wallet address from a previous `connect()`, restored from local storage. */
|
|
@@ -53,12 +54,21 @@ class OrbiClient {
|
|
|
53
54
|
*/
|
|
54
55
|
async connect(opts = {}) {
|
|
55
56
|
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).
|
|
59
57
|
const cached = this.getSession();
|
|
60
|
-
if (cached
|
|
61
|
-
|
|
58
|
+
if (cached) {
|
|
59
|
+
// Already on the requested chain — nothing to do.
|
|
60
|
+
if (cached.chain === chain)
|
|
61
|
+
return cached;
|
|
62
|
+
// Switching chains: if a prior connect already derived this chain's
|
|
63
|
+
// address (the popup returns both at once), switch instantly with no
|
|
64
|
+
// re-prompt — just re-point the active chain/address.
|
|
65
|
+
const known = cached.addresses?.[chain];
|
|
66
|
+
if (known) {
|
|
67
|
+
const switched = { ...cached, walletAddress: known, chain };
|
|
68
|
+
localStorage.setItem(SESSION_KEY, JSON.stringify(switched));
|
|
69
|
+
return switched;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
62
72
|
const wallet = await this.openPopup({
|
|
63
73
|
path: '/connect',
|
|
64
74
|
params: { chain },
|
|
@@ -68,6 +78,7 @@ class OrbiClient {
|
|
|
68
78
|
credentialId: msg.credentialId ?? '',
|
|
69
79
|
passkeyId: msg.passkeyId ?? '',
|
|
70
80
|
chain: (msg.chain ?? chain),
|
|
81
|
+
addresses: msg.addresses,
|
|
71
82
|
}),
|
|
72
83
|
});
|
|
73
84
|
localStorage.setItem(SESSION_KEY, JSON.stringify(wallet));
|
|
@@ -98,19 +109,26 @@ class OrbiClient {
|
|
|
98
109
|
});
|
|
99
110
|
}
|
|
100
111
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
112
|
+
* Review and approve an EVM transaction — native transfer or contract call.
|
|
113
|
+
* Signing and submission happen inside the Orbi popup (where the passkey
|
|
114
|
+
* lives), so the dApp never touches a key. Returns the tx hash.
|
|
115
|
+
* `value` is wei (decimal string); `data` is 0x calldata for contract calls.
|
|
104
116
|
*/
|
|
105
117
|
signEvmTransaction(params) {
|
|
106
118
|
const walletAddress = params.walletAddress ?? this.getAddress() ?? undefined;
|
|
119
|
+
const chainId = params.chainId ?? this.chainId;
|
|
120
|
+
if (chainId === undefined)
|
|
121
|
+
throw new Error('chainId is required for EVM transactions');
|
|
107
122
|
return this.openPopup({
|
|
108
123
|
path: '/sign',
|
|
109
124
|
params: {
|
|
110
125
|
chain: 'botchain',
|
|
126
|
+
evmAction: 'tx',
|
|
127
|
+
chainId: String(chainId),
|
|
111
128
|
to: params.to,
|
|
112
|
-
value: params.value,
|
|
113
|
-
|
|
129
|
+
...(params.value ? { value: params.value } : {}),
|
|
130
|
+
...(params.data ? { data: params.data } : {}),
|
|
131
|
+
...(params.gas ? { gas: params.gas } : {}),
|
|
114
132
|
...(walletAddress ? { walletAddress } : {}),
|
|
115
133
|
},
|
|
116
134
|
successType: 'orbi_evm_sent',
|
|
@@ -120,6 +138,52 @@ class OrbiClient {
|
|
|
120
138
|
}),
|
|
121
139
|
});
|
|
122
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Sign an arbitrary message (EIP-191 / personal_sign). This is what dApp
|
|
143
|
+
* login ("Sign-In With Ethereum") uses. Returns the 65-byte signature.
|
|
144
|
+
*/
|
|
145
|
+
signMessage(params) {
|
|
146
|
+
const walletAddress = params.walletAddress ?? this.getAddress() ?? undefined;
|
|
147
|
+
const chainId = params.chainId ?? this.chainId;
|
|
148
|
+
return this.openPopup({
|
|
149
|
+
path: '/sign',
|
|
150
|
+
params: {
|
|
151
|
+
chain: 'botchain',
|
|
152
|
+
evmAction: 'message',
|
|
153
|
+
message: params.message,
|
|
154
|
+
...(chainId !== undefined ? { chainId: String(chainId) } : {}),
|
|
155
|
+
...(walletAddress ? { walletAddress } : {}),
|
|
156
|
+
},
|
|
157
|
+
successType: 'orbi_evm_signed',
|
|
158
|
+
mapSuccess: (msg) => ({
|
|
159
|
+
signature: msg.signature,
|
|
160
|
+
walletAddress: msg.walletAddress,
|
|
161
|
+
}),
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Sign EIP-712 typed data (eth_signTypedData_v4) — permits, listings, etc.
|
|
166
|
+
* `typedData` is the standard { domain, types, primaryType, message } object.
|
|
167
|
+
*/
|
|
168
|
+
signTypedData(params) {
|
|
169
|
+
const walletAddress = params.walletAddress ?? this.getAddress() ?? undefined;
|
|
170
|
+
const chainId = params.chainId ?? this.chainId;
|
|
171
|
+
return this.openPopup({
|
|
172
|
+
path: '/sign',
|
|
173
|
+
params: {
|
|
174
|
+
chain: 'botchain',
|
|
175
|
+
evmAction: 'typedData',
|
|
176
|
+
typedData: JSON.stringify(params.typedData),
|
|
177
|
+
...(chainId !== undefined ? { chainId: String(chainId) } : {}),
|
|
178
|
+
...(walletAddress ? { walletAddress } : {}),
|
|
179
|
+
},
|
|
180
|
+
successType: 'orbi_evm_signed',
|
|
181
|
+
mapSuccess: (msg) => ({
|
|
182
|
+
signature: msg.signature,
|
|
183
|
+
walletAddress: msg.walletAddress,
|
|
184
|
+
}),
|
|
185
|
+
});
|
|
186
|
+
}
|
|
123
187
|
// ── Popup + postMessage handshake ───────────────────────────────────────────
|
|
124
188
|
openPopup(req) {
|
|
125
189
|
if (typeof window === 'undefined') {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { OrbiClient } from './client';
|
|
2
|
-
export type { ConnectedWallet, EvmSignResult, OrbiChain, OrbiClientConfig, OrbiNetwork, SignResult } from './types';
|
|
2
|
+
export type { ConnectedWallet, EvmSignatureResult, EvmSignResult, EvmTxParams, OrbiChain, OrbiClientConfig, OrbiNetwork, SignResult } from './types';
|
package/dist/types.d.ts
CHANGED
|
@@ -6,12 +6,20 @@ export interface OrbiClientConfig {
|
|
|
6
6
|
network?: OrbiNetwork;
|
|
7
7
|
/** Chain to connect on. Defaults to 'stellar'. */
|
|
8
8
|
chain?: OrbiChain;
|
|
9
|
+
/** Default EVM chainId for signing/sending (per-call override available). */
|
|
10
|
+
chainId?: number;
|
|
9
11
|
}
|
|
10
12
|
export interface ConnectedWallet {
|
|
11
13
|
walletAddress: string;
|
|
12
14
|
credentialId: string;
|
|
13
15
|
passkeyId: string;
|
|
14
16
|
chain: OrbiChain;
|
|
17
|
+
/**
|
|
18
|
+
* All per-chain addresses derived from this passkey, when the wallet
|
|
19
|
+
* provided them. Lets `connect()` switch chains without re-prompting once an
|
|
20
|
+
* address is known.
|
|
21
|
+
*/
|
|
22
|
+
addresses?: Partial<Record<OrbiChain, string>>;
|
|
15
23
|
}
|
|
16
24
|
export interface SignResult {
|
|
17
25
|
signedXdr: string;
|
|
@@ -21,3 +29,15 @@ export interface EvmSignResult {
|
|
|
21
29
|
txHash: string;
|
|
22
30
|
walletAddress: string;
|
|
23
31
|
}
|
|
32
|
+
export interface EvmSignatureResult {
|
|
33
|
+
signature: string;
|
|
34
|
+
walletAddress: string;
|
|
35
|
+
}
|
|
36
|
+
export interface EvmTxParams {
|
|
37
|
+
to: string;
|
|
38
|
+
value?: string;
|
|
39
|
+
data?: string;
|
|
40
|
+
gas?: string;
|
|
41
|
+
chainId?: number;
|
|
42
|
+
walletAddress?: string;
|
|
43
|
+
}
|
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.3";
|
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.3";
|