@orbi-wallet/sdk 0.1.2 → 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 +59 -5
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +14 -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. */
|
|
@@ -108,19 +109,26 @@ class OrbiClient {
|
|
|
108
109
|
});
|
|
109
110
|
}
|
|
110
111
|
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
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.
|
|
114
116
|
*/
|
|
115
117
|
signEvmTransaction(params) {
|
|
116
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');
|
|
117
122
|
return this.openPopup({
|
|
118
123
|
path: '/sign',
|
|
119
124
|
params: {
|
|
120
125
|
chain: 'botchain',
|
|
126
|
+
evmAction: 'tx',
|
|
127
|
+
chainId: String(chainId),
|
|
121
128
|
to: params.to,
|
|
122
|
-
value: params.value,
|
|
123
|
-
|
|
129
|
+
...(params.value ? { value: params.value } : {}),
|
|
130
|
+
...(params.data ? { data: params.data } : {}),
|
|
131
|
+
...(params.gas ? { gas: params.gas } : {}),
|
|
124
132
|
...(walletAddress ? { walletAddress } : {}),
|
|
125
133
|
},
|
|
126
134
|
successType: 'orbi_evm_sent',
|
|
@@ -130,6 +138,52 @@ class OrbiClient {
|
|
|
130
138
|
}),
|
|
131
139
|
});
|
|
132
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
|
+
}
|
|
133
187
|
// ── Popup + postMessage handshake ───────────────────────────────────────────
|
|
134
188
|
openPopup(req) {
|
|
135
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,6 +6,8 @@ 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;
|
|
@@ -27,3 +29,15 @@ export interface EvmSignResult {
|
|
|
27
29
|
txHash: string;
|
|
28
30
|
walletAddress: string;
|
|
29
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";
|