@drift-labs/sdk 2.136.0-beta.4 → 2.136.0-beta.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/VERSION +1 -1
- package/lib/browser/constants/spotMarkets.js +12 -0
- package/lib/browser/driftClient.js +8 -16
- package/lib/browser/tx/baseTxSender.js +6 -5
- package/lib/browser/tx/txHandler.js +8 -13
- package/lib/node/constants/spotMarkets.d.ts.map +1 -1
- package/lib/node/constants/spotMarkets.js +12 -0
- package/lib/node/driftClient.js +8 -16
- package/lib/node/tx/baseTxSender.js +6 -5
- package/lib/node/tx/txHandler.d.ts.map +1 -1
- package/lib/node/tx/txHandler.js +8 -13
- package/package.json +1 -1
- package/src/constants/spotMarkets.ts +13 -0
- package/src/driftClient.ts +8 -8
- package/src/tx/baseTxSender.ts +5 -5
- package/src/tx/txHandler.ts +5 -7
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.136.0-beta.
|
|
1
|
+
2.136.0-beta.6
|
|
@@ -803,6 +803,18 @@ exports.MainnetSpotMarkets = [
|
|
|
803
803
|
precisionExp: numericConstants_1.SIX,
|
|
804
804
|
pythFeedId: '0x2ad31d1c4a85fbf2156ce57fab4104124c5ef76a6386375ecfc8da1ed5ce1486',
|
|
805
805
|
},
|
|
806
|
+
{
|
|
807
|
+
symbol: 'LBTC',
|
|
808
|
+
marketIndex: 58,
|
|
809
|
+
poolId: 0,
|
|
810
|
+
oracle: new web3_js_1.PublicKey('Fa3VKWbdb9yQ89vA9JfYnR6micY9LwGneoQ1So9JgXHT'),
|
|
811
|
+
oracleSource: types_1.OracleSource.PYTH_PULL,
|
|
812
|
+
mint: new web3_js_1.PublicKey('LBTCgU4b3wsFKsPwBn1rRZDx5DoFutM6RPiEt1TPDsY'),
|
|
813
|
+
precision: new anchor_1.BN(10).pow(numericConstants_1.EIGHT),
|
|
814
|
+
precisionExp: numericConstants_1.EIGHT,
|
|
815
|
+
pythFeedId: '0x8f257aab6e7698bb92b15511915e593d6f8eae914452f781874754b03d0c612b',
|
|
816
|
+
launchTs: 1756392947000,
|
|
817
|
+
},
|
|
806
818
|
];
|
|
807
819
|
exports.SpotMarkets = {
|
|
808
820
|
devnet: exports.DevnetSpotMarkets,
|
|
@@ -622,13 +622,12 @@ class DriftClient {
|
|
|
622
622
|
return [txSig, userAccountPublicKey];
|
|
623
623
|
}
|
|
624
624
|
async getInitializeUserStatsIx() {
|
|
625
|
-
var _a, _b;
|
|
626
625
|
return await this.program.instruction.initializeUserStats({
|
|
627
626
|
accounts: {
|
|
628
627
|
userStats: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, this.wallet.publicKey // only allow payer to initialize own user stats account
|
|
629
628
|
),
|
|
630
629
|
authority: this.wallet.publicKey,
|
|
631
|
-
payer:
|
|
630
|
+
payer: this.wallet.publicKey,
|
|
632
631
|
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
633
632
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
634
633
|
state: await this.getStatePublicKey(),
|
|
@@ -644,13 +643,12 @@ class DriftClient {
|
|
|
644
643
|
return [txSig, signedMsgUserAccountPublicKey];
|
|
645
644
|
}
|
|
646
645
|
async getInitializeSignedMsgUserOrdersAccountIx(authority, numOrders) {
|
|
647
|
-
var _a, _b;
|
|
648
646
|
const signedMsgUserAccountPublicKey = (0, pda_1.getSignedMsgUserAccountPublicKey)(this.program.programId, authority);
|
|
649
647
|
const initializeUserAccountIx = await this.program.instruction.initializeSignedMsgUserOrders(numOrders, {
|
|
650
648
|
accounts: {
|
|
651
649
|
signedMsgUserOrders: signedMsgUserAccountPublicKey,
|
|
652
650
|
authority,
|
|
653
|
-
payer:
|
|
651
|
+
payer: this.wallet.publicKey,
|
|
654
652
|
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
655
653
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
656
654
|
},
|
|
@@ -664,13 +662,12 @@ class DriftClient {
|
|
|
664
662
|
return txSig;
|
|
665
663
|
}
|
|
666
664
|
async getResizeSignedMsgUserOrdersInstruction(authority, numOrders, userSubaccountId) {
|
|
667
|
-
var _a, _b;
|
|
668
665
|
const signedMsgUserAccountPublicKey = (0, pda_1.getSignedMsgUserAccountPublicKey)(this.program.programId, authority);
|
|
669
666
|
const resizeUserAccountIx = await this.program.instruction.resizeSignedMsgUserOrders(numOrders, {
|
|
670
667
|
accounts: {
|
|
671
668
|
signedMsgUserOrders: signedMsgUserAccountPublicKey,
|
|
672
669
|
authority,
|
|
673
|
-
payer:
|
|
670
|
+
payer: this.wallet.publicKey,
|
|
674
671
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
675
672
|
user: await (0, pda_1.getUserAccountPublicKey)(this.program.programId, authority, userSubaccountId),
|
|
676
673
|
},
|
|
@@ -736,13 +733,12 @@ class DriftClient {
|
|
|
736
733
|
return txSig;
|
|
737
734
|
}
|
|
738
735
|
async getInitializeFuelOverflowIx(authority) {
|
|
739
|
-
var _a, _b;
|
|
740
736
|
return await this.program.instruction.initializeFuelOverflow({
|
|
741
737
|
accounts: {
|
|
742
738
|
fuelOverflow: (0, pda_1.getFuelOverflowAccountPublicKey)(this.program.programId, authority !== null && authority !== void 0 ? authority : this.wallet.publicKey),
|
|
743
739
|
userStats: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, authority !== null && authority !== void 0 ? authority : this.wallet.publicKey),
|
|
744
740
|
authority: authority !== null && authority !== void 0 ? authority : this.wallet.publicKey,
|
|
745
|
-
payer:
|
|
741
|
+
payer: this.wallet.publicKey,
|
|
746
742
|
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
747
743
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
748
744
|
},
|
|
@@ -765,7 +761,6 @@ class DriftClient {
|
|
|
765
761
|
});
|
|
766
762
|
}
|
|
767
763
|
async getInitializeUserInstructions(subAccountId = 0, name, referrerInfo) {
|
|
768
|
-
var _a, _b;
|
|
769
764
|
const userAccountPublicKey = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, subAccountId);
|
|
770
765
|
const remainingAccounts = new Array();
|
|
771
766
|
if (referrerInfo !== undefined) {
|
|
@@ -803,7 +798,7 @@ class DriftClient {
|
|
|
803
798
|
user: userAccountPublicKey,
|
|
804
799
|
userStats: this.getUserStatsAccountPublicKey(),
|
|
805
800
|
authority: this.wallet.publicKey,
|
|
806
|
-
payer:
|
|
801
|
+
payer: this.wallet.publicKey,
|
|
807
802
|
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
808
803
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
809
804
|
state: await this.getStatePublicKey(),
|
|
@@ -824,7 +819,6 @@ class DriftClient {
|
|
|
824
819
|
return userStatsAccount.numberOfSubAccountsCreated;
|
|
825
820
|
}
|
|
826
821
|
async initializeReferrerName(name) {
|
|
827
|
-
var _a, _b;
|
|
828
822
|
const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, 0);
|
|
829
823
|
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
830
824
|
const referrerNameAccountPublicKey = (0, pda_1.getReferrerNamePublicKeySync)(this.program.programId, nameBuffer);
|
|
@@ -834,7 +828,7 @@ class DriftClient {
|
|
|
834
828
|
user: userAccountPublicKey,
|
|
835
829
|
authority: this.wallet.publicKey,
|
|
836
830
|
userStats: this.getUserStatsAccountPublicKey(),
|
|
837
|
-
payer:
|
|
831
|
+
payer: this.wallet.publicKey,
|
|
838
832
|
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
839
833
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
840
834
|
},
|
|
@@ -4498,7 +4492,6 @@ class DriftClient {
|
|
|
4498
4492
|
return txSig;
|
|
4499
4493
|
}
|
|
4500
4494
|
async getInitializeInsuranceFundStakeIx(marketIndex) {
|
|
4501
|
-
var _a, _b;
|
|
4502
4495
|
const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
|
|
4503
4496
|
const accounts = {
|
|
4504
4497
|
insuranceFundStake: ifStakeAccountPublicKey,
|
|
@@ -4506,7 +4499,7 @@ class DriftClient {
|
|
|
4506
4499
|
userStats: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, this.wallet.publicKey // only allow payer to initialize own insurance fund stake account
|
|
4507
4500
|
),
|
|
4508
4501
|
authority: this.wallet.publicKey,
|
|
4509
|
-
payer:
|
|
4502
|
+
payer: this.wallet.publicKey,
|
|
4510
4503
|
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
4511
4504
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
4512
4505
|
state: await this.getStatePublicKey(),
|
|
@@ -5083,7 +5076,6 @@ class DriftClient {
|
|
|
5083
5076
|
return pullIx[0];
|
|
5084
5077
|
}
|
|
5085
5078
|
async postSwitchboardOnDemandUpdate(feed, recentSlothash, numSignatures = 3) {
|
|
5086
|
-
var _a, _b;
|
|
5087
5079
|
const pullIx = await this.getPostSwitchboardOnDemandUpdateAtomicIx(feed, recentSlothash, numSignatures);
|
|
5088
5080
|
if (!pullIx) {
|
|
5089
5081
|
return undefined;
|
|
@@ -5091,7 +5083,7 @@ class DriftClient {
|
|
|
5091
5083
|
const tx = await (0, on_demand_1.asV0Tx)({
|
|
5092
5084
|
connection: this.connection,
|
|
5093
5085
|
ixs: [pullIx],
|
|
5094
|
-
payer:
|
|
5086
|
+
payer: this.wallet.publicKey,
|
|
5095
5087
|
computeUnitLimitMultiple: 1.3,
|
|
5096
5088
|
lookupTables: await this.fetchAllLookupTableAccounts(),
|
|
5097
5089
|
});
|
|
@@ -66,14 +66,15 @@ class BaseTxSender {
|
|
|
66
66
|
let signedTx;
|
|
67
67
|
if (preSigned) {
|
|
68
68
|
signedTx = tx;
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
}
|
|
71
|
+
else if (this.wallet.payer) {
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
tx.sign((additionalSigners !== null && additionalSigners !== void 0 ? additionalSigners : []).concat(this.wallet.payer));
|
|
74
|
+
signedTx = tx;
|
|
69
75
|
}
|
|
70
76
|
else {
|
|
71
|
-
// Sign with user first for instruction authorities
|
|
72
77
|
signedTx = await this.txHandler.signVersionedTx(tx, additionalSigners, undefined, this.wallet);
|
|
73
|
-
// Add payer signature if available
|
|
74
|
-
if (this.wallet.payer) {
|
|
75
|
-
signedTx.sign([this.wallet.payer]);
|
|
76
|
-
}
|
|
77
78
|
}
|
|
78
79
|
if (opts === undefined) {
|
|
79
80
|
opts = this.opts;
|
|
@@ -79,12 +79,11 @@ class TxHandler {
|
|
|
79
79
|
* @returns
|
|
80
80
|
*/
|
|
81
81
|
async prepareTx(tx, additionalSigners, wallet, confirmationOpts, preSigned, recentBlockhash) {
|
|
82
|
-
var _a, _b;
|
|
83
82
|
if (preSigned) {
|
|
84
83
|
return tx;
|
|
85
84
|
}
|
|
86
85
|
[wallet, confirmationOpts] = this.getProps(wallet, confirmationOpts);
|
|
87
|
-
tx.feePayer =
|
|
86
|
+
tx.feePayer = wallet.publicKey;
|
|
88
87
|
recentBlockhash = recentBlockhash
|
|
89
88
|
? recentBlockhash
|
|
90
89
|
: await this.getLatestBlockhashForTransaction();
|
|
@@ -223,10 +222,9 @@ class TxHandler {
|
|
|
223
222
|
return new web3_js_1.VersionedTransaction(message);
|
|
224
223
|
}
|
|
225
224
|
generateLegacyVersionedTransaction(recentBlockhash, ixs, wallet) {
|
|
226
|
-
var _a, _b;
|
|
227
225
|
[wallet] = this.getProps(wallet);
|
|
228
226
|
const message = new web3_js_1.TransactionMessage({
|
|
229
|
-
payerKey:
|
|
227
|
+
payerKey: wallet.publicKey,
|
|
230
228
|
recentBlockhash: recentBlockhash.blockhash,
|
|
231
229
|
instructions: ixs,
|
|
232
230
|
}).compileToLegacyMessage();
|
|
@@ -236,10 +234,9 @@ class TxHandler {
|
|
|
236
234
|
return tx;
|
|
237
235
|
}
|
|
238
236
|
generateVersionedTransaction(recentBlockhash, ixs, lookupTableAccounts, wallet) {
|
|
239
|
-
var _a, _b;
|
|
240
237
|
[wallet] = this.getProps(wallet);
|
|
241
238
|
const message = new web3_js_1.TransactionMessage({
|
|
242
|
-
payerKey:
|
|
239
|
+
payerKey: wallet.publicKey,
|
|
243
240
|
recentBlockhash: recentBlockhash.blockhash,
|
|
244
241
|
instructions: ixs,
|
|
245
242
|
}).compileToV0Message(lookupTableAccounts);
|
|
@@ -387,7 +384,7 @@ class TxHandler {
|
|
|
387
384
|
* @returns
|
|
388
385
|
*/
|
|
389
386
|
async getPreparedAndSignedLegacyTransactionMap(txsMap, wallet, commitment, recentBlockhash) {
|
|
390
|
-
var _a, _b
|
|
387
|
+
var _a, _b;
|
|
391
388
|
recentBlockhash = recentBlockhash
|
|
392
389
|
? recentBlockhash
|
|
393
390
|
: await this.getLatestBlockhashForTransaction();
|
|
@@ -396,8 +393,7 @@ class TxHandler {
|
|
|
396
393
|
if (!tx)
|
|
397
394
|
continue;
|
|
398
395
|
tx.recentBlockhash = recentBlockhash.blockhash;
|
|
399
|
-
tx.feePayer =
|
|
400
|
-
(_c = (_b = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : wallet === null || wallet === void 0 ? void 0 : wallet.publicKey) !== null && _c !== void 0 ? _c : (_d = this.wallet) === null || _d === void 0 ? void 0 : _d.publicKey;
|
|
396
|
+
tx.feePayer = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.publicKey) !== null && _a !== void 0 ? _a : (_b = this.wallet) === null || _b === void 0 ? void 0 : _b.publicKey;
|
|
401
397
|
// @ts-ignore
|
|
402
398
|
tx.SIGNATURE_BLOCK_AND_EXPIRY = recentBlockhash;
|
|
403
399
|
}
|
|
@@ -411,7 +407,7 @@ class TxHandler {
|
|
|
411
407
|
* @returns
|
|
412
408
|
*/
|
|
413
409
|
async getSignedTransactionMap(txsToSignMap, wallet) {
|
|
414
|
-
var _a
|
|
410
|
+
var _a;
|
|
415
411
|
[wallet] = this.getProps(wallet);
|
|
416
412
|
const txsToSignEntries = Object.entries(txsToSignMap);
|
|
417
413
|
// Create a map of the same keys as the input map, but with the values set to undefined. We'll populate the filtered (non-undefined) values with signed transactions.
|
|
@@ -423,11 +419,10 @@ class TxHandler {
|
|
|
423
419
|
// Extra handling for legacy transactions
|
|
424
420
|
for (const [_key, tx] of filteredTxEntries) {
|
|
425
421
|
if (this.isLegacyTransaction(tx)) {
|
|
426
|
-
tx.feePayer =
|
|
427
|
-
(_b = (_a = wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : wallet.publicKey;
|
|
422
|
+
tx.feePayer = wallet.publicKey;
|
|
428
423
|
}
|
|
429
424
|
}
|
|
430
|
-
(
|
|
425
|
+
(_a = this.preSignedCb) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
431
426
|
const signedFilteredTxs = await wallet.signAllTransactions(filteredTxEntries.map(([_, tx]) => tx));
|
|
432
427
|
signedFilteredTxs.forEach((signedTx, index) => {
|
|
433
428
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spotMarkets.d.ts","sourceRoot":"","sources":["../../../src/constants/spotMarkets.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAW5C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,MAAM,gBAAgB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,CAAC;IAClB,IAAI,EAAE,SAAS,CAAC;IA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,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,gBAAgB,WAE5B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,gBAAgB,EA+F/C,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,EAmyBhD,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE;KAAG,GAAG,IAAI,QAAQ,GAAG,gBAAgB,EAAE;CAGhE,CAAC"}
|
|
@@ -803,6 +803,18 @@ exports.MainnetSpotMarkets = [
|
|
|
803
803
|
precisionExp: numericConstants_1.SIX,
|
|
804
804
|
pythFeedId: '0x2ad31d1c4a85fbf2156ce57fab4104124c5ef76a6386375ecfc8da1ed5ce1486',
|
|
805
805
|
},
|
|
806
|
+
{
|
|
807
|
+
symbol: 'LBTC',
|
|
808
|
+
marketIndex: 58,
|
|
809
|
+
poolId: 0,
|
|
810
|
+
oracle: new web3_js_1.PublicKey('Fa3VKWbdb9yQ89vA9JfYnR6micY9LwGneoQ1So9JgXHT'),
|
|
811
|
+
oracleSource: types_1.OracleSource.PYTH_PULL,
|
|
812
|
+
mint: new web3_js_1.PublicKey('LBTCgU4b3wsFKsPwBn1rRZDx5DoFutM6RPiEt1TPDsY'),
|
|
813
|
+
precision: new anchor_1.BN(10).pow(numericConstants_1.EIGHT),
|
|
814
|
+
precisionExp: numericConstants_1.EIGHT,
|
|
815
|
+
pythFeedId: '0x8f257aab6e7698bb92b15511915e593d6f8eae914452f781874754b03d0c612b',
|
|
816
|
+
launchTs: 1756392947000,
|
|
817
|
+
},
|
|
806
818
|
];
|
|
807
819
|
exports.SpotMarkets = {
|
|
808
820
|
devnet: exports.DevnetSpotMarkets,
|
package/lib/node/driftClient.js
CHANGED
|
@@ -622,13 +622,12 @@ class DriftClient {
|
|
|
622
622
|
return [txSig, userAccountPublicKey];
|
|
623
623
|
}
|
|
624
624
|
async getInitializeUserStatsIx() {
|
|
625
|
-
var _a, _b;
|
|
626
625
|
return await this.program.instruction.initializeUserStats({
|
|
627
626
|
accounts: {
|
|
628
627
|
userStats: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, this.wallet.publicKey // only allow payer to initialize own user stats account
|
|
629
628
|
),
|
|
630
629
|
authority: this.wallet.publicKey,
|
|
631
|
-
payer:
|
|
630
|
+
payer: this.wallet.publicKey,
|
|
632
631
|
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
633
632
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
634
633
|
state: await this.getStatePublicKey(),
|
|
@@ -644,13 +643,12 @@ class DriftClient {
|
|
|
644
643
|
return [txSig, signedMsgUserAccountPublicKey];
|
|
645
644
|
}
|
|
646
645
|
async getInitializeSignedMsgUserOrdersAccountIx(authority, numOrders) {
|
|
647
|
-
var _a, _b;
|
|
648
646
|
const signedMsgUserAccountPublicKey = (0, pda_1.getSignedMsgUserAccountPublicKey)(this.program.programId, authority);
|
|
649
647
|
const initializeUserAccountIx = await this.program.instruction.initializeSignedMsgUserOrders(numOrders, {
|
|
650
648
|
accounts: {
|
|
651
649
|
signedMsgUserOrders: signedMsgUserAccountPublicKey,
|
|
652
650
|
authority,
|
|
653
|
-
payer:
|
|
651
|
+
payer: this.wallet.publicKey,
|
|
654
652
|
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
655
653
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
656
654
|
},
|
|
@@ -664,13 +662,12 @@ class DriftClient {
|
|
|
664
662
|
return txSig;
|
|
665
663
|
}
|
|
666
664
|
async getResizeSignedMsgUserOrdersInstruction(authority, numOrders, userSubaccountId) {
|
|
667
|
-
var _a, _b;
|
|
668
665
|
const signedMsgUserAccountPublicKey = (0, pda_1.getSignedMsgUserAccountPublicKey)(this.program.programId, authority);
|
|
669
666
|
const resizeUserAccountIx = await this.program.instruction.resizeSignedMsgUserOrders(numOrders, {
|
|
670
667
|
accounts: {
|
|
671
668
|
signedMsgUserOrders: signedMsgUserAccountPublicKey,
|
|
672
669
|
authority,
|
|
673
|
-
payer:
|
|
670
|
+
payer: this.wallet.publicKey,
|
|
674
671
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
675
672
|
user: await (0, pda_1.getUserAccountPublicKey)(this.program.programId, authority, userSubaccountId),
|
|
676
673
|
},
|
|
@@ -736,13 +733,12 @@ class DriftClient {
|
|
|
736
733
|
return txSig;
|
|
737
734
|
}
|
|
738
735
|
async getInitializeFuelOverflowIx(authority) {
|
|
739
|
-
var _a, _b;
|
|
740
736
|
return await this.program.instruction.initializeFuelOverflow({
|
|
741
737
|
accounts: {
|
|
742
738
|
fuelOverflow: (0, pda_1.getFuelOverflowAccountPublicKey)(this.program.programId, authority !== null && authority !== void 0 ? authority : this.wallet.publicKey),
|
|
743
739
|
userStats: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, authority !== null && authority !== void 0 ? authority : this.wallet.publicKey),
|
|
744
740
|
authority: authority !== null && authority !== void 0 ? authority : this.wallet.publicKey,
|
|
745
|
-
payer:
|
|
741
|
+
payer: this.wallet.publicKey,
|
|
746
742
|
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
747
743
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
748
744
|
},
|
|
@@ -765,7 +761,6 @@ class DriftClient {
|
|
|
765
761
|
});
|
|
766
762
|
}
|
|
767
763
|
async getInitializeUserInstructions(subAccountId = 0, name, referrerInfo) {
|
|
768
|
-
var _a, _b;
|
|
769
764
|
const userAccountPublicKey = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, subAccountId);
|
|
770
765
|
const remainingAccounts = new Array();
|
|
771
766
|
if (referrerInfo !== undefined) {
|
|
@@ -803,7 +798,7 @@ class DriftClient {
|
|
|
803
798
|
user: userAccountPublicKey,
|
|
804
799
|
userStats: this.getUserStatsAccountPublicKey(),
|
|
805
800
|
authority: this.wallet.publicKey,
|
|
806
|
-
payer:
|
|
801
|
+
payer: this.wallet.publicKey,
|
|
807
802
|
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
808
803
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
809
804
|
state: await this.getStatePublicKey(),
|
|
@@ -824,7 +819,6 @@ class DriftClient {
|
|
|
824
819
|
return userStatsAccount.numberOfSubAccountsCreated;
|
|
825
820
|
}
|
|
826
821
|
async initializeReferrerName(name) {
|
|
827
|
-
var _a, _b;
|
|
828
822
|
const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, 0);
|
|
829
823
|
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
830
824
|
const referrerNameAccountPublicKey = (0, pda_1.getReferrerNamePublicKeySync)(this.program.programId, nameBuffer);
|
|
@@ -834,7 +828,7 @@ class DriftClient {
|
|
|
834
828
|
user: userAccountPublicKey,
|
|
835
829
|
authority: this.wallet.publicKey,
|
|
836
830
|
userStats: this.getUserStatsAccountPublicKey(),
|
|
837
|
-
payer:
|
|
831
|
+
payer: this.wallet.publicKey,
|
|
838
832
|
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
839
833
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
840
834
|
},
|
|
@@ -4498,7 +4492,6 @@ class DriftClient {
|
|
|
4498
4492
|
return txSig;
|
|
4499
4493
|
}
|
|
4500
4494
|
async getInitializeInsuranceFundStakeIx(marketIndex) {
|
|
4501
|
-
var _a, _b;
|
|
4502
4495
|
const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
|
|
4503
4496
|
const accounts = {
|
|
4504
4497
|
insuranceFundStake: ifStakeAccountPublicKey,
|
|
@@ -4506,7 +4499,7 @@ class DriftClient {
|
|
|
4506
4499
|
userStats: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, this.wallet.publicKey // only allow payer to initialize own insurance fund stake account
|
|
4507
4500
|
),
|
|
4508
4501
|
authority: this.wallet.publicKey,
|
|
4509
|
-
payer:
|
|
4502
|
+
payer: this.wallet.publicKey,
|
|
4510
4503
|
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
4511
4504
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
4512
4505
|
state: await this.getStatePublicKey(),
|
|
@@ -5083,7 +5076,6 @@ class DriftClient {
|
|
|
5083
5076
|
return pullIx[0];
|
|
5084
5077
|
}
|
|
5085
5078
|
async postSwitchboardOnDemandUpdate(feed, recentSlothash, numSignatures = 3) {
|
|
5086
|
-
var _a, _b;
|
|
5087
5079
|
const pullIx = await this.getPostSwitchboardOnDemandUpdateAtomicIx(feed, recentSlothash, numSignatures);
|
|
5088
5080
|
if (!pullIx) {
|
|
5089
5081
|
return undefined;
|
|
@@ -5091,7 +5083,7 @@ class DriftClient {
|
|
|
5091
5083
|
const tx = await (0, on_demand_1.asV0Tx)({
|
|
5092
5084
|
connection: this.connection,
|
|
5093
5085
|
ixs: [pullIx],
|
|
5094
|
-
payer:
|
|
5086
|
+
payer: this.wallet.publicKey,
|
|
5095
5087
|
computeUnitLimitMultiple: 1.3,
|
|
5096
5088
|
lookupTables: await this.fetchAllLookupTableAccounts(),
|
|
5097
5089
|
});
|
|
@@ -66,14 +66,15 @@ class BaseTxSender {
|
|
|
66
66
|
let signedTx;
|
|
67
67
|
if (preSigned) {
|
|
68
68
|
signedTx = tx;
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
}
|
|
71
|
+
else if (this.wallet.payer) {
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
tx.sign((additionalSigners !== null && additionalSigners !== void 0 ? additionalSigners : []).concat(this.wallet.payer));
|
|
74
|
+
signedTx = tx;
|
|
69
75
|
}
|
|
70
76
|
else {
|
|
71
|
-
// Sign with user first for instruction authorities
|
|
72
77
|
signedTx = await this.txHandler.signVersionedTx(tx, additionalSigners, undefined, this.wallet);
|
|
73
|
-
// Add payer signature if available
|
|
74
|
-
if (this.wallet.payer) {
|
|
75
|
-
signedTx.sign([this.wallet.payer]);
|
|
76
|
-
}
|
|
77
78
|
}
|
|
78
79
|
if (opts === undefined) {
|
|
79
80
|
opts = this.opts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txHandler.d.ts","sourceRoot":"","sources":["../../../src/tx/txHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,yBAAyB,EACzB,8BAA8B,EAC9B,UAAU,EAEV,cAAc,EACd,UAAU,EAGV,MAAM,EACN,4BAA4B,EAC5B,WAAW,EACX,sBAAsB,EAEtB,kBAAkB,EAClB,oBAAoB,EACpB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAEN,wBAAwB,EACxB,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,MAAM,UAAU,CAAC;AAqBlB,eAAO,MAAM,qBAAqB,SAAU,CAAC;AAM7C,MAAM,MAAM,eAAe,GAAG;IAC7B,YAAY,EAAE,sBAAsB,GAAG,sBAAsB,EAAE,CAAC;IAChE,SAAS,EAAE,kBAAkB,CAAC;IAC9B,UAAU,EAAE,UAAU,CAAC;IACvB,mBAAmB,EAAE,UAAU,CAAC;IAChC,iCAAiC,EAAE,MAAM,OAAO,CAAC,yBAAyB,EAAE,CAAC,CAAC;IAC9E,YAAY,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAC3C,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,eAAe,CAAC,EAAE,8BAA8B,CAAC;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,sBAAsB,EAAE,CAAC;IACvC,WAAW,CAAC,EAAE,4BAA4B,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC7B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,sBAAsB,CAAC,EAAE;QACxB,UAAU,EAAE,MAAM,CAAC;QACnB,gBAAgB,EAAE,MAAM,CAAC;QACzB,gBAAgB,EAAE,MAAM,CAAC;KACzB,CAAC;CACF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V,WAAW,EAAE,CAAC,CAAC;QACf,YAAY,EAAE,YAAY,EAAE,CAAC;KAC7B,CAAC;IAoDF;;;;OAIG;IACU,oBAAoB,CAChC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,sBAAsB,GAAG,sBAAsB,EAAE,CAAC,EAE3E,KAAK,EAAE,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,GAAG;QAC9C,eAAe,EAAE,CAAC,CAAC;KACnB,GACC,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,WAAW,GAAG,oBAAoB,CAAC,CAAC;IAY/D;;;;OAIG;IACU,0BAA0B,CACtC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,sBAAsB,GAAG,sBAAsB,EAAE,CAAC,EAE3E,KAAK,EAAE,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,GAAG;QAC9C,eAAe,EAAE,CAAC,CAAC;KACnB;;;;;;;IAeW,gCAAgC,CAC5C,eAAe,EAAE,eAAe,EAChC,oBAAoB,GAAE,sBAAsB,EAAO,EACnD,oBAAoB,UAAO,EAC3B,mBAAmB,GAAE,yBAAyB,EAAO,GACnD,OAAO,CACT;QAAC,sBAAsB,EAAE;QAAE,4BAA4B,GAAG,SAAS;KAAC,CACpE;CAmDD"}
|
package/lib/node/tx/txHandler.js
CHANGED
|
@@ -79,12 +79,11 @@ class TxHandler {
|
|
|
79
79
|
* @returns
|
|
80
80
|
*/
|
|
81
81
|
async prepareTx(tx, additionalSigners, wallet, confirmationOpts, preSigned, recentBlockhash) {
|
|
82
|
-
var _a, _b;
|
|
83
82
|
if (preSigned) {
|
|
84
83
|
return tx;
|
|
85
84
|
}
|
|
86
85
|
[wallet, confirmationOpts] = this.getProps(wallet, confirmationOpts);
|
|
87
|
-
tx.feePayer =
|
|
86
|
+
tx.feePayer = wallet.publicKey;
|
|
88
87
|
recentBlockhash = recentBlockhash
|
|
89
88
|
? recentBlockhash
|
|
90
89
|
: await this.getLatestBlockhashForTransaction();
|
|
@@ -223,10 +222,9 @@ class TxHandler {
|
|
|
223
222
|
return new web3_js_1.VersionedTransaction(message);
|
|
224
223
|
}
|
|
225
224
|
generateLegacyVersionedTransaction(recentBlockhash, ixs, wallet) {
|
|
226
|
-
var _a, _b;
|
|
227
225
|
[wallet] = this.getProps(wallet);
|
|
228
226
|
const message = new web3_js_1.TransactionMessage({
|
|
229
|
-
payerKey:
|
|
227
|
+
payerKey: wallet.publicKey,
|
|
230
228
|
recentBlockhash: recentBlockhash.blockhash,
|
|
231
229
|
instructions: ixs,
|
|
232
230
|
}).compileToLegacyMessage();
|
|
@@ -236,10 +234,9 @@ class TxHandler {
|
|
|
236
234
|
return tx;
|
|
237
235
|
}
|
|
238
236
|
generateVersionedTransaction(recentBlockhash, ixs, lookupTableAccounts, wallet) {
|
|
239
|
-
var _a, _b;
|
|
240
237
|
[wallet] = this.getProps(wallet);
|
|
241
238
|
const message = new web3_js_1.TransactionMessage({
|
|
242
|
-
payerKey:
|
|
239
|
+
payerKey: wallet.publicKey,
|
|
243
240
|
recentBlockhash: recentBlockhash.blockhash,
|
|
244
241
|
instructions: ixs,
|
|
245
242
|
}).compileToV0Message(lookupTableAccounts);
|
|
@@ -387,7 +384,7 @@ class TxHandler {
|
|
|
387
384
|
* @returns
|
|
388
385
|
*/
|
|
389
386
|
async getPreparedAndSignedLegacyTransactionMap(txsMap, wallet, commitment, recentBlockhash) {
|
|
390
|
-
var _a, _b
|
|
387
|
+
var _a, _b;
|
|
391
388
|
recentBlockhash = recentBlockhash
|
|
392
389
|
? recentBlockhash
|
|
393
390
|
: await this.getLatestBlockhashForTransaction();
|
|
@@ -396,8 +393,7 @@ class TxHandler {
|
|
|
396
393
|
if (!tx)
|
|
397
394
|
continue;
|
|
398
395
|
tx.recentBlockhash = recentBlockhash.blockhash;
|
|
399
|
-
tx.feePayer =
|
|
400
|
-
(_c = (_b = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : wallet === null || wallet === void 0 ? void 0 : wallet.publicKey) !== null && _c !== void 0 ? _c : (_d = this.wallet) === null || _d === void 0 ? void 0 : _d.publicKey;
|
|
396
|
+
tx.feePayer = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.publicKey) !== null && _a !== void 0 ? _a : (_b = this.wallet) === null || _b === void 0 ? void 0 : _b.publicKey;
|
|
401
397
|
// @ts-ignore
|
|
402
398
|
tx.SIGNATURE_BLOCK_AND_EXPIRY = recentBlockhash;
|
|
403
399
|
}
|
|
@@ -411,7 +407,7 @@ class TxHandler {
|
|
|
411
407
|
* @returns
|
|
412
408
|
*/
|
|
413
409
|
async getSignedTransactionMap(txsToSignMap, wallet) {
|
|
414
|
-
var _a
|
|
410
|
+
var _a;
|
|
415
411
|
[wallet] = this.getProps(wallet);
|
|
416
412
|
const txsToSignEntries = Object.entries(txsToSignMap);
|
|
417
413
|
// Create a map of the same keys as the input map, but with the values set to undefined. We'll populate the filtered (non-undefined) values with signed transactions.
|
|
@@ -423,11 +419,10 @@ class TxHandler {
|
|
|
423
419
|
// Extra handling for legacy transactions
|
|
424
420
|
for (const [_key, tx] of filteredTxEntries) {
|
|
425
421
|
if (this.isLegacyTransaction(tx)) {
|
|
426
|
-
tx.feePayer =
|
|
427
|
-
(_b = (_a = wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : wallet.publicKey;
|
|
422
|
+
tx.feePayer = wallet.publicKey;
|
|
428
423
|
}
|
|
429
424
|
}
|
|
430
|
-
(
|
|
425
|
+
(_a = this.preSignedCb) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
431
426
|
const signedFilteredTxs = await wallet.signAllTransactions(filteredTxEntries.map(([_, tx]) => tx));
|
|
432
427
|
signedFilteredTxs.forEach((signedTx, index) => {
|
|
433
428
|
var _a;
|
package/package.json
CHANGED
|
@@ -921,6 +921,19 @@ export const MainnetSpotMarkets: SpotMarketConfig[] = [
|
|
|
921
921
|
pythFeedId:
|
|
922
922
|
'0x2ad31d1c4a85fbf2156ce57fab4104124c5ef76a6386375ecfc8da1ed5ce1486',
|
|
923
923
|
},
|
|
924
|
+
{
|
|
925
|
+
symbol: 'LBTC',
|
|
926
|
+
marketIndex: 58,
|
|
927
|
+
poolId: 0,
|
|
928
|
+
oracle: new PublicKey('Fa3VKWbdb9yQ89vA9JfYnR6micY9LwGneoQ1So9JgXHT'),
|
|
929
|
+
oracleSource: OracleSource.PYTH_PULL,
|
|
930
|
+
mint: new PublicKey('LBTCgU4b3wsFKsPwBn1rRZDx5DoFutM6RPiEt1TPDsY'),
|
|
931
|
+
precision: new BN(10).pow(EIGHT),
|
|
932
|
+
precisionExp: EIGHT,
|
|
933
|
+
pythFeedId:
|
|
934
|
+
'0x8f257aab6e7698bb92b15511915e593d6f8eae914452f781874754b03d0c612b',
|
|
935
|
+
launchTs: 1756392947000,
|
|
936
|
+
},
|
|
924
937
|
];
|
|
925
938
|
|
|
926
939
|
export const SpotMarkets: { [key in DriftEnv]: SpotMarketConfig[] } = {
|
package/src/driftClient.ts
CHANGED
|
@@ -1102,7 +1102,7 @@ export class DriftClient {
|
|
|
1102
1102
|
this.wallet.publicKey // only allow payer to initialize own user stats account
|
|
1103
1103
|
),
|
|
1104
1104
|
authority: this.wallet.publicKey,
|
|
1105
|
-
payer: this.wallet.
|
|
1105
|
+
payer: this.wallet.publicKey,
|
|
1106
1106
|
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
1107
1107
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
1108
1108
|
state: await this.getStatePublicKey(),
|
|
@@ -1142,7 +1142,7 @@ export class DriftClient {
|
|
|
1142
1142
|
accounts: {
|
|
1143
1143
|
signedMsgUserOrders: signedMsgUserAccountPublicKey,
|
|
1144
1144
|
authority,
|
|
1145
|
-
payer: this.wallet.
|
|
1145
|
+
payer: this.wallet.publicKey,
|
|
1146
1146
|
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
1147
1147
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
1148
1148
|
},
|
|
@@ -1183,7 +1183,7 @@ export class DriftClient {
|
|
|
1183
1183
|
accounts: {
|
|
1184
1184
|
signedMsgUserOrders: signedMsgUserAccountPublicKey,
|
|
1185
1185
|
authority,
|
|
1186
|
-
payer: this.wallet.
|
|
1186
|
+
payer: this.wallet.publicKey,
|
|
1187
1187
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
1188
1188
|
user: await getUserAccountPublicKey(
|
|
1189
1189
|
this.program.programId,
|
|
@@ -1321,7 +1321,7 @@ export class DriftClient {
|
|
|
1321
1321
|
authority ?? this.wallet.publicKey
|
|
1322
1322
|
),
|
|
1323
1323
|
authority: authority ?? this.wallet.publicKey,
|
|
1324
|
-
payer: this.wallet.
|
|
1324
|
+
payer: this.wallet.publicKey,
|
|
1325
1325
|
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
1326
1326
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
1327
1327
|
},
|
|
@@ -1407,7 +1407,7 @@ export class DriftClient {
|
|
|
1407
1407
|
user: userAccountPublicKey,
|
|
1408
1408
|
userStats: this.getUserStatsAccountPublicKey(),
|
|
1409
1409
|
authority: this.wallet.publicKey,
|
|
1410
|
-
payer: this.wallet.
|
|
1410
|
+
payer: this.wallet.publicKey,
|
|
1411
1411
|
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
1412
1412
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
1413
1413
|
state: await this.getStatePublicKey(),
|
|
@@ -1457,7 +1457,7 @@ export class DriftClient {
|
|
|
1457
1457
|
user: userAccountPublicKey,
|
|
1458
1458
|
authority: this.wallet.publicKey,
|
|
1459
1459
|
userStats: this.getUserStatsAccountPublicKey(),
|
|
1460
|
-
payer: this.wallet.
|
|
1460
|
+
payer: this.wallet.publicKey,
|
|
1461
1461
|
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
1462
1462
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
1463
1463
|
},
|
|
@@ -8630,7 +8630,7 @@ export class DriftClient {
|
|
|
8630
8630
|
this.wallet.publicKey // only allow payer to initialize own insurance fund stake account
|
|
8631
8631
|
),
|
|
8632
8632
|
authority: this.wallet.publicKey,
|
|
8633
|
-
payer: this.wallet.
|
|
8633
|
+
payer: this.wallet.publicKey,
|
|
8634
8634
|
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
8635
8635
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
8636
8636
|
state: await this.getStatePublicKey(),
|
|
@@ -9743,7 +9743,7 @@ export class DriftClient {
|
|
|
9743
9743
|
const tx = await asV0Tx({
|
|
9744
9744
|
connection: this.connection,
|
|
9745
9745
|
ixs: [pullIx],
|
|
9746
|
-
payer: this.wallet.
|
|
9746
|
+
payer: this.wallet.publicKey,
|
|
9747
9747
|
computeUnitLimitMultiple: 1.3,
|
|
9748
9748
|
lookupTables: await this.fetchAllLookupTableAccounts(),
|
|
9749
9749
|
});
|
package/src/tx/baseTxSender.ts
CHANGED
|
@@ -173,18 +173,18 @@ export abstract class BaseTxSender implements TxSender {
|
|
|
173
173
|
|
|
174
174
|
if (preSigned) {
|
|
175
175
|
signedTx = tx;
|
|
176
|
+
// @ts-ignore
|
|
177
|
+
} else if (this.wallet.payer) {
|
|
178
|
+
// @ts-ignore
|
|
179
|
+
tx.sign((additionalSigners ?? []).concat(this.wallet.payer));
|
|
180
|
+
signedTx = tx;
|
|
176
181
|
} else {
|
|
177
|
-
// Sign with user first for instruction authorities
|
|
178
182
|
signedTx = await this.txHandler.signVersionedTx(
|
|
179
183
|
tx,
|
|
180
184
|
additionalSigners,
|
|
181
185
|
undefined,
|
|
182
186
|
this.wallet
|
|
183
187
|
);
|
|
184
|
-
// Add payer signature if available
|
|
185
|
-
if (this.wallet.payer) {
|
|
186
|
-
signedTx.sign([this.wallet.payer]);
|
|
187
|
-
}
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
if (opts === undefined) {
|
package/src/tx/txHandler.ts
CHANGED
|
@@ -191,7 +191,7 @@ export class TxHandler {
|
|
|
191
191
|
|
|
192
192
|
[wallet, confirmationOpts] = this.getProps(wallet, confirmationOpts);
|
|
193
193
|
|
|
194
|
-
tx.feePayer = wallet.
|
|
194
|
+
tx.feePayer = wallet.publicKey;
|
|
195
195
|
recentBlockhash = recentBlockhash
|
|
196
196
|
? recentBlockhash
|
|
197
197
|
: await this.getLatestBlockhashForTransaction();
|
|
@@ -398,7 +398,7 @@ export class TxHandler {
|
|
|
398
398
|
[wallet] = this.getProps(wallet);
|
|
399
399
|
|
|
400
400
|
const message = new TransactionMessage({
|
|
401
|
-
payerKey: wallet.
|
|
401
|
+
payerKey: wallet.publicKey,
|
|
402
402
|
recentBlockhash: recentBlockhash.blockhash,
|
|
403
403
|
instructions: ixs,
|
|
404
404
|
}).compileToLegacyMessage();
|
|
@@ -420,7 +420,7 @@ export class TxHandler {
|
|
|
420
420
|
[wallet] = this.getProps(wallet);
|
|
421
421
|
|
|
422
422
|
const message = new TransactionMessage({
|
|
423
|
-
payerKey: wallet.
|
|
423
|
+
payerKey: wallet.publicKey,
|
|
424
424
|
recentBlockhash: recentBlockhash.blockhash,
|
|
425
425
|
instructions: ixs,
|
|
426
426
|
}).compileToV0Message(lookupTableAccounts);
|
|
@@ -649,8 +649,7 @@ export class TxHandler {
|
|
|
649
649
|
for (const tx of Object.values(txsMap)) {
|
|
650
650
|
if (!tx) continue;
|
|
651
651
|
tx.recentBlockhash = recentBlockhash.blockhash;
|
|
652
|
-
tx.feePayer =
|
|
653
|
-
wallet?.payer?.publicKey ?? wallet?.publicKey ?? this.wallet?.publicKey;
|
|
652
|
+
tx.feePayer = wallet?.publicKey ?? this.wallet?.publicKey;
|
|
654
653
|
|
|
655
654
|
// @ts-ignore
|
|
656
655
|
tx.SIGNATURE_BLOCK_AND_EXPIRY = recentBlockhash;
|
|
@@ -690,8 +689,7 @@ export class TxHandler {
|
|
|
690
689
|
// Extra handling for legacy transactions
|
|
691
690
|
for (const [_key, tx] of filteredTxEntries) {
|
|
692
691
|
if (this.isLegacyTransaction(tx)) {
|
|
693
|
-
(tx as Transaction).feePayer =
|
|
694
|
-
wallet.payer?.publicKey ?? wallet.publicKey;
|
|
692
|
+
(tx as Transaction).feePayer = wallet.publicKey;
|
|
695
693
|
}
|
|
696
694
|
}
|
|
697
695
|
|