@dynamic-labs/solana-core 5.7.0 → 5.8.0
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 +14 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +7 -7
- package/src/index.cjs +2 -0
- package/src/index.js +1 -0
- package/src/utils/createAssociatedTokenAccountTransaction/createAssociatedTokenAccountTransaction.cjs +40 -0
- package/src/utils/createAssociatedTokenAccountTransaction/createAssociatedTokenAccountTransaction.d.ts +15 -0
- package/src/utils/createAssociatedTokenAccountTransaction/createAssociatedTokenAccountTransaction.js +36 -0
- package/src/utils/createAssociatedTokenAccountTransaction/index.d.ts +1 -0
- package/src/utils/index.d.ts +1 -0
- package/src/wallet/SolanaWallet.cjs +29 -0
- package/src/wallet/SolanaWallet.d.ts +12 -0
- package/src/wallet/SolanaWallet.js +29 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
|
|
2
|
+
## [5.8.0](https://github.com/dynamic-labs/dynamic-auth/compare/v5.7.0...v5.8.0) (2026-09-09)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **solana-core:** standalone sponsored ATA creation ([#12365](https://github.com/dynamic-labs/dynamic-auth/issues/12365)) ([ac2e776](https://github.com/dynamic-labs/dynamic-auth/commit/ac2e7769fcf91c868e961a227b8acb6347bf3f13))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* do not report wallets installed from a provider selection router ([#12340](https://github.com/dynamic-labs/dynamic-auth/issues/12340)) ([dac5546](https://github.com/dynamic-labs/dynamic-auth/commit/dac5546edf6004c37bd84dd2089d94952949230b))
|
|
13
|
+
* **screening:** soften the blocked-wallet copy to be provider-neutral ([#12358](https://github.com/dynamic-labs/dynamic-auth/issues/12358)) ([b4854d8](https://github.com/dynamic-labs/dynamic-auth/commit/b4854d88fa67f684be0e133edd5fd4a4bf5c7f37))
|
|
14
|
+
* show transaction amount when simulation returns no transfers ([#12355](https://github.com/dynamic-labs/dynamic-auth/issues/12355)) ([bfaf337](https://github.com/dynamic-labs/dynamic-auth/commit/bfaf337e5350970f71255baff065e0cdbccdc7ca))
|
|
15
|
+
|
|
2
16
|
## [5.7.0](https://github.com/dynamic-labs/dynamic-auth/compare/v5.6.1...v5.7.0) (2026-09-08)
|
|
3
17
|
|
|
4
18
|
|
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": "5.
|
|
3
|
+
"version": "5.8.0",
|
|
4
4
|
"description": "Core package for utilities and types for solana",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@dynamic-labs/sdk-api-core": "0.32.0",
|
|
22
|
-
"@dynamic-labs/utils": "5.
|
|
22
|
+
"@dynamic-labs/utils": "5.8.0",
|
|
23
23
|
"@solana/web3.js": "1.98.1",
|
|
24
24
|
"@solana/spl-token": "0.4.14",
|
|
25
|
-
"@dynamic-labs/assert-package-version": "5.
|
|
26
|
-
"@dynamic-labs/rpc-providers": "5.
|
|
27
|
-
"@dynamic-labs/types": "5.
|
|
28
|
-
"@dynamic-labs/wallet-book": "5.
|
|
29
|
-
"@dynamic-labs/wallet-connector-core": "5.
|
|
25
|
+
"@dynamic-labs/assert-package-version": "5.8.0",
|
|
26
|
+
"@dynamic-labs/rpc-providers": "5.8.0",
|
|
27
|
+
"@dynamic-labs/types": "5.8.0",
|
|
28
|
+
"@dynamic-labs/wallet-book": "5.8.0",
|
|
29
|
+
"@dynamic-labs/wallet-connector-core": "5.8.0",
|
|
30
30
|
"eventemitter3": "5.0.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {}
|
package/src/index.cjs
CHANGED
|
@@ -17,6 +17,7 @@ var getGenesisHashLSKey = require('./utils/getGenesisHashLSKey/getGenesisHashLSK
|
|
|
17
17
|
var isTransactionSigned = require('./utils/isTransactionSigned/isTransactionSigned.cjs');
|
|
18
18
|
var getOverrideRpcUrlForNetwork = require('./utils/getOverrideRpcUrlForNetwork/getOverrideRpcUrlForNetwork.cjs');
|
|
19
19
|
var createNonNativeTokenTransfer = require('./utils/createNonNativeTokenTransfer/createNonNativeTokenTransfer.cjs');
|
|
20
|
+
var createAssociatedTokenAccountTransaction = require('./utils/createAssociatedTokenAccountTransaction/createAssociatedTokenAccountTransaction.cjs');
|
|
20
21
|
var createSolTransfer = require('./utils/createSolTransfer/createSolTransfer.cjs');
|
|
21
22
|
var getBackwardsCompatibleSolNetworks = require('./utils/getBackwardsCompatibleSolNetworks/getBackwardsCompatibleSolNetworks.cjs');
|
|
22
23
|
var serializeTransactionForScreening = require('./utils/serializeTransactionForScreening/serializeTransactionForScreening.cjs');
|
|
@@ -38,6 +39,7 @@ exports.getGenesisHashLSKey = getGenesisHashLSKey.getGenesisHashLSKey;
|
|
|
38
39
|
exports.isTxAlreadySigned = isTransactionSigned.isTxAlreadySigned;
|
|
39
40
|
exports.getOverrideRpcUrlForNetwork = getOverrideRpcUrlForNetwork.getOverrideRpcUrlForNetwork;
|
|
40
41
|
exports.createNonNativeTokenTransfer = createNonNativeTokenTransfer.createNonNativeTokenTransfer;
|
|
42
|
+
exports.createAssociatedTokenAccountTransaction = createAssociatedTokenAccountTransaction.createAssociatedTokenAccountTransaction;
|
|
41
43
|
exports.createSolTransfer = createSolTransfer.createSolTransfer;
|
|
42
44
|
exports.getBackwardsCompatibleSolNetworks = getBackwardsCompatibleSolNetworks.getBackwardsCompatibleSolNetworks;
|
|
43
45
|
exports.serializeTransactionForScreening = serializeTransactionForScreening.serializeTransactionForScreening;
|
package/src/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export { getGenesisHashLSKey } from './utils/getGenesisHashLSKey/getGenesisHashL
|
|
|
13
13
|
export { isTxAlreadySigned } from './utils/isTransactionSigned/isTransactionSigned.js';
|
|
14
14
|
export { getOverrideRpcUrlForNetwork } from './utils/getOverrideRpcUrlForNetwork/getOverrideRpcUrlForNetwork.js';
|
|
15
15
|
export { createNonNativeTokenTransfer } from './utils/createNonNativeTokenTransfer/createNonNativeTokenTransfer.js';
|
|
16
|
+
export { createAssociatedTokenAccountTransaction } from './utils/createAssociatedTokenAccountTransaction/createAssociatedTokenAccountTransaction.js';
|
|
16
17
|
export { createSolTransfer } from './utils/createSolTransfer/createSolTransfer.js';
|
|
17
18
|
export { getBackwardsCompatibleSolNetworks } from './utils/getBackwardsCompatibleSolNetworks/getBackwardsCompatibleSolNetworks.js';
|
|
18
19
|
export { serializeTransactionForScreening } from './utils/serializeTransactionForScreening/serializeTransactionForScreening.js';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
var splToken = require('@solana/spl-token');
|
|
8
|
+
var web3_js = require('@solana/web3.js');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Builds a standalone transaction that creates the owner's associated token
|
|
12
|
+
* account for the given mint, if it doesn't already exist — returns
|
|
13
|
+
* undefined (no transaction to send) when it's already there. Kept separate
|
|
14
|
+
* from any transfer/swap instructions so it can be sponsored and sent on its
|
|
15
|
+
* own, without competing for space in an already-large transaction.
|
|
16
|
+
*/
|
|
17
|
+
const createAssociatedTokenAccountTransaction = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ connection, ownerAddress, tokenAddress, blockhash, lastValidBlockHeight, }) {
|
|
18
|
+
const ownerPublicKey = new web3_js.PublicKey(ownerAddress);
|
|
19
|
+
const tokenPublicKey = new web3_js.PublicKey(tokenAddress);
|
|
20
|
+
const mintAccountInfo = yield connection.getAccountInfo(tokenPublicKey);
|
|
21
|
+
const tokenProgramId = mintAccountInfo && mintAccountInfo.owner.equals(splToken.TOKEN_2022_PROGRAM_ID)
|
|
22
|
+
? splToken.TOKEN_2022_PROGRAM_ID
|
|
23
|
+
: splToken.TOKEN_PROGRAM_ID;
|
|
24
|
+
const associatedTokenAddress = yield splToken.getAssociatedTokenAddress(tokenPublicKey, ownerPublicKey, false, tokenProgramId);
|
|
25
|
+
try {
|
|
26
|
+
yield connection.getTokenAccountBalance(associatedTokenAddress);
|
|
27
|
+
// Already exists — nothing to do.
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
catch (_b) {
|
|
31
|
+
// Doesn't exist yet — build the create instruction below.
|
|
32
|
+
}
|
|
33
|
+
const transaction = new web3_js.Transaction().add(splToken.createAssociatedTokenAccountIdempotentInstruction(ownerPublicKey, associatedTokenAddress, ownerPublicKey, tokenPublicKey, tokenProgramId));
|
|
34
|
+
transaction.recentBlockhash = blockhash;
|
|
35
|
+
transaction.lastValidBlockHeight = lastValidBlockHeight;
|
|
36
|
+
transaction.feePayer = ownerPublicKey;
|
|
37
|
+
return transaction;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
exports.createAssociatedTokenAccountTransaction = createAssociatedTokenAccountTransaction;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Connection, Transaction } from '@solana/web3.js';
|
|
2
|
+
/**
|
|
3
|
+
* Builds a standalone transaction that creates the owner's associated token
|
|
4
|
+
* account for the given mint, if it doesn't already exist — returns
|
|
5
|
+
* undefined (no transaction to send) when it's already there. Kept separate
|
|
6
|
+
* from any transfer/swap instructions so it can be sponsored and sent on its
|
|
7
|
+
* own, without competing for space in an already-large transaction.
|
|
8
|
+
*/
|
|
9
|
+
export declare const createAssociatedTokenAccountTransaction: ({ connection, ownerAddress, tokenAddress, blockhash, lastValidBlockHeight, }: {
|
|
10
|
+
connection: Connection;
|
|
11
|
+
ownerAddress: string;
|
|
12
|
+
tokenAddress: string;
|
|
13
|
+
blockhash: string;
|
|
14
|
+
lastValidBlockHeight: number;
|
|
15
|
+
}) => Promise<Transaction | undefined>;
|
package/src/utils/createAssociatedTokenAccountTransaction/createAssociatedTokenAccountTransaction.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
+
import { TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, getAssociatedTokenAddress, createAssociatedTokenAccountIdempotentInstruction } from '@solana/spl-token';
|
|
4
|
+
import { PublicKey, Transaction } from '@solana/web3.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Builds a standalone transaction that creates the owner's associated token
|
|
8
|
+
* account for the given mint, if it doesn't already exist — returns
|
|
9
|
+
* undefined (no transaction to send) when it's already there. Kept separate
|
|
10
|
+
* from any transfer/swap instructions so it can be sponsored and sent on its
|
|
11
|
+
* own, without competing for space in an already-large transaction.
|
|
12
|
+
*/
|
|
13
|
+
const createAssociatedTokenAccountTransaction = (_a) => __awaiter(void 0, [_a], void 0, function* ({ connection, ownerAddress, tokenAddress, blockhash, lastValidBlockHeight, }) {
|
|
14
|
+
const ownerPublicKey = new PublicKey(ownerAddress);
|
|
15
|
+
const tokenPublicKey = new PublicKey(tokenAddress);
|
|
16
|
+
const mintAccountInfo = yield connection.getAccountInfo(tokenPublicKey);
|
|
17
|
+
const tokenProgramId = mintAccountInfo && mintAccountInfo.owner.equals(TOKEN_2022_PROGRAM_ID)
|
|
18
|
+
? TOKEN_2022_PROGRAM_ID
|
|
19
|
+
: TOKEN_PROGRAM_ID;
|
|
20
|
+
const associatedTokenAddress = yield getAssociatedTokenAddress(tokenPublicKey, ownerPublicKey, false, tokenProgramId);
|
|
21
|
+
try {
|
|
22
|
+
yield connection.getTokenAccountBalance(associatedTokenAddress);
|
|
23
|
+
// Already exists — nothing to do.
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
catch (_b) {
|
|
27
|
+
// Doesn't exist yet — build the create instruction below.
|
|
28
|
+
}
|
|
29
|
+
const transaction = new Transaction().add(createAssociatedTokenAccountIdempotentInstruction(ownerPublicKey, associatedTokenAddress, ownerPublicKey, tokenPublicKey, tokenProgramId));
|
|
30
|
+
transaction.recentBlockhash = blockhash;
|
|
31
|
+
transaction.lastValidBlockHeight = lastValidBlockHeight;
|
|
32
|
+
transaction.feePayer = ownerPublicKey;
|
|
33
|
+
return transaction;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export { createAssociatedTokenAccountTransaction };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createAssociatedTokenAccountTransaction } from './createAssociatedTokenAccountTransaction';
|
package/src/utils/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { getGenesisHashLSKey } from './getGenesisHashLSKey';
|
|
|
6
6
|
export { isTxAlreadySigned } from './isTransactionSigned';
|
|
7
7
|
export { getOverrideRpcUrlForNetwork } from './getOverrideRpcUrlForNetwork';
|
|
8
8
|
export { createNonNativeTokenTransfer } from './createNonNativeTokenTransfer';
|
|
9
|
+
export { createAssociatedTokenAccountTransaction } from './createAssociatedTokenAccountTransaction';
|
|
9
10
|
export { createSolTransfer } from './createSolTransfer';
|
|
10
11
|
export { getBackwardsCompatibleSolNetworks } from './getBackwardsCompatibleSolNetworks';
|
|
11
12
|
export { serializeTransactionForScreening } from './serializeTransactionForScreening';
|
|
@@ -9,6 +9,7 @@ var utils = require('@dynamic-labs/utils');
|
|
|
9
9
|
require('@solana/web3.js');
|
|
10
10
|
require('@solana/spl-token');
|
|
11
11
|
var createNonNativeTokenTransfer = require('../utils/createNonNativeTokenTransfer/createNonNativeTokenTransfer.cjs');
|
|
12
|
+
var createAssociatedTokenAccountTransaction = require('../utils/createAssociatedTokenAccountTransaction/createAssociatedTokenAccountTransaction.cjs');
|
|
12
13
|
var createSolTransfer = require('../utils/createSolTransfer/createSolTransfer.cjs');
|
|
13
14
|
var screenSolanaTransactions = require('../utils/screenSolanaTransactions/screenSolanaTransactions.cjs');
|
|
14
15
|
|
|
@@ -49,6 +50,34 @@ class SolanaWallet extends walletConnectorCore.Wallet {
|
|
|
49
50
|
return signature;
|
|
50
51
|
});
|
|
51
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Creates the wallet's associated token account for the given mint, as its
|
|
55
|
+
* own standalone (sponsorable) transaction, if it doesn't already exist —
|
|
56
|
+
* returns undefined without signing or sending anything when it's already
|
|
57
|
+
* there. Kept separate from sendBalance/swap flows so it doesn't compete
|
|
58
|
+
* for space with other instructions in an already-large transaction.
|
|
59
|
+
* @param tokenAddress - The mint address to create the associated token account for.
|
|
60
|
+
* @returns The signature of the sent transaction, or undefined if the account already existed.
|
|
61
|
+
*/
|
|
62
|
+
createAssociatedTokenAccount(_a) {
|
|
63
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ tokenAddress, }) {
|
|
64
|
+
const connection = yield this.getConnection();
|
|
65
|
+
const { blockhash, lastValidBlockHeight } = yield connection.getLatestBlockhash('confirmed');
|
|
66
|
+
const transaction = yield createAssociatedTokenAccountTransaction.createAssociatedTokenAccountTransaction({
|
|
67
|
+
blockhash,
|
|
68
|
+
connection,
|
|
69
|
+
lastValidBlockHeight,
|
|
70
|
+
ownerAddress: this.address,
|
|
71
|
+
tokenAddress,
|
|
72
|
+
});
|
|
73
|
+
if (!transaction) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
const signer = yield this.getSigner();
|
|
77
|
+
const { signature } = yield signer.signAndSendTransaction(transaction);
|
|
78
|
+
return signature;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
52
81
|
/**
|
|
53
82
|
* Retrieves the RPC connection
|
|
54
83
|
* @returns A promise that resolves to the RPC connection
|
|
@@ -17,6 +17,18 @@ export declare class SolanaWallet extends Wallet<SolanaWalletConnector> {
|
|
|
17
17
|
decimals?: number;
|
|
18
18
|
};
|
|
19
19
|
}): Promise<string | undefined>;
|
|
20
|
+
/**
|
|
21
|
+
* Creates the wallet's associated token account for the given mint, as its
|
|
22
|
+
* own standalone (sponsorable) transaction, if it doesn't already exist —
|
|
23
|
+
* returns undefined without signing or sending anything when it's already
|
|
24
|
+
* there. Kept separate from sendBalance/swap flows so it doesn't compete
|
|
25
|
+
* for space with other instructions in an already-large transaction.
|
|
26
|
+
* @param tokenAddress - The mint address to create the associated token account for.
|
|
27
|
+
* @returns The signature of the sent transaction, or undefined if the account already existed.
|
|
28
|
+
*/
|
|
29
|
+
createAssociatedTokenAccount({ tokenAddress, }: {
|
|
30
|
+
tokenAddress: string;
|
|
31
|
+
}): Promise<string | undefined>;
|
|
20
32
|
/**
|
|
21
33
|
* Retrieves the RPC connection
|
|
22
34
|
* @returns A promise that resolves to the RPC connection
|
|
@@ -5,6 +5,7 @@ import { cloneObjectWithOverrides } from '@dynamic-labs/utils';
|
|
|
5
5
|
import '@solana/web3.js';
|
|
6
6
|
import '@solana/spl-token';
|
|
7
7
|
import { createNonNativeTokenTransfer } from '../utils/createNonNativeTokenTransfer/createNonNativeTokenTransfer.js';
|
|
8
|
+
import { createAssociatedTokenAccountTransaction } from '../utils/createAssociatedTokenAccountTransaction/createAssociatedTokenAccountTransaction.js';
|
|
8
9
|
import { createSolTransfer } from '../utils/createSolTransfer/createSolTransfer.js';
|
|
9
10
|
import { screenSolanaTransactions } from '../utils/screenSolanaTransactions/screenSolanaTransactions.js';
|
|
10
11
|
|
|
@@ -45,6 +46,34 @@ class SolanaWallet extends Wallet {
|
|
|
45
46
|
return signature;
|
|
46
47
|
});
|
|
47
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Creates the wallet's associated token account for the given mint, as its
|
|
51
|
+
* own standalone (sponsorable) transaction, if it doesn't already exist —
|
|
52
|
+
* returns undefined without signing or sending anything when it's already
|
|
53
|
+
* there. Kept separate from sendBalance/swap flows so it doesn't compete
|
|
54
|
+
* for space with other instructions in an already-large transaction.
|
|
55
|
+
* @param tokenAddress - The mint address to create the associated token account for.
|
|
56
|
+
* @returns The signature of the sent transaction, or undefined if the account already existed.
|
|
57
|
+
*/
|
|
58
|
+
createAssociatedTokenAccount(_a) {
|
|
59
|
+
return __awaiter(this, arguments, void 0, function* ({ tokenAddress, }) {
|
|
60
|
+
const connection = yield this.getConnection();
|
|
61
|
+
const { blockhash, lastValidBlockHeight } = yield connection.getLatestBlockhash('confirmed');
|
|
62
|
+
const transaction = yield createAssociatedTokenAccountTransaction({
|
|
63
|
+
blockhash,
|
|
64
|
+
connection,
|
|
65
|
+
lastValidBlockHeight,
|
|
66
|
+
ownerAddress: this.address,
|
|
67
|
+
tokenAddress,
|
|
68
|
+
});
|
|
69
|
+
if (!transaction) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
const signer = yield this.getSigner();
|
|
73
|
+
const { signature } = yield signer.signAndSendTransaction(transaction);
|
|
74
|
+
return signature;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
48
77
|
/**
|
|
49
78
|
* Retrieves the RPC connection
|
|
50
79
|
* @returns A promise that resolves to the RPC connection
|