@pooflabs/web 0.0.4 → 0.0.6
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/global.d.ts +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +63 -10
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +63 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/global.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ClientConfig } from './client/config';
|
|
2
2
|
import { User } from './types';
|
|
3
|
+
import { Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
3
4
|
export declare function init(newConfig: Partial<ClientConfig>): Promise<void>;
|
|
4
5
|
export declare function onAuthStateChanged(callback: (user: User | null) => void): void;
|
|
5
6
|
export declare function login(): Promise<User | null>;
|
|
6
7
|
export declare function logout(): Promise<void>;
|
|
7
8
|
export declare function setCurrentUser(user: User | null): void;
|
|
8
9
|
export declare function getCurrentUser(): User | null;
|
|
10
|
+
export declare function signTransaction(transaction: Transaction | VersionedTransaction): Promise<Transaction | VersionedTransaction>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { init, getCurrentUser, onAuthStateChanged, login, logout } from "./global";
|
|
1
|
+
export { init, getCurrentUser, onAuthStateChanged, login, logout, signTransaction } from "./global";
|
|
2
2
|
export { getConfig } from './client/config';
|
|
3
3
|
export { getAuthProvider, deserializeTransaction } from './auth';
|
|
4
4
|
export { get, set, setMany, setFile, getFiles, runQuery, runQueryMany, syncItems } from './client/operations';
|
package/dist/index.esm.js
CHANGED
|
@@ -4154,7 +4154,7 @@ class PhantomWalletProvider {
|
|
|
4154
4154
|
}
|
|
4155
4155
|
}
|
|
4156
4156
|
async runTransaction(evmTransactionData, solTransactionData, options) {
|
|
4157
|
-
var _a;
|
|
4157
|
+
var _a, _b, _c, _d, _e;
|
|
4158
4158
|
if (!solTransactionData) {
|
|
4159
4159
|
throw new Error("Solana transaction data is required for Phantom wallet");
|
|
4160
4160
|
}
|
|
@@ -4243,7 +4243,15 @@ class PhantomWalletProvider {
|
|
|
4243
4243
|
};
|
|
4244
4244
|
}
|
|
4245
4245
|
catch (error) {
|
|
4246
|
-
|
|
4246
|
+
// Check if this is a user rejection (don't log these as errors)
|
|
4247
|
+
const isUserRejection = (error === null || error === void 0 ? void 0 : error.code) === 4001 ||
|
|
4248
|
+
((_b = error === null || error === void 0 ? void 0 : error.message) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes('user rejected')) ||
|
|
4249
|
+
((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.toLowerCase().includes('user denied')) ||
|
|
4250
|
+
((_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes('user cancelled')) ||
|
|
4251
|
+
((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.toLowerCase().includes('user canceled'));
|
|
4252
|
+
if (!isUserRejection) {
|
|
4253
|
+
console.error('Failed to execute transaction', error);
|
|
4254
|
+
}
|
|
4247
4255
|
throw new Error(`Failed to execute transaction: ${error.message}`);
|
|
4248
4256
|
}
|
|
4249
4257
|
}
|
|
@@ -4265,6 +4273,7 @@ class PhantomWalletProvider {
|
|
|
4265
4273
|
}
|
|
4266
4274
|
}
|
|
4267
4275
|
async signMessage(message) {
|
|
4276
|
+
var _a, _b, _c, _d;
|
|
4268
4277
|
try {
|
|
4269
4278
|
// Use ensureConnected to auto-connect if needed
|
|
4270
4279
|
const provider = await this.ensureConnected();
|
|
@@ -4285,7 +4294,15 @@ class PhantomWalletProvider {
|
|
|
4285
4294
|
return Buffer.from(signatureResponse.signature).toString('base64');
|
|
4286
4295
|
}
|
|
4287
4296
|
catch (error) {
|
|
4288
|
-
|
|
4297
|
+
// Check if this is a user rejection (don't log these as errors)
|
|
4298
|
+
const isUserRejection = (error === null || error === void 0 ? void 0 : error.code) === 4001 ||
|
|
4299
|
+
((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('user rejected')) ||
|
|
4300
|
+
((_b = error === null || error === void 0 ? void 0 : error.message) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes('user denied')) ||
|
|
4301
|
+
((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.toLowerCase().includes('user cancelled')) ||
|
|
4302
|
+
((_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes('user canceled'));
|
|
4303
|
+
if (!isUserRejection) {
|
|
4304
|
+
console.error('Failed to sign message', error);
|
|
4305
|
+
}
|
|
4289
4306
|
throw new Error('Failed to sign message');
|
|
4290
4307
|
}
|
|
4291
4308
|
}
|
|
@@ -19449,6 +19466,7 @@ class PrivyWalletProvider {
|
|
|
19449
19466
|
const useOAuthTokens = privyImports.useOAuthTokens();
|
|
19450
19467
|
const useFundWalletSolana = privySolana.useFundWallet();
|
|
19451
19468
|
const useSendTransactionSolana = privySolana.useSendTransaction();
|
|
19469
|
+
const { signTransaction } = privySolana.useSignTransaction();
|
|
19452
19470
|
const useSolanaWallets = privySolana.useSolanaWallets();
|
|
19453
19471
|
const useIdentityToken = privyImports.useIdentityToken();
|
|
19454
19472
|
const { createWallet, wallets, ready: walletReady } = privySolana.useSolanaWallets();
|
|
@@ -19469,7 +19487,10 @@ class PrivyWalletProvider {
|
|
|
19469
19487
|
}
|
|
19470
19488
|
},
|
|
19471
19489
|
onError: (error) => {
|
|
19472
|
-
|
|
19490
|
+
// Only log errors that aren't user-initiated cancellations
|
|
19491
|
+
if (error !== 'exited_auth_flow' && (error === null || error === void 0 ? void 0 : error.message) !== 'exited_auth_flow') {
|
|
19492
|
+
console.error('Wallet connection error:', error);
|
|
19493
|
+
}
|
|
19473
19494
|
if (that.pendingTransaction) {
|
|
19474
19495
|
that.pendingTransaction.reject(error);
|
|
19475
19496
|
that.pendingTransaction = null;
|
|
@@ -19515,7 +19536,10 @@ class PrivyWalletProvider {
|
|
|
19515
19536
|
}
|
|
19516
19537
|
},
|
|
19517
19538
|
onError: (error) => {
|
|
19518
|
-
|
|
19539
|
+
// Only log errors that aren't user-initiated cancellations
|
|
19540
|
+
if (error !== 'exited_auth_flow' && (error === null || error === void 0 ? void 0 : error.message) !== 'exited_auth_flow') {
|
|
19541
|
+
console.error('Login error:', error);
|
|
19542
|
+
}
|
|
19519
19543
|
if (that.pendingLogin) {
|
|
19520
19544
|
that.pendingLogin.reject(error);
|
|
19521
19545
|
that.pendingLogin = null;
|
|
@@ -19544,6 +19568,7 @@ class PrivyWalletProvider {
|
|
|
19544
19568
|
useFundWalletSolana: useFundWalletSolana,
|
|
19545
19569
|
useSendTransactionSolana: useSendTransactionSolana,
|
|
19546
19570
|
useSolanaWallets: useSolanaWallets,
|
|
19571
|
+
signTransaction: signTransaction,
|
|
19547
19572
|
};
|
|
19548
19573
|
}
|
|
19549
19574
|
}, [privy.ready, privy.authenticated, wallets, login, logout, walletReady]);
|
|
@@ -19608,7 +19633,7 @@ class PrivyWalletProvider {
|
|
|
19608
19633
|
await this.privyMethods.logout();
|
|
19609
19634
|
}
|
|
19610
19635
|
async runTransaction(_evmTransactionData, solTransactionData, options) {
|
|
19611
|
-
var _a;
|
|
19636
|
+
var _a, _b, _c;
|
|
19612
19637
|
await this.ensureReady();
|
|
19613
19638
|
let session = await SessionManager.getSession();
|
|
19614
19639
|
let sessionAddress = session === null || session === void 0 ? void 0 : session.address;
|
|
@@ -19677,7 +19702,11 @@ class PrivyWalletProvider {
|
|
|
19677
19702
|
}
|
|
19678
19703
|
try {
|
|
19679
19704
|
if ((options === null || options === void 0 ? void 0 : options.shouldSubmitTx) === false) {
|
|
19680
|
-
const signedTx = await
|
|
19705
|
+
const signedTx = await ((_b = this.privyMethods) === null || _b === void 0 ? void 0 : _b.signTransaction({
|
|
19706
|
+
transaction: tx,
|
|
19707
|
+
connection,
|
|
19708
|
+
address: wallet.address.toString(),
|
|
19709
|
+
}));
|
|
19681
19710
|
return {
|
|
19682
19711
|
signedTransaction: signedTx,
|
|
19683
19712
|
blockNumber: 0,
|
|
@@ -19685,7 +19714,19 @@ class PrivyWalletProvider {
|
|
|
19685
19714
|
data: ""
|
|
19686
19715
|
};
|
|
19687
19716
|
}
|
|
19688
|
-
const
|
|
19717
|
+
const isSurfnet = connection.rpcEndpoint === SURFNET_RPC_URL;
|
|
19718
|
+
let txSignature;
|
|
19719
|
+
if (isSurfnet) {
|
|
19720
|
+
const signedTx = await ((_c = this.privyMethods) === null || _c === void 0 ? void 0 : _c.signTransaction({
|
|
19721
|
+
transaction: tx,
|
|
19722
|
+
connection,
|
|
19723
|
+
address: wallet.address.toString(),
|
|
19724
|
+
}));
|
|
19725
|
+
txSignature = await connection.sendRawTransaction(signedTx.serialize());
|
|
19726
|
+
}
|
|
19727
|
+
else {
|
|
19728
|
+
txSignature = await privyWallet.sendTransaction(tx, connection);
|
|
19729
|
+
}
|
|
19689
19730
|
return {
|
|
19690
19731
|
transactionSignature: txSignature,
|
|
19691
19732
|
blockNumber: 0,
|
|
@@ -20055,6 +20096,15 @@ function setCurrentUser(user) {
|
|
|
20055
20096
|
function getCurrentUser() {
|
|
20056
20097
|
return currentUser;
|
|
20057
20098
|
}
|
|
20099
|
+
async function signTransaction(transaction) {
|
|
20100
|
+
if (!authProviderInstance) {
|
|
20101
|
+
authProviderInstance = await getAuthProvider();
|
|
20102
|
+
}
|
|
20103
|
+
if (!currentUser) {
|
|
20104
|
+
throw new Error('No user logged in. Please call login() first.');
|
|
20105
|
+
}
|
|
20106
|
+
return await authProviderInstance.signTransaction(transaction);
|
|
20107
|
+
}
|
|
20058
20108
|
|
|
20059
20109
|
// Cache for get responses
|
|
20060
20110
|
const getCache = {};
|
|
@@ -21143,7 +21193,10 @@ function useAuth() {
|
|
|
21143
21193
|
setUser(user);
|
|
21144
21194
|
}
|
|
21145
21195
|
catch (error) {
|
|
21146
|
-
|
|
21196
|
+
// Only log errors that aren't user-initiated cancellations
|
|
21197
|
+
if (error !== 'exited_auth_flow' && (error === null || error === void 0 ? void 0 : error.message) !== 'exited_auth_flow') {
|
|
21198
|
+
console.error('Error logging in:', error);
|
|
21199
|
+
}
|
|
21147
21200
|
setUser(null);
|
|
21148
21201
|
}
|
|
21149
21202
|
finally {
|
|
@@ -21171,5 +21224,5 @@ function useAuth() {
|
|
|
21171
21224
|
};
|
|
21172
21225
|
}
|
|
21173
21226
|
|
|
21174
|
-
export { deserializeTransaction, get, getAuthProvider, getConfig, getCurrentUser, getFiles, getIdToken, init, login, logout, onAuthStateChanged, runQuery, runQueryMany, set, setFile, setMany, subscribe, syncItems, useAuth };
|
|
21227
|
+
export { deserializeTransaction, get, getAuthProvider, getConfig, getCurrentUser, getFiles, getIdToken, init, login, logout, onAuthStateChanged, runQuery, runQueryMany, set, setFile, setMany, signTransaction, subscribe, syncItems, useAuth };
|
|
21175
21228
|
//# sourceMappingURL=index.esm.js.map
|