@dynamic-labs/solana 0.19.0-alpha.25 → 0.19.0-alpha.26
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/CHANGELOG.md +15 -0
- package/package.json +6 -6
- package/src/index.cjs +4 -0
- package/src/index.d.ts +3 -0
- package/src/index.js +2 -0
- package/src/injected/BackpackSol.cjs +4 -1
- package/src/injected/BackpackSol.d.ts +2 -2
- package/src/injected/BackpackSol.js +4 -1
- package/src/injected/InjectedWalletBase.d.ts +2 -2
- package/src/solProviderHelper.cjs +6 -2
- package/src/solProviderHelper.d.ts +0 -3
- package/src/solProviderHelper.js +6 -2
- package/src/solWalletConnector.cjs +1 -1
- package/src/solWalletConnector.js +1 -1
- package/src/types.d.ts +29 -15
- package/src/utils/isBackpackSolanaSigner.cjs +7 -0
- package/src/utils/isBackpackSolanaSigner.d.ts +2 -0
- package/src/utils/isBackpackSolanaSigner.js +3 -0
- package/src/utils/isSignedMessage.cjs +7 -0
- package/src/utils/isSignedMessage.d.ts +2 -0
- package/src/utils/isSignedMessage.js +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
|
|
2
|
+
## [0.19.0-alpha.26](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.0-alpha.25...v0.19.0-alpha.26) (2023-10-25)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* allow filtering social providers for Dynamic Social with socialProvidersFilter ([#3707](https://github.com/dynamic-labs/DynamicAuth/issues/3707)) ([e4c16f3](https://github.com/dynamic-labs/DynamicAuth/commit/e4c16f359946e278a372cb8153242946d4887dcc))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* only create embedded wallet if user have no wallet ([#3715](https://github.com/dynamic-labs/DynamicAuth/issues/3715)) ([728e01a](https://github.com/dynamic-labs/DynamicAuth/commit/728e01ab8b5931eaa6fb7877c23847ac85947f52))
|
|
13
|
+
* Revert "fix(use-wallet-event-listener): handle switching wallet … ([#3699](https://github.com/dynamic-labs/DynamicAuth/issues/3699)) ([9b94737](https://github.com/dynamic-labs/DynamicAuth/commit/9b94737ecfa72cd047964254d806403b342433a1)), closes [#3626](https://github.com/dynamic-labs/DynamicAuth/issues/3626)
|
|
14
|
+
* undefined network edge case ([#3667](https://github.com/dynamic-labs/DynamicAuth/issues/3667)) ([12d4236](https://github.com/dynamic-labs/DynamicAuth/commit/12d42363f69b1dfd5babe05142bd03c501f62e5f))
|
|
15
|
+
* **useOnClickOutside:** prevent opening element on click while already open ([#3714](https://github.com/dynamic-labs/DynamicAuth/issues/3714)) ([1999dc5](https://github.com/dynamic-labs/DynamicAuth/commit/1999dc50b6e82eb5ee8d0919118e9dfbc39c2b67))
|
|
16
|
+
|
|
2
17
|
## [0.19.0-alpha.25](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.0-alpha.24...v0.19.0-alpha.25) (2023-10-25)
|
|
3
18
|
|
|
4
19
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/solana",
|
|
3
|
-
"version": "0.19.0-alpha.
|
|
3
|
+
"version": "0.19.0-alpha.26",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@solana/web3.js": "1.70.1",
|
|
30
|
-
"@dynamic-labs/rpc-providers": "0.19.0-alpha.
|
|
31
|
-
"@dynamic-labs/types": "0.19.0-alpha.
|
|
32
|
-
"@dynamic-labs/utils": "0.19.0-alpha.
|
|
33
|
-
"@dynamic-labs/wallet-book": "0.19.0-alpha.
|
|
34
|
-
"@dynamic-labs/wallet-connector-core": "0.19.0-alpha.
|
|
30
|
+
"@dynamic-labs/rpc-providers": "0.19.0-alpha.26",
|
|
31
|
+
"@dynamic-labs/types": "0.19.0-alpha.26",
|
|
32
|
+
"@dynamic-labs/utils": "0.19.0-alpha.26",
|
|
33
|
+
"@dynamic-labs/wallet-book": "0.19.0-alpha.26",
|
|
34
|
+
"@dynamic-labs/wallet-connector-core": "0.19.0-alpha.26",
|
|
35
35
|
"eventemitter3": "5.0.1"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {}
|
package/src/index.cjs
CHANGED
|
@@ -9,6 +9,8 @@ var Solflare = require('./Solflare.cjs');
|
|
|
9
9
|
var index = require('./injected/index.cjs');
|
|
10
10
|
var solWalletConnector = require('./solWalletConnector.cjs');
|
|
11
11
|
var solProviderHelper = require('./solProviderHelper.cjs');
|
|
12
|
+
var isSignedMessage = require('./utils/isSignedMessage.cjs');
|
|
13
|
+
var isBackpackSolanaSigner = require('./utils/isBackpackSolanaSigner.cjs');
|
|
12
14
|
|
|
13
15
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
14
16
|
const SolanaWalletConnectors = (props) => [
|
|
@@ -21,4 +23,6 @@ const SolanaWalletConnectors = (props) => [
|
|
|
21
23
|
|
|
22
24
|
exports.SolWalletConnector = solWalletConnector.SolWalletConnector;
|
|
23
25
|
exports.SolProviderHelper = solProviderHelper.SolProviderHelper;
|
|
26
|
+
exports.isSignedMessage = isSignedMessage.isSignedMessage;
|
|
27
|
+
exports.isBackpackSolanaSigner = isBackpackSolanaSigner.isBackpackSolanaSigner;
|
|
24
28
|
exports.SolanaWalletConnectors = SolanaWalletConnectors;
|
package/src/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export * from './solWalletConnector';
|
|
2
2
|
export * from './solProviderHelper';
|
|
3
3
|
export declare const SolanaWalletConnectors: (props: any) => typeof import("./injected/BraveSol").BraveSol[];
|
|
4
|
+
export { isSignedMessage } from './utils/isSignedMessage';
|
|
5
|
+
export { isBackpackSolanaSigner } from './utils/isBackpackSolanaSigner';
|
|
6
|
+
export type { ISolana, IBackpackSolanaSigner, SignedMessage, ISolanaSigner, } from './types';
|
package/src/index.js
CHANGED
|
@@ -5,6 +5,8 @@ import { Solflare } from './Solflare.js';
|
|
|
5
5
|
import { injectedWallets } from './injected/index.js';
|
|
6
6
|
export { SolWalletConnector } from './solWalletConnector.js';
|
|
7
7
|
export { SolProviderHelper } from './solProviderHelper.js';
|
|
8
|
+
export { isSignedMessage } from './utils/isSignedMessage.js';
|
|
9
|
+
export { isBackpackSolanaSigner } from './utils/isBackpackSolanaSigner.js';
|
|
8
10
|
|
|
9
11
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
10
12
|
const SolanaWalletConnectors = (props) => [
|
|
@@ -39,7 +39,10 @@ class BackpackSol extends InjectedWalletBase.InjectedWalletBase {
|
|
|
39
39
|
if (!provider) {
|
|
40
40
|
return undefined;
|
|
41
41
|
}
|
|
42
|
-
const signedMessage =
|
|
42
|
+
const signedMessage = yield provider.signMessage(Buffer.from(messageToSign, 'utf8'));
|
|
43
|
+
if (!signedMessage) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
43
46
|
return utils.bufferToBase64(signedMessage);
|
|
44
47
|
});
|
|
45
48
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IBackpackSolanaSigner } from '../types';
|
|
2
2
|
import { InjectedWalletBase } from './InjectedWalletBase';
|
|
3
3
|
export declare class BackpackSol extends InjectedWalletBase {
|
|
4
4
|
name: string;
|
|
5
5
|
setupEventListeners(): void;
|
|
6
6
|
fetchPublicAddress(): Promise<string | undefined>;
|
|
7
|
-
getSigner(): Promise<
|
|
7
|
+
getSigner(): Promise<IBackpackSolanaSigner | undefined>;
|
|
8
8
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
9
9
|
getConnectedAccounts(): Promise<string[]>;
|
|
10
10
|
}
|
|
@@ -35,7 +35,10 @@ class BackpackSol extends InjectedWalletBase {
|
|
|
35
35
|
if (!provider) {
|
|
36
36
|
return undefined;
|
|
37
37
|
}
|
|
38
|
-
const signedMessage =
|
|
38
|
+
const signedMessage = yield provider.signMessage(Buffer.from(messageToSign, 'utf8'));
|
|
39
|
+
if (!signedMessage) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
39
42
|
return bufferToBase64(signedMessage);
|
|
40
43
|
});
|
|
41
44
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SolWalletConnector } from '../solWalletConnector';
|
|
2
|
-
import {
|
|
2
|
+
import { ISolana } from '../types';
|
|
3
3
|
export declare abstract class InjectedWalletBase extends SolWalletConnector {
|
|
4
4
|
setupEventListeners(): void;
|
|
5
5
|
teardownEventListeners(): void;
|
|
6
6
|
connect(): Promise<void>;
|
|
7
|
-
getSigner(): Promise<ISolana |
|
|
7
|
+
getSigner(): Promise<ISolana | undefined>;
|
|
8
8
|
isInstalledOnBrowser(): boolean;
|
|
9
9
|
fetchPublicAddress(): Promise<string | undefined>;
|
|
10
10
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _tslib = require('../_virtual/_tslib.cjs');
|
|
6
6
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
7
7
|
var utils = require('@dynamic-labs/utils');
|
|
8
|
+
var isSignedMessage = require('./utils/isSignedMessage.cjs');
|
|
8
9
|
|
|
9
10
|
var _a;
|
|
10
11
|
class SolProviderHelper {
|
|
@@ -77,8 +78,11 @@ class SolProviderHelper {
|
|
|
77
78
|
yield provider.connect();
|
|
78
79
|
}
|
|
79
80
|
const encodedMessage = new TextEncoder().encode(messageToSign);
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
const signedMessage = yield provider.signMessage(encodedMessage, 'utf8');
|
|
82
|
+
if (!signedMessage) {
|
|
83
|
+
return Promise.resolve(undefined);
|
|
84
|
+
}
|
|
85
|
+
return utils.bufferToBase64(isSignedMessage.isSignedMessage(signedMessage) ? signedMessage.signature : signedMessage);
|
|
82
86
|
});
|
|
83
87
|
}
|
|
84
88
|
static _setupEventListeners(walletConnector, web3Provider) {
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { ProviderCondition, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
2
2
|
import { ISolana, ProviderFlag } from './types';
|
|
3
|
-
export interface SignedMessage {
|
|
4
|
-
signature: Uint8Array;
|
|
5
|
-
}
|
|
6
3
|
type Provider = () => ISolana | undefined;
|
|
7
4
|
export type AccountChangeEventHandler = (address: {
|
|
8
5
|
toString(): string;
|
package/src/solProviderHelper.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from '../_virtual/_tslib.js';
|
|
2
2
|
import { ProviderLookup, normalizeWalletName } from '@dynamic-labs/wallet-connector-core';
|
|
3
3
|
import { bufferToBase64 } from '@dynamic-labs/utils';
|
|
4
|
+
import { isSignedMessage } from './utils/isSignedMessage.js';
|
|
4
5
|
|
|
5
6
|
var _a;
|
|
6
7
|
class SolProviderHelper {
|
|
@@ -73,8 +74,11 @@ class SolProviderHelper {
|
|
|
73
74
|
yield provider.connect();
|
|
74
75
|
}
|
|
75
76
|
const encodedMessage = new TextEncoder().encode(messageToSign);
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
const signedMessage = yield provider.signMessage(encodedMessage, 'utf8');
|
|
78
|
+
if (!signedMessage) {
|
|
79
|
+
return Promise.resolve(undefined);
|
|
80
|
+
}
|
|
81
|
+
return bufferToBase64(isSignedMessage(signedMessage) ? signedMessage.signature : signedMessage);
|
|
78
82
|
});
|
|
79
83
|
}
|
|
80
84
|
static _setupEventListeners(walletConnector, web3Provider) {
|
|
@@ -76,7 +76,7 @@ class SolWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
76
76
|
getBalance() {
|
|
77
77
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
78
78
|
const signer = yield this.getSigner();
|
|
79
|
-
if (!signer)
|
|
79
|
+
if (!signer || !signer.publicKey)
|
|
80
80
|
return;
|
|
81
81
|
const publicKey = new web3_js.PublicKey(signer.publicKey.toString());
|
|
82
82
|
const balance = this.lamportsToSol(yield this.getWalletClient().getBalance(publicKey));
|
|
@@ -72,7 +72,7 @@ class SolWalletConnector extends WalletConnectorBase {
|
|
|
72
72
|
getBalance() {
|
|
73
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
74
|
const signer = yield this.getSigner();
|
|
75
|
-
if (!signer)
|
|
75
|
+
if (!signer || !signer.publicKey)
|
|
76
76
|
return;
|
|
77
77
|
const publicKey = new PublicKey(signer.publicKey.toString());
|
|
78
78
|
const balance = this.lamportsToSol(yield this.getWalletClient().getBalance(publicKey));
|
package/src/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Connection, SendOptions, Signer, Transaction, TransactionSignature } from '@solana/web3.js';
|
|
1
|
+
import { Connection, SendOptions, Signer, Transaction, TransactionSignature, VersionedTransaction } from '@solana/web3.js';
|
|
2
|
+
import EventEmitter from 'eventemitter3';
|
|
2
3
|
import { ProviderCondition } from '@dynamic-labs/wallet-connector-core';
|
|
3
4
|
declare global {
|
|
4
5
|
interface IWindowPhantom {
|
|
@@ -13,7 +14,7 @@ declare global {
|
|
|
13
14
|
phantom?: IWindowPhantom;
|
|
14
15
|
solana?: ISolana;
|
|
15
16
|
solflare?: ISolana;
|
|
16
|
-
backpack?:
|
|
17
|
+
backpack?: IBackpackSolanaSigner;
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
type PublicKey = {
|
|
@@ -23,26 +24,39 @@ export type ConnectionResult = {
|
|
|
23
24
|
address?: string;
|
|
24
25
|
publicKey?: PublicKey;
|
|
25
26
|
} | undefined;
|
|
26
|
-
|
|
27
|
+
interface ISolanaEvents {
|
|
28
|
+
connect(...args: unknown[]): unknown;
|
|
29
|
+
disconnect(...args: unknown[]): unknown;
|
|
30
|
+
accountChanged(publicKey: string): unknown;
|
|
31
|
+
activeWalletDidChange(publicKey: string): unknown;
|
|
32
|
+
}
|
|
33
|
+
export type SignedMessage = {
|
|
34
|
+
signature: Uint8Array;
|
|
35
|
+
};
|
|
36
|
+
export type ISolanaSigner = {
|
|
27
37
|
[key in ProviderFlag]: boolean;
|
|
28
|
-
} & {
|
|
38
|
+
} & EventEmitter<ISolanaEvents> & {
|
|
39
|
+
publicKey?: {
|
|
40
|
+
toBytes(): Uint8Array;
|
|
41
|
+
};
|
|
42
|
+
isConnected: boolean;
|
|
43
|
+
providers: ISolanaSigner[];
|
|
44
|
+
signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T>;
|
|
45
|
+
signAllTransactions<T extends Transaction | VersionedTransaction>(transactions: T[]): Promise<T[]>;
|
|
46
|
+
signAndSendTransaction<T extends Transaction | VersionedTransaction>(transaction: T, options?: SendOptions): Promise<{
|
|
47
|
+
signature: TransactionSignature;
|
|
48
|
+
}>;
|
|
49
|
+
signMessage(message: Uint8Array, encoding?: string): Promise<SignedMessage>;
|
|
29
50
|
connect: (args?: {
|
|
30
51
|
onlyIfTrusted: boolean;
|
|
31
52
|
}) => Promise<ConnectionResult>;
|
|
32
|
-
disconnect
|
|
33
|
-
on: (eventMessage: string, callback?: (publickey: string) => void) => Promise<void | object>;
|
|
34
|
-
providers: object[];
|
|
35
|
-
publicKey: PublicKey;
|
|
36
|
-
removeAllListeners: () => void;
|
|
37
|
-
removeListener: (eventMessage: string, callback?: (publickey: string) => void) => Promise<void | object>;
|
|
38
|
-
signMessage: (message: Uint8Array, encoding?: string) => Promise<void | object>;
|
|
39
|
-
signTransaction: (transaction: Transaction) => Promise<Transaction>;
|
|
40
|
-
isConnected?: boolean;
|
|
53
|
+
disconnect(): Promise<void>;
|
|
41
54
|
};
|
|
42
|
-
export type
|
|
43
|
-
signMessage: (message: Uint8Array,
|
|
55
|
+
export type IBackpackSolanaSigner = Omit<ISolanaSigner, 'signMessage'> & {
|
|
56
|
+
signMessage: (message: Uint8Array, encoding?: string) => Promise<void | Uint8Array>;
|
|
44
57
|
send: (transaction: Transaction, signers?: Signer[], options?: SendOptions, connection?: Connection, publicKey?: PublicKey) => Promise<TransactionSignature>;
|
|
45
58
|
};
|
|
59
|
+
export type ISolana = ISolanaSigner | IBackpackSolanaSigner;
|
|
46
60
|
export type ProviderFlag = 'isBraveWallet' | 'isGlow' | 'isPhantom' | 'isSolflare' | 'isExodus' | 'isBackpack';
|
|
47
61
|
export type EthProviderCondition = ProviderCondition<ProviderFlag>;
|
|
48
62
|
export {};
|