@dynamic-labs/solana-core 4.0.0-alpha.46 → 4.0.0-alpha.48
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 +22 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +7 -7
- package/src/utils/SolanaUiTransaction/SolanaUiTransaction.cjs +0 -8
- package/src/utils/SolanaUiTransaction/SolanaUiTransaction.js +0 -8
- package/src/wallet/SolanaWallet.cjs +28 -0
- package/src/wallet/SolanaWallet.d.ts +10 -0
- package/src/wallet/SolanaWallet.js +29 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.0.0-alpha.48](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.47...v4.0.0-alpha.48) (2024-12-17)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* Temp disable refreshing blockhash for solana transactions ([#7638](https://github.com/dynamic-labs/dynamic-auth/issues/7638)) ([fd457bf](https://github.com/dynamic-labs/dynamic-auth/commit/fd457bf0579ad35ba17fc2c7aa18a9feb49d8c7b))
|
|
8
|
+
|
|
9
|
+
## [4.0.0-alpha.47](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.46...v4.0.0-alpha.47) (2024-12-17)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### ⚠ BREAKING CHANGES
|
|
13
|
+
|
|
14
|
+
* stop exposing authToken and minAuthToken from dynamic context (#7629)
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* allow re-linking unknown wallet when there's another account of the same wallet provider already linked ([#7628](https://github.com/dynamic-labs/dynamic-auth/issues/7628)) ([20c6dc3](https://github.com/dynamic-labs/dynamic-auth/commit/20c6dc3b1847d82bd46f0df5abaef4efe1e24e38))
|
|
19
|
+
* ensure wallet connector will not get removed ([#7625](https://github.com/dynamic-labs/dynamic-auth/issues/7625)) ([b764846](https://github.com/dynamic-labs/dynamic-auth/commit/b764846b56428e2997d33858e29a87f44359eb6c))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
* stop exposing authToken and minAuthToken from dynamic context ([#7629](https://github.com/dynamic-labs/dynamic-auth/issues/7629)) ([9648870](https://github.com/dynamic-labs/dynamic-auth/commit/9648870478cdcecde279117ada2a1095dab54e2c))
|
|
23
|
+
|
|
2
24
|
## [4.0.0-alpha.46](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.45...v4.0.0-alpha.46) (2024-12-17)
|
|
3
25
|
|
|
4
26
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/solana-core",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.48",
|
|
4
4
|
"description": "Core package for utilities and types for solana",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"@solana/spl-token": "0.4.6"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@dynamic-labs/assert-package-version": "4.0.0-alpha.
|
|
27
|
-
"@dynamic-labs/rpc-providers": "4.0.0-alpha.
|
|
28
|
-
"@dynamic-labs/types": "4.0.0-alpha.
|
|
29
|
-
"@dynamic-labs/utils": "4.0.0-alpha.
|
|
30
|
-
"@dynamic-labs/wallet-book": "4.0.0-alpha.
|
|
31
|
-
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.
|
|
26
|
+
"@dynamic-labs/assert-package-version": "4.0.0-alpha.48",
|
|
27
|
+
"@dynamic-labs/rpc-providers": "4.0.0-alpha.48",
|
|
28
|
+
"@dynamic-labs/types": "4.0.0-alpha.48",
|
|
29
|
+
"@dynamic-labs/utils": "4.0.0-alpha.48",
|
|
30
|
+
"@dynamic-labs/wallet-book": "4.0.0-alpha.48",
|
|
31
|
+
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.48",
|
|
32
32
|
"eventemitter3": "5.0.1"
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -7,7 +7,6 @@ var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
|
7
7
|
var web3_js = require('@solana/web3.js');
|
|
8
8
|
var splToken = require('@solana/spl-token');
|
|
9
9
|
var utils = require('@dynamic-labs/utils');
|
|
10
|
-
var isTransactionSigned = require('../isTransactionSigned/isTransactionSigned.cjs');
|
|
11
10
|
|
|
12
11
|
const LAMPORTS_PER_SOL = 1000000000;
|
|
13
12
|
class SolanaUiTransaction {
|
|
@@ -33,17 +32,10 @@ class SolanaUiTransaction {
|
|
|
33
32
|
return;
|
|
34
33
|
transactions = tx instanceof Array ? tx : [tx];
|
|
35
34
|
}
|
|
36
|
-
const { blockhash } = yield this.connection.getLatestBlockhash();
|
|
37
35
|
const compiledMessages = yield Promise.all(transactions.map((tx) => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
38
36
|
if ('version' in tx) {
|
|
39
|
-
if (!(yield isTransactionSigned.isTxAlreadySigned(tx))) {
|
|
40
|
-
tx.message.recentBlockhash = blockhash;
|
|
41
|
-
}
|
|
42
37
|
return tx.message;
|
|
43
38
|
}
|
|
44
|
-
if (!(yield isTransactionSigned.isTxAlreadySigned(tx))) {
|
|
45
|
-
tx.recentBlockhash = blockhash;
|
|
46
|
-
}
|
|
47
39
|
return tx.compileMessage();
|
|
48
40
|
})));
|
|
49
41
|
if (compiledMessages.some((msg) => !msg)) {
|
|
@@ -3,7 +3,6 @@ import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
|
3
3
|
import { PublicKey, Transaction, SystemProgram } from '@solana/web3.js';
|
|
4
4
|
import { getAssociatedTokenAddress, createAssociatedTokenAccountInstruction, createTransferInstruction } from '@solana/spl-token';
|
|
5
5
|
import { formatNumberText } from '@dynamic-labs/utils';
|
|
6
|
-
import { isTxAlreadySigned } from '../isTransactionSigned/isTransactionSigned.js';
|
|
7
6
|
|
|
8
7
|
const LAMPORTS_PER_SOL = 1000000000;
|
|
9
8
|
class SolanaUiTransaction {
|
|
@@ -29,17 +28,10 @@ class SolanaUiTransaction {
|
|
|
29
28
|
return;
|
|
30
29
|
transactions = tx instanceof Array ? tx : [tx];
|
|
31
30
|
}
|
|
32
|
-
const { blockhash } = yield this.connection.getLatestBlockhash();
|
|
33
31
|
const compiledMessages = yield Promise.all(transactions.map((tx) => __awaiter(this, void 0, void 0, function* () {
|
|
34
32
|
if ('version' in tx) {
|
|
35
|
-
if (!(yield isTxAlreadySigned(tx))) {
|
|
36
|
-
tx.message.recentBlockhash = blockhash;
|
|
37
|
-
}
|
|
38
33
|
return tx.message;
|
|
39
34
|
}
|
|
40
|
-
if (!(yield isTxAlreadySigned(tx))) {
|
|
41
|
-
tx.recentBlockhash = blockhash;
|
|
42
|
-
}
|
|
43
35
|
return tx.compileMessage();
|
|
44
36
|
})));
|
|
45
37
|
if (compiledMessages.some((msg) => !msg)) {
|
|
@@ -4,10 +4,38 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
|
+
var web3_js = require('@solana/web3.js');
|
|
7
8
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
9
|
var utils = require('@dynamic-labs/utils');
|
|
9
10
|
|
|
10
11
|
class SolanaWallet extends walletConnectorCore.Wallet {
|
|
12
|
+
/**
|
|
13
|
+
* Sends the native balance of the wallet to the given address.
|
|
14
|
+
* @param amount - The amount of balance to send (in SOL).
|
|
15
|
+
* @param toAddress - The address to send the balance to.
|
|
16
|
+
* @returns The signature of the sent transaction.
|
|
17
|
+
*/
|
|
18
|
+
sendBalance(_a) {
|
|
19
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ amount, toAddress, }) {
|
|
20
|
+
const connection = yield this.getConnection();
|
|
21
|
+
const signer = yield this.getSigner();
|
|
22
|
+
const { blockhash } = yield connection.getLatestBlockhash('finalized');
|
|
23
|
+
const message = new web3_js.TransactionMessage({
|
|
24
|
+
instructions: [
|
|
25
|
+
web3_js.SystemProgram.transfer({
|
|
26
|
+
fromPubkey: new web3_js.PublicKey(this.address),
|
|
27
|
+
lamports: utils.solToLamports(Number(amount)),
|
|
28
|
+
toPubkey: new web3_js.PublicKey(toAddress),
|
|
29
|
+
}),
|
|
30
|
+
],
|
|
31
|
+
payerKey: new web3_js.PublicKey(this.address),
|
|
32
|
+
recentBlockhash: blockhash,
|
|
33
|
+
}).compileToV0Message();
|
|
34
|
+
const transaction = new web3_js.VersionedTransaction(message);
|
|
35
|
+
const { signature } = yield signer.signAndSendTransaction(transaction);
|
|
36
|
+
return signature;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
11
39
|
/**
|
|
12
40
|
* Retrieves the RPC connection
|
|
13
41
|
* @returns A promise that resolves to the RPC connection
|
|
@@ -3,6 +3,16 @@ import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
|
3
3
|
import { SolanaWalletConnector } from '../connector';
|
|
4
4
|
import { ISolana } from '../types';
|
|
5
5
|
export declare class SolanaWallet extends Wallet<SolanaWalletConnector> {
|
|
6
|
+
/**
|
|
7
|
+
* Sends the native balance of the wallet to the given address.
|
|
8
|
+
* @param amount - The amount of balance to send (in SOL).
|
|
9
|
+
* @param toAddress - The address to send the balance to.
|
|
10
|
+
* @returns The signature of the sent transaction.
|
|
11
|
+
*/
|
|
12
|
+
sendBalance({ amount, toAddress, }: {
|
|
13
|
+
amount: string;
|
|
14
|
+
toAddress: string;
|
|
15
|
+
}): Promise<string | undefined>;
|
|
6
16
|
/**
|
|
7
17
|
* Retrieves the RPC connection
|
|
8
18
|
* @returns A promise that resolves to the RPC connection
|
|
@@ -1,9 +1,37 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
|
+
import { TransactionMessage, SystemProgram, PublicKey, VersionedTransaction } from '@solana/web3.js';
|
|
3
4
|
import { Wallet, logger } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
-
import { cloneObjectWithOverrides } from '@dynamic-labs/utils';
|
|
5
|
+
import { solToLamports, cloneObjectWithOverrides } from '@dynamic-labs/utils';
|
|
5
6
|
|
|
6
7
|
class SolanaWallet extends Wallet {
|
|
8
|
+
/**
|
|
9
|
+
* Sends the native balance of the wallet to the given address.
|
|
10
|
+
* @param amount - The amount of balance to send (in SOL).
|
|
11
|
+
* @param toAddress - The address to send the balance to.
|
|
12
|
+
* @returns The signature of the sent transaction.
|
|
13
|
+
*/
|
|
14
|
+
sendBalance(_a) {
|
|
15
|
+
return __awaiter(this, arguments, void 0, function* ({ amount, toAddress, }) {
|
|
16
|
+
const connection = yield this.getConnection();
|
|
17
|
+
const signer = yield this.getSigner();
|
|
18
|
+
const { blockhash } = yield connection.getLatestBlockhash('finalized');
|
|
19
|
+
const message = new TransactionMessage({
|
|
20
|
+
instructions: [
|
|
21
|
+
SystemProgram.transfer({
|
|
22
|
+
fromPubkey: new PublicKey(this.address),
|
|
23
|
+
lamports: solToLamports(Number(amount)),
|
|
24
|
+
toPubkey: new PublicKey(toAddress),
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
payerKey: new PublicKey(this.address),
|
|
28
|
+
recentBlockhash: blockhash,
|
|
29
|
+
}).compileToV0Message();
|
|
30
|
+
const transaction = new VersionedTransaction(message);
|
|
31
|
+
const { signature } = yield signer.signAndSendTransaction(transaction);
|
|
32
|
+
return signature;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
7
35
|
/**
|
|
8
36
|
* Retrieves the RPC connection
|
|
9
37
|
* @returns A promise that resolves to the RPC connection
|