@solana/web3.js 1.47.4 → 1.50.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/lib/index.browser.cjs.js +654 -320
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +652 -321
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +654 -320
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +347 -233
- package/lib/index.esm.js +652 -321
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +699 -365
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +3 -3
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +654 -320
- package/lib/index.native.js.map +1 -1
- package/package.json +1 -1
- package/src/address-lookup-table-program.ts +433 -0
- package/src/connection.ts +76 -10
- package/src/index.ts +1 -0
- package/src/layout.ts +16 -4
package/lib/index.iife.js
CHANGED
|
@@ -11478,7 +11478,69 @@ var solanaWeb3 = (function (exports) {
|
|
|
11478
11478
|
|
|
11479
11479
|
}
|
|
11480
11480
|
|
|
11481
|
-
|
|
11481
|
+
var browser$1 = {};
|
|
11482
|
+
|
|
11483
|
+
Object.defineProperty(browser$1, "__esModule", { value: true });
|
|
11484
|
+
/**
|
|
11485
|
+
* Convert a little-endian buffer into a BigInt.
|
|
11486
|
+
* @param buf The little-endian buffer to convert
|
|
11487
|
+
* @returns A BigInt with the little-endian representation of buf.
|
|
11488
|
+
*/
|
|
11489
|
+
function toBigIntLE(buf) {
|
|
11490
|
+
{
|
|
11491
|
+
const reversed = Buffer.from(buf);
|
|
11492
|
+
reversed.reverse();
|
|
11493
|
+
const hex = reversed.toString('hex');
|
|
11494
|
+
if (hex.length === 0) {
|
|
11495
|
+
return BigInt(0);
|
|
11496
|
+
}
|
|
11497
|
+
return BigInt(`0x${hex}`);
|
|
11498
|
+
}
|
|
11499
|
+
}
|
|
11500
|
+
var toBigIntLE_1 = browser$1.toBigIntLE = toBigIntLE;
|
|
11501
|
+
/**
|
|
11502
|
+
* Convert a big-endian buffer into a BigInt
|
|
11503
|
+
* @param buf The big-endian buffer to convert.
|
|
11504
|
+
* @returns A BigInt with the big-endian representation of buf.
|
|
11505
|
+
*/
|
|
11506
|
+
function toBigIntBE(buf) {
|
|
11507
|
+
{
|
|
11508
|
+
const hex = buf.toString('hex');
|
|
11509
|
+
if (hex.length === 0) {
|
|
11510
|
+
return BigInt(0);
|
|
11511
|
+
}
|
|
11512
|
+
return BigInt(`0x${hex}`);
|
|
11513
|
+
}
|
|
11514
|
+
}
|
|
11515
|
+
browser$1.toBigIntBE = toBigIntBE;
|
|
11516
|
+
/**
|
|
11517
|
+
* Convert a BigInt to a little-endian buffer.
|
|
11518
|
+
* @param num The BigInt to convert.
|
|
11519
|
+
* @param width The number of bytes that the resulting buffer should be.
|
|
11520
|
+
* @returns A little-endian buffer representation of num.
|
|
11521
|
+
*/
|
|
11522
|
+
function toBufferLE(num, width) {
|
|
11523
|
+
{
|
|
11524
|
+
const hex = num.toString(16);
|
|
11525
|
+
const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
|
|
11526
|
+
buffer.reverse();
|
|
11527
|
+
return buffer;
|
|
11528
|
+
}
|
|
11529
|
+
}
|
|
11530
|
+
var toBufferLE_1 = browser$1.toBufferLE = toBufferLE;
|
|
11531
|
+
/**
|
|
11532
|
+
* Convert a BigInt to a big-endian buffer.
|
|
11533
|
+
* @param num The BigInt to convert.
|
|
11534
|
+
* @param width The number of bytes that the resulting buffer should be.
|
|
11535
|
+
* @returns A big-endian buffer representation of num.
|
|
11536
|
+
*/
|
|
11537
|
+
function toBufferBE(num, width) {
|
|
11538
|
+
{
|
|
11539
|
+
const hex = num.toString(16);
|
|
11540
|
+
return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
|
|
11541
|
+
}
|
|
11542
|
+
}
|
|
11543
|
+
browser$1.toBufferBE = toBufferBE;
|
|
11482
11544
|
|
|
11483
11545
|
var Layout$1 = {};
|
|
11484
11546
|
|
|
@@ -13763,16 +13825,6 @@ var solanaWeb3 = (function (exports) {
|
|
|
13763
13825
|
/** Factory for {@link Constant} values. */
|
|
13764
13826
|
Layout$1.constant = ((value, property) => new Constant(value, property));
|
|
13765
13827
|
|
|
13766
|
-
/**
|
|
13767
|
-
* Maximum over-the-wire size of a Transaction
|
|
13768
|
-
*
|
|
13769
|
-
* 1280 is IPv6 minimum MTU
|
|
13770
|
-
* 40 bytes is the size of the IPv6 header
|
|
13771
|
-
* 8 bytes is the size of the fragment header
|
|
13772
|
-
*/
|
|
13773
|
-
const PACKET_DATA_SIZE = 1280 - 40 - 8;
|
|
13774
|
-
const SIGNATURE_LENGTH_IN_BYTES = 64;
|
|
13775
|
-
|
|
13776
13828
|
/**
|
|
13777
13829
|
* Layout for a public key
|
|
13778
13830
|
*/
|
|
@@ -13834,17 +13886,170 @@ var solanaWeb3 = (function (exports) {
|
|
|
13834
13886
|
return struct([publicKey('nodePubkey'), publicKey('authorizedVoter'), publicKey('authorizedWithdrawer'), u8('commission')], property);
|
|
13835
13887
|
};
|
|
13836
13888
|
function getAlloc(type, fields) {
|
|
13837
|
-
|
|
13838
|
-
type.layout.fields.forEach(item => {
|
|
13889
|
+
const getItemAlloc = item => {
|
|
13839
13890
|
if (item.span >= 0) {
|
|
13840
|
-
|
|
13891
|
+
return item.span;
|
|
13841
13892
|
} else if (typeof item.alloc === 'function') {
|
|
13842
|
-
|
|
13843
|
-
}
|
|
13893
|
+
return item.alloc(fields[item.property]);
|
|
13894
|
+
} else if ('count' in item && 'elementLayout' in item) {
|
|
13895
|
+
const field = fields[item.property];
|
|
13896
|
+
|
|
13897
|
+
if (Array.isArray(field)) {
|
|
13898
|
+
return field.length * getItemAlloc(item.elementLayout);
|
|
13899
|
+
}
|
|
13900
|
+
} // Couldn't determine allocated size of layout
|
|
13901
|
+
|
|
13902
|
+
|
|
13903
|
+
return 0;
|
|
13904
|
+
};
|
|
13905
|
+
|
|
13906
|
+
let alloc = 0;
|
|
13907
|
+
type.layout.fields.forEach(item => {
|
|
13908
|
+
alloc += getItemAlloc(item);
|
|
13844
13909
|
});
|
|
13845
13910
|
return alloc;
|
|
13846
13911
|
}
|
|
13847
13912
|
|
|
13913
|
+
const encodeDecode = layout => {
|
|
13914
|
+
const decode = layout.decode.bind(layout);
|
|
13915
|
+
const encode = layout.encode.bind(layout);
|
|
13916
|
+
return {
|
|
13917
|
+
decode,
|
|
13918
|
+
encode
|
|
13919
|
+
};
|
|
13920
|
+
};
|
|
13921
|
+
|
|
13922
|
+
const bigInt = length => property => {
|
|
13923
|
+
const layout = blob(length, property);
|
|
13924
|
+
const {
|
|
13925
|
+
encode,
|
|
13926
|
+
decode
|
|
13927
|
+
} = encodeDecode(layout);
|
|
13928
|
+
const bigIntLayout = layout;
|
|
13929
|
+
|
|
13930
|
+
bigIntLayout.decode = (buffer$1, offset) => {
|
|
13931
|
+
const src = decode(buffer$1, offset);
|
|
13932
|
+
return toBigIntLE_1(buffer.Buffer.from(src));
|
|
13933
|
+
};
|
|
13934
|
+
|
|
13935
|
+
bigIntLayout.encode = (bigInt, buffer, offset) => {
|
|
13936
|
+
const src = toBufferLE_1(bigInt, length);
|
|
13937
|
+
return encode(src, buffer, offset);
|
|
13938
|
+
};
|
|
13939
|
+
|
|
13940
|
+
return bigIntLayout;
|
|
13941
|
+
};
|
|
13942
|
+
|
|
13943
|
+
const u64 = bigInt(8);
|
|
13944
|
+
|
|
13945
|
+
/**
|
|
13946
|
+
* Populate a buffer of instruction data using an InstructionType
|
|
13947
|
+
* @internal
|
|
13948
|
+
*/
|
|
13949
|
+
function encodeData(type, fields) {
|
|
13950
|
+
const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
|
|
13951
|
+
const data = buffer.Buffer.alloc(allocLength);
|
|
13952
|
+
const layoutFields = Object.assign({
|
|
13953
|
+
instruction: type.index
|
|
13954
|
+
}, fields);
|
|
13955
|
+
type.layout.encode(layoutFields, data);
|
|
13956
|
+
return data;
|
|
13957
|
+
}
|
|
13958
|
+
/**
|
|
13959
|
+
* Decode instruction data buffer using an InstructionType
|
|
13960
|
+
* @internal
|
|
13961
|
+
*/
|
|
13962
|
+
|
|
13963
|
+
function decodeData(type, buffer) {
|
|
13964
|
+
let data;
|
|
13965
|
+
|
|
13966
|
+
try {
|
|
13967
|
+
data = type.layout.decode(buffer);
|
|
13968
|
+
} catch (err) {
|
|
13969
|
+
throw new Error('invalid instruction; ' + err);
|
|
13970
|
+
}
|
|
13971
|
+
|
|
13972
|
+
if (data.instruction !== type.index) {
|
|
13973
|
+
throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
|
|
13974
|
+
}
|
|
13975
|
+
|
|
13976
|
+
return data;
|
|
13977
|
+
}
|
|
13978
|
+
|
|
13979
|
+
/**
|
|
13980
|
+
* https://github.com/solana-labs/solana/blob/90bedd7e067b5b8f3ddbb45da00a4e9cabb22c62/sdk/src/fee_calculator.rs#L7-L11
|
|
13981
|
+
*
|
|
13982
|
+
* @internal
|
|
13983
|
+
*/
|
|
13984
|
+
|
|
13985
|
+
const FeeCalculatorLayout = nu64('lamportsPerSignature');
|
|
13986
|
+
/**
|
|
13987
|
+
* Calculator for transaction fees.
|
|
13988
|
+
*/
|
|
13989
|
+
|
|
13990
|
+
/**
|
|
13991
|
+
* See https://github.com/solana-labs/solana/blob/0ea2843ec9cdc517572b8e62c959f41b55cf4453/sdk/src/nonce_state.rs#L29-L32
|
|
13992
|
+
*
|
|
13993
|
+
* @internal
|
|
13994
|
+
*/
|
|
13995
|
+
|
|
13996
|
+
const NonceAccountLayout = struct([u32('version'), u32('state'), publicKey('authorizedPubkey'), publicKey('nonce'), struct([FeeCalculatorLayout], 'feeCalculator')]);
|
|
13997
|
+
const NONCE_ACCOUNT_LENGTH = NonceAccountLayout.span;
|
|
13998
|
+
|
|
13999
|
+
/**
|
|
14000
|
+
* NonceAccount class
|
|
14001
|
+
*/
|
|
14002
|
+
class NonceAccount {
|
|
14003
|
+
/**
|
|
14004
|
+
* @internal
|
|
14005
|
+
*/
|
|
14006
|
+
constructor(args) {
|
|
14007
|
+
this.authorizedPubkey = void 0;
|
|
14008
|
+
this.nonce = void 0;
|
|
14009
|
+
this.feeCalculator = void 0;
|
|
14010
|
+
this.authorizedPubkey = args.authorizedPubkey;
|
|
14011
|
+
this.nonce = args.nonce;
|
|
14012
|
+
this.feeCalculator = args.feeCalculator;
|
|
14013
|
+
}
|
|
14014
|
+
/**
|
|
14015
|
+
* Deserialize NonceAccount from the account data.
|
|
14016
|
+
*
|
|
14017
|
+
* @param buffer account data
|
|
14018
|
+
* @return NonceAccount
|
|
14019
|
+
*/
|
|
14020
|
+
|
|
14021
|
+
|
|
14022
|
+
static fromAccountData(buffer) {
|
|
14023
|
+
const nonceAccount = NonceAccountLayout.decode(toBuffer(buffer), 0);
|
|
14024
|
+
return new NonceAccount({
|
|
14025
|
+
authorizedPubkey: new PublicKey(nonceAccount.authorizedPubkey),
|
|
14026
|
+
nonce: new PublicKey(nonceAccount.nonce).toString(),
|
|
14027
|
+
feeCalculator: nonceAccount.feeCalculator
|
|
14028
|
+
});
|
|
14029
|
+
}
|
|
14030
|
+
|
|
14031
|
+
}
|
|
14032
|
+
|
|
14033
|
+
const SYSVAR_CLOCK_PUBKEY = new PublicKey('SysvarC1ock11111111111111111111111111111111');
|
|
14034
|
+
const SYSVAR_EPOCH_SCHEDULE_PUBKEY = new PublicKey('SysvarEpochSchedu1e111111111111111111111111');
|
|
14035
|
+
const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
|
|
14036
|
+
const SYSVAR_RECENT_BLOCKHASHES_PUBKEY = new PublicKey('SysvarRecentB1ockHashes11111111111111111111');
|
|
14037
|
+
const SYSVAR_RENT_PUBKEY = new PublicKey('SysvarRent111111111111111111111111111111111');
|
|
14038
|
+
const SYSVAR_REWARDS_PUBKEY = new PublicKey('SysvarRewards111111111111111111111111111111');
|
|
14039
|
+
const SYSVAR_SLOT_HASHES_PUBKEY = new PublicKey('SysvarS1otHashes111111111111111111111111111');
|
|
14040
|
+
const SYSVAR_SLOT_HISTORY_PUBKEY = new PublicKey('SysvarS1otHistory11111111111111111111111111');
|
|
14041
|
+
const SYSVAR_STAKE_HISTORY_PUBKEY = new PublicKey('SysvarStakeHistory1111111111111111111111111');
|
|
14042
|
+
|
|
14043
|
+
/**
|
|
14044
|
+
* Maximum over-the-wire size of a Transaction
|
|
14045
|
+
*
|
|
14046
|
+
* 1280 is IPv6 minimum MTU
|
|
14047
|
+
* 40 bytes is the size of the IPv6 header
|
|
14048
|
+
* 8 bytes is the size of the fragment header
|
|
14049
|
+
*/
|
|
14050
|
+
const PACKET_DATA_SIZE = 1280 - 40 - 8;
|
|
14051
|
+
const SIGNATURE_LENGTH_IN_BYTES = 64;
|
|
14052
|
+
|
|
13848
14053
|
function decodeLength(bytes) {
|
|
13849
14054
|
let len = 0;
|
|
13850
14055
|
let size = 0;
|
|
@@ -14758,243 +14963,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
14758
14963
|
|
|
14759
14964
|
}
|
|
14760
14965
|
|
|
14761
|
-
|
|
14762
|
-
|
|
14763
|
-
|
|
14764
|
-
const SYSVAR_RECENT_BLOCKHASHES_PUBKEY = new PublicKey('SysvarRecentB1ockHashes11111111111111111111');
|
|
14765
|
-
const SYSVAR_RENT_PUBKEY = new PublicKey('SysvarRent111111111111111111111111111111111');
|
|
14766
|
-
const SYSVAR_REWARDS_PUBKEY = new PublicKey('SysvarRewards111111111111111111111111111111');
|
|
14767
|
-
const SYSVAR_SLOT_HASHES_PUBKEY = new PublicKey('SysvarS1otHashes111111111111111111111111111');
|
|
14768
|
-
const SYSVAR_SLOT_HISTORY_PUBKEY = new PublicKey('SysvarS1otHistory11111111111111111111111111');
|
|
14769
|
-
const SYSVAR_STAKE_HISTORY_PUBKEY = new PublicKey('SysvarStakeHistory1111111111111111111111111');
|
|
14966
|
+
/**
|
|
14967
|
+
* Create account system transaction params
|
|
14968
|
+
*/
|
|
14770
14969
|
|
|
14771
14970
|
/**
|
|
14772
|
-
*
|
|
14773
|
-
*
|
|
14774
|
-
* If `commitment` option is not specified, defaults to 'max' commitment.
|
|
14775
|
-
*
|
|
14776
|
-
* @param {Connection} connection
|
|
14777
|
-
* @param {Transaction} transaction
|
|
14778
|
-
* @param {Array<Signer>} signers
|
|
14779
|
-
* @param {ConfirmOptions} [options]
|
|
14780
|
-
* @returns {Promise<TransactionSignature>}
|
|
14781
|
-
*/
|
|
14782
|
-
async function sendAndConfirmTransaction(connection, transaction, signers, options) {
|
|
14783
|
-
const sendOptions = options && {
|
|
14784
|
-
skipPreflight: options.skipPreflight,
|
|
14785
|
-
preflightCommitment: options.preflightCommitment || options.commitment,
|
|
14786
|
-
maxRetries: options.maxRetries,
|
|
14787
|
-
minContextSlot: options.minContextSlot
|
|
14788
|
-
};
|
|
14789
|
-
const signature = await connection.sendTransaction(transaction, signers, sendOptions);
|
|
14790
|
-
const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
|
|
14791
|
-
signature: signature,
|
|
14792
|
-
blockhash: transaction.recentBlockhash,
|
|
14793
|
-
lastValidBlockHeight: transaction.lastValidBlockHeight
|
|
14794
|
-
}, options && options.commitment)).value : (await connection.confirmTransaction(signature, options && options.commitment)).value;
|
|
14795
|
-
|
|
14796
|
-
if (status.err) {
|
|
14797
|
-
throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
|
|
14798
|
-
}
|
|
14799
|
-
|
|
14800
|
-
return signature;
|
|
14801
|
-
}
|
|
14802
|
-
|
|
14803
|
-
// zzz
|
|
14804
|
-
function sleep(ms) {
|
|
14805
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
14806
|
-
}
|
|
14807
|
-
|
|
14808
|
-
/**
|
|
14809
|
-
* Populate a buffer of instruction data using an InstructionType
|
|
14810
|
-
* @internal
|
|
14811
|
-
*/
|
|
14812
|
-
function encodeData(type, fields) {
|
|
14813
|
-
const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
|
|
14814
|
-
const data = buffer.Buffer.alloc(allocLength);
|
|
14815
|
-
const layoutFields = Object.assign({
|
|
14816
|
-
instruction: type.index
|
|
14817
|
-
}, fields);
|
|
14818
|
-
type.layout.encode(layoutFields, data);
|
|
14819
|
-
return data;
|
|
14820
|
-
}
|
|
14821
|
-
/**
|
|
14822
|
-
* Decode instruction data buffer using an InstructionType
|
|
14823
|
-
* @internal
|
|
14824
|
-
*/
|
|
14825
|
-
|
|
14826
|
-
function decodeData(type, buffer) {
|
|
14827
|
-
let data;
|
|
14828
|
-
|
|
14829
|
-
try {
|
|
14830
|
-
data = type.layout.decode(buffer);
|
|
14831
|
-
} catch (err) {
|
|
14832
|
-
throw new Error('invalid instruction; ' + err);
|
|
14833
|
-
}
|
|
14834
|
-
|
|
14835
|
-
if (data.instruction !== type.index) {
|
|
14836
|
-
throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
|
|
14837
|
-
}
|
|
14838
|
-
|
|
14839
|
-
return data;
|
|
14840
|
-
}
|
|
14841
|
-
|
|
14842
|
-
/**
|
|
14843
|
-
* https://github.com/solana-labs/solana/blob/90bedd7e067b5b8f3ddbb45da00a4e9cabb22c62/sdk/src/fee_calculator.rs#L7-L11
|
|
14844
|
-
*
|
|
14845
|
-
* @internal
|
|
14846
|
-
*/
|
|
14847
|
-
|
|
14848
|
-
const FeeCalculatorLayout = nu64('lamportsPerSignature');
|
|
14849
|
-
/**
|
|
14850
|
-
* Calculator for transaction fees.
|
|
14851
|
-
*/
|
|
14852
|
-
|
|
14853
|
-
/**
|
|
14854
|
-
* See https://github.com/solana-labs/solana/blob/0ea2843ec9cdc517572b8e62c959f41b55cf4453/sdk/src/nonce_state.rs#L29-L32
|
|
14855
|
-
*
|
|
14856
|
-
* @internal
|
|
14857
|
-
*/
|
|
14858
|
-
|
|
14859
|
-
const NonceAccountLayout = struct([u32('version'), u32('state'), publicKey('authorizedPubkey'), publicKey('nonce'), struct([FeeCalculatorLayout], 'feeCalculator')]);
|
|
14860
|
-
const NONCE_ACCOUNT_LENGTH = NonceAccountLayout.span;
|
|
14861
|
-
|
|
14862
|
-
/**
|
|
14863
|
-
* NonceAccount class
|
|
14864
|
-
*/
|
|
14865
|
-
class NonceAccount {
|
|
14866
|
-
/**
|
|
14867
|
-
* @internal
|
|
14868
|
-
*/
|
|
14869
|
-
constructor(args) {
|
|
14870
|
-
this.authorizedPubkey = void 0;
|
|
14871
|
-
this.nonce = void 0;
|
|
14872
|
-
this.feeCalculator = void 0;
|
|
14873
|
-
this.authorizedPubkey = args.authorizedPubkey;
|
|
14874
|
-
this.nonce = args.nonce;
|
|
14875
|
-
this.feeCalculator = args.feeCalculator;
|
|
14876
|
-
}
|
|
14877
|
-
/**
|
|
14878
|
-
* Deserialize NonceAccount from the account data.
|
|
14879
|
-
*
|
|
14880
|
-
* @param buffer account data
|
|
14881
|
-
* @return NonceAccount
|
|
14882
|
-
*/
|
|
14883
|
-
|
|
14884
|
-
|
|
14885
|
-
static fromAccountData(buffer) {
|
|
14886
|
-
const nonceAccount = NonceAccountLayout.decode(toBuffer(buffer), 0);
|
|
14887
|
-
return new NonceAccount({
|
|
14888
|
-
authorizedPubkey: new PublicKey(nonceAccount.authorizedPubkey),
|
|
14889
|
-
nonce: new PublicKey(nonceAccount.nonce).toString(),
|
|
14890
|
-
feeCalculator: nonceAccount.feeCalculator
|
|
14891
|
-
});
|
|
14892
|
-
}
|
|
14893
|
-
|
|
14894
|
-
}
|
|
14895
|
-
|
|
14896
|
-
var browser$1 = {};
|
|
14897
|
-
|
|
14898
|
-
Object.defineProperty(browser$1, "__esModule", { value: true });
|
|
14899
|
-
/**
|
|
14900
|
-
* Convert a little-endian buffer into a BigInt.
|
|
14901
|
-
* @param buf The little-endian buffer to convert
|
|
14902
|
-
* @returns A BigInt with the little-endian representation of buf.
|
|
14903
|
-
*/
|
|
14904
|
-
function toBigIntLE(buf) {
|
|
14905
|
-
{
|
|
14906
|
-
const reversed = Buffer.from(buf);
|
|
14907
|
-
reversed.reverse();
|
|
14908
|
-
const hex = reversed.toString('hex');
|
|
14909
|
-
if (hex.length === 0) {
|
|
14910
|
-
return BigInt(0);
|
|
14911
|
-
}
|
|
14912
|
-
return BigInt(`0x${hex}`);
|
|
14913
|
-
}
|
|
14914
|
-
}
|
|
14915
|
-
var toBigIntLE_1 = browser$1.toBigIntLE = toBigIntLE;
|
|
14916
|
-
/**
|
|
14917
|
-
* Convert a big-endian buffer into a BigInt
|
|
14918
|
-
* @param buf The big-endian buffer to convert.
|
|
14919
|
-
* @returns A BigInt with the big-endian representation of buf.
|
|
14920
|
-
*/
|
|
14921
|
-
function toBigIntBE(buf) {
|
|
14922
|
-
{
|
|
14923
|
-
const hex = buf.toString('hex');
|
|
14924
|
-
if (hex.length === 0) {
|
|
14925
|
-
return BigInt(0);
|
|
14926
|
-
}
|
|
14927
|
-
return BigInt(`0x${hex}`);
|
|
14928
|
-
}
|
|
14929
|
-
}
|
|
14930
|
-
browser$1.toBigIntBE = toBigIntBE;
|
|
14931
|
-
/**
|
|
14932
|
-
* Convert a BigInt to a little-endian buffer.
|
|
14933
|
-
* @param num The BigInt to convert.
|
|
14934
|
-
* @param width The number of bytes that the resulting buffer should be.
|
|
14935
|
-
* @returns A little-endian buffer representation of num.
|
|
14936
|
-
*/
|
|
14937
|
-
function toBufferLE(num, width) {
|
|
14938
|
-
{
|
|
14939
|
-
const hex = num.toString(16);
|
|
14940
|
-
const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
|
|
14941
|
-
buffer.reverse();
|
|
14942
|
-
return buffer;
|
|
14943
|
-
}
|
|
14944
|
-
}
|
|
14945
|
-
var toBufferLE_1 = browser$1.toBufferLE = toBufferLE;
|
|
14946
|
-
/**
|
|
14947
|
-
* Convert a BigInt to a big-endian buffer.
|
|
14948
|
-
* @param num The BigInt to convert.
|
|
14949
|
-
* @param width The number of bytes that the resulting buffer should be.
|
|
14950
|
-
* @returns A big-endian buffer representation of num.
|
|
14951
|
-
*/
|
|
14952
|
-
function toBufferBE(num, width) {
|
|
14953
|
-
{
|
|
14954
|
-
const hex = num.toString(16);
|
|
14955
|
-
return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
|
|
14956
|
-
}
|
|
14957
|
-
}
|
|
14958
|
-
browser$1.toBufferBE = toBufferBE;
|
|
14959
|
-
|
|
14960
|
-
const encodeDecode = layout => {
|
|
14961
|
-
const decode = layout.decode.bind(layout);
|
|
14962
|
-
const encode = layout.encode.bind(layout);
|
|
14963
|
-
return {
|
|
14964
|
-
decode,
|
|
14965
|
-
encode
|
|
14966
|
-
};
|
|
14967
|
-
};
|
|
14968
|
-
|
|
14969
|
-
const bigInt = length => property => {
|
|
14970
|
-
const layout = blob(length, property);
|
|
14971
|
-
const {
|
|
14972
|
-
encode,
|
|
14973
|
-
decode
|
|
14974
|
-
} = encodeDecode(layout);
|
|
14975
|
-
const bigIntLayout = layout;
|
|
14976
|
-
|
|
14977
|
-
bigIntLayout.decode = (buffer$1, offset) => {
|
|
14978
|
-
const src = decode(buffer$1, offset);
|
|
14979
|
-
return toBigIntLE_1(buffer.Buffer.from(src));
|
|
14980
|
-
};
|
|
14981
|
-
|
|
14982
|
-
bigIntLayout.encode = (bigInt, buffer, offset) => {
|
|
14983
|
-
const src = toBufferLE_1(bigInt, length);
|
|
14984
|
-
return encode(src, buffer, offset);
|
|
14985
|
-
};
|
|
14986
|
-
|
|
14987
|
-
return bigIntLayout;
|
|
14988
|
-
};
|
|
14989
|
-
|
|
14990
|
-
const u64 = bigInt(8);
|
|
14991
|
-
|
|
14992
|
-
/**
|
|
14993
|
-
* Create account system transaction params
|
|
14994
|
-
*/
|
|
14995
|
-
|
|
14996
|
-
/**
|
|
14997
|
-
* System Instruction class
|
|
14971
|
+
* System Instruction class
|
|
14998
14972
|
*/
|
|
14999
14973
|
class SystemInstruction {
|
|
15000
14974
|
/**
|
|
@@ -15569,140 +15543,446 @@ var solanaWeb3 = (function (exports) {
|
|
|
15569
15543
|
return new TransactionInstruction(instructionData);
|
|
15570
15544
|
}
|
|
15571
15545
|
/**
|
|
15572
|
-
* Generate an instruction to advance the nonce in a Nonce account
|
|
15546
|
+
* Generate an instruction to advance the nonce in a Nonce account
|
|
15547
|
+
*/
|
|
15548
|
+
|
|
15549
|
+
|
|
15550
|
+
static nonceAdvance(params) {
|
|
15551
|
+
const type = SYSTEM_INSTRUCTION_LAYOUTS.AdvanceNonceAccount;
|
|
15552
|
+
const data = encodeData(type);
|
|
15553
|
+
const instructionData = {
|
|
15554
|
+
keys: [{
|
|
15555
|
+
pubkey: params.noncePubkey,
|
|
15556
|
+
isSigner: false,
|
|
15557
|
+
isWritable: true
|
|
15558
|
+
}, {
|
|
15559
|
+
pubkey: SYSVAR_RECENT_BLOCKHASHES_PUBKEY,
|
|
15560
|
+
isSigner: false,
|
|
15561
|
+
isWritable: false
|
|
15562
|
+
}, {
|
|
15563
|
+
pubkey: params.authorizedPubkey,
|
|
15564
|
+
isSigner: true,
|
|
15565
|
+
isWritable: false
|
|
15566
|
+
}],
|
|
15567
|
+
programId: this.programId,
|
|
15568
|
+
data
|
|
15569
|
+
};
|
|
15570
|
+
return new TransactionInstruction(instructionData);
|
|
15571
|
+
}
|
|
15572
|
+
/**
|
|
15573
|
+
* Generate a transaction instruction that withdraws lamports from a Nonce account
|
|
15574
|
+
*/
|
|
15575
|
+
|
|
15576
|
+
|
|
15577
|
+
static nonceWithdraw(params) {
|
|
15578
|
+
const type = SYSTEM_INSTRUCTION_LAYOUTS.WithdrawNonceAccount;
|
|
15579
|
+
const data = encodeData(type, {
|
|
15580
|
+
lamports: params.lamports
|
|
15581
|
+
});
|
|
15582
|
+
return new TransactionInstruction({
|
|
15583
|
+
keys: [{
|
|
15584
|
+
pubkey: params.noncePubkey,
|
|
15585
|
+
isSigner: false,
|
|
15586
|
+
isWritable: true
|
|
15587
|
+
}, {
|
|
15588
|
+
pubkey: params.toPubkey,
|
|
15589
|
+
isSigner: false,
|
|
15590
|
+
isWritable: true
|
|
15591
|
+
}, {
|
|
15592
|
+
pubkey: SYSVAR_RECENT_BLOCKHASHES_PUBKEY,
|
|
15593
|
+
isSigner: false,
|
|
15594
|
+
isWritable: false
|
|
15595
|
+
}, {
|
|
15596
|
+
pubkey: SYSVAR_RENT_PUBKEY,
|
|
15597
|
+
isSigner: false,
|
|
15598
|
+
isWritable: false
|
|
15599
|
+
}, {
|
|
15600
|
+
pubkey: params.authorizedPubkey,
|
|
15601
|
+
isSigner: true,
|
|
15602
|
+
isWritable: false
|
|
15603
|
+
}],
|
|
15604
|
+
programId: this.programId,
|
|
15605
|
+
data
|
|
15606
|
+
});
|
|
15607
|
+
}
|
|
15608
|
+
/**
|
|
15609
|
+
* Generate a transaction instruction that authorizes a new PublicKey as the authority
|
|
15610
|
+
* on a Nonce account.
|
|
15611
|
+
*/
|
|
15612
|
+
|
|
15613
|
+
|
|
15614
|
+
static nonceAuthorize(params) {
|
|
15615
|
+
const type = SYSTEM_INSTRUCTION_LAYOUTS.AuthorizeNonceAccount;
|
|
15616
|
+
const data = encodeData(type, {
|
|
15617
|
+
authorized: toBuffer(params.newAuthorizedPubkey.toBuffer())
|
|
15618
|
+
});
|
|
15619
|
+
return new TransactionInstruction({
|
|
15620
|
+
keys: [{
|
|
15621
|
+
pubkey: params.noncePubkey,
|
|
15622
|
+
isSigner: false,
|
|
15623
|
+
isWritable: true
|
|
15624
|
+
}, {
|
|
15625
|
+
pubkey: params.authorizedPubkey,
|
|
15626
|
+
isSigner: true,
|
|
15627
|
+
isWritable: false
|
|
15628
|
+
}],
|
|
15629
|
+
programId: this.programId,
|
|
15630
|
+
data
|
|
15631
|
+
});
|
|
15632
|
+
}
|
|
15633
|
+
/**
|
|
15634
|
+
* Generate a transaction instruction that allocates space in an account without funding
|
|
15635
|
+
*/
|
|
15636
|
+
|
|
15637
|
+
|
|
15638
|
+
static allocate(params) {
|
|
15639
|
+
let data;
|
|
15640
|
+
let keys;
|
|
15641
|
+
|
|
15642
|
+
if ('basePubkey' in params) {
|
|
15643
|
+
const type = SYSTEM_INSTRUCTION_LAYOUTS.AllocateWithSeed;
|
|
15644
|
+
data = encodeData(type, {
|
|
15645
|
+
base: toBuffer(params.basePubkey.toBuffer()),
|
|
15646
|
+
seed: params.seed,
|
|
15647
|
+
space: params.space,
|
|
15648
|
+
programId: toBuffer(params.programId.toBuffer())
|
|
15649
|
+
});
|
|
15650
|
+
keys = [{
|
|
15651
|
+
pubkey: params.accountPubkey,
|
|
15652
|
+
isSigner: false,
|
|
15653
|
+
isWritable: true
|
|
15654
|
+
}, {
|
|
15655
|
+
pubkey: params.basePubkey,
|
|
15656
|
+
isSigner: true,
|
|
15657
|
+
isWritable: false
|
|
15658
|
+
}];
|
|
15659
|
+
} else {
|
|
15660
|
+
const type = SYSTEM_INSTRUCTION_LAYOUTS.Allocate;
|
|
15661
|
+
data = encodeData(type, {
|
|
15662
|
+
space: params.space
|
|
15663
|
+
});
|
|
15664
|
+
keys = [{
|
|
15665
|
+
pubkey: params.accountPubkey,
|
|
15666
|
+
isSigner: true,
|
|
15667
|
+
isWritable: true
|
|
15668
|
+
}];
|
|
15669
|
+
}
|
|
15670
|
+
|
|
15671
|
+
return new TransactionInstruction({
|
|
15672
|
+
keys,
|
|
15673
|
+
programId: this.programId,
|
|
15674
|
+
data
|
|
15675
|
+
});
|
|
15676
|
+
}
|
|
15677
|
+
|
|
15678
|
+
}
|
|
15679
|
+
SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
|
|
15680
|
+
|
|
15681
|
+
/**
|
|
15682
|
+
* An enumeration of valid address lookup table InstructionType's
|
|
15683
|
+
* @internal
|
|
15684
|
+
*/
|
|
15685
|
+
const LOOKUP_TABLE_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
15686
|
+
CreateLookupTable: {
|
|
15687
|
+
index: 0,
|
|
15688
|
+
layout: struct([u32('instruction'), u64('recentSlot'), u8('bumpSeed')])
|
|
15689
|
+
},
|
|
15690
|
+
FreezeLookupTable: {
|
|
15691
|
+
index: 1,
|
|
15692
|
+
layout: struct([u32('instruction')])
|
|
15693
|
+
},
|
|
15694
|
+
ExtendLookupTable: {
|
|
15695
|
+
index: 2,
|
|
15696
|
+
layout: struct([u32('instruction'), u64(), seq(publicKey(), offset(u32(), -8), 'addresses')])
|
|
15697
|
+
},
|
|
15698
|
+
DeactivateLookupTable: {
|
|
15699
|
+
index: 3,
|
|
15700
|
+
layout: struct([u32('instruction')])
|
|
15701
|
+
},
|
|
15702
|
+
CloseLookupTable: {
|
|
15703
|
+
index: 4,
|
|
15704
|
+
layout: struct([u32('instruction')])
|
|
15705
|
+
}
|
|
15706
|
+
});
|
|
15707
|
+
class AddressLookupTableInstruction {
|
|
15708
|
+
/**
|
|
15709
|
+
* @internal
|
|
15710
|
+
*/
|
|
15711
|
+
constructor() {}
|
|
15712
|
+
|
|
15713
|
+
static decodeInstructionType(instruction) {
|
|
15714
|
+
this.checkProgramId(instruction.programId);
|
|
15715
|
+
const instructionTypeLayout = u32('instruction');
|
|
15716
|
+
const index = instructionTypeLayout.decode(instruction.data);
|
|
15717
|
+
let type;
|
|
15718
|
+
|
|
15719
|
+
for (const [layoutType, layout] of Object.entries(LOOKUP_TABLE_INSTRUCTION_LAYOUTS)) {
|
|
15720
|
+
if (layout.index == index) {
|
|
15721
|
+
type = layoutType;
|
|
15722
|
+
break;
|
|
15723
|
+
}
|
|
15724
|
+
}
|
|
15725
|
+
|
|
15726
|
+
if (!type) {
|
|
15727
|
+
throw new Error('Invalid Instruction. Should be a LookupTable Instruction');
|
|
15728
|
+
}
|
|
15729
|
+
|
|
15730
|
+
return type;
|
|
15731
|
+
}
|
|
15732
|
+
|
|
15733
|
+
static decodeCreateLookupTable(instruction) {
|
|
15734
|
+
this.checkProgramId(instruction.programId);
|
|
15735
|
+
this.checkKeysLength(instruction.keys, 4);
|
|
15736
|
+
const {
|
|
15737
|
+
recentSlot
|
|
15738
|
+
} = decodeData(LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable, instruction.data);
|
|
15739
|
+
return {
|
|
15740
|
+
authority: instruction.keys[1].pubkey,
|
|
15741
|
+
payer: instruction.keys[2].pubkey,
|
|
15742
|
+
recentSlot: Number(recentSlot)
|
|
15743
|
+
};
|
|
15744
|
+
}
|
|
15745
|
+
|
|
15746
|
+
static decodeExtendLookupTable(instruction) {
|
|
15747
|
+
this.checkProgramId(instruction.programId);
|
|
15748
|
+
|
|
15749
|
+
if (instruction.keys.length < 2) {
|
|
15750
|
+
throw new Error(`invalid instruction; found ${instruction.keys.length} keys, expected at least 2`);
|
|
15751
|
+
}
|
|
15752
|
+
|
|
15753
|
+
const {
|
|
15754
|
+
addresses
|
|
15755
|
+
} = decodeData(LOOKUP_TABLE_INSTRUCTION_LAYOUTS.ExtendLookupTable, instruction.data);
|
|
15756
|
+
return {
|
|
15757
|
+
lookupTable: instruction.keys[0].pubkey,
|
|
15758
|
+
authority: instruction.keys[1].pubkey,
|
|
15759
|
+
payer: instruction.keys.length > 2 ? instruction.keys[2].pubkey : undefined,
|
|
15760
|
+
addresses: addresses.map(buffer => new PublicKey(buffer))
|
|
15761
|
+
};
|
|
15762
|
+
}
|
|
15763
|
+
|
|
15764
|
+
static decodeCloseLookupTable(instruction) {
|
|
15765
|
+
this.checkProgramId(instruction.programId);
|
|
15766
|
+
this.checkKeysLength(instruction.keys, 3);
|
|
15767
|
+
return {
|
|
15768
|
+
lookupTable: instruction.keys[0].pubkey,
|
|
15769
|
+
authority: instruction.keys[1].pubkey,
|
|
15770
|
+
recipient: instruction.keys[2].pubkey
|
|
15771
|
+
};
|
|
15772
|
+
}
|
|
15773
|
+
|
|
15774
|
+
static decodeFreezeLookupTable(instruction) {
|
|
15775
|
+
this.checkProgramId(instruction.programId);
|
|
15776
|
+
this.checkKeysLength(instruction.keys, 2);
|
|
15777
|
+
return {
|
|
15778
|
+
lookupTable: instruction.keys[0].pubkey,
|
|
15779
|
+
authority: instruction.keys[1].pubkey
|
|
15780
|
+
};
|
|
15781
|
+
}
|
|
15782
|
+
|
|
15783
|
+
static decodeDeactivateLookupTable(instruction) {
|
|
15784
|
+
this.checkProgramId(instruction.programId);
|
|
15785
|
+
this.checkKeysLength(instruction.keys, 2);
|
|
15786
|
+
return {
|
|
15787
|
+
lookupTable: instruction.keys[0].pubkey,
|
|
15788
|
+
authority: instruction.keys[1].pubkey
|
|
15789
|
+
};
|
|
15790
|
+
}
|
|
15791
|
+
/**
|
|
15792
|
+
* @internal
|
|
15793
|
+
*/
|
|
15794
|
+
|
|
15795
|
+
|
|
15796
|
+
static checkProgramId(programId) {
|
|
15797
|
+
if (!programId.equals(AddressLookupTableProgram.programId)) {
|
|
15798
|
+
throw new Error('invalid instruction; programId is not AddressLookupTable Program');
|
|
15799
|
+
}
|
|
15800
|
+
}
|
|
15801
|
+
/**
|
|
15802
|
+
* @internal
|
|
15573
15803
|
*/
|
|
15574
15804
|
|
|
15575
15805
|
|
|
15576
|
-
static
|
|
15577
|
-
|
|
15578
|
-
|
|
15579
|
-
|
|
15580
|
-
keys: [{
|
|
15581
|
-
pubkey: params.noncePubkey,
|
|
15582
|
-
isSigner: false,
|
|
15583
|
-
isWritable: true
|
|
15584
|
-
}, {
|
|
15585
|
-
pubkey: SYSVAR_RECENT_BLOCKHASHES_PUBKEY,
|
|
15586
|
-
isSigner: false,
|
|
15587
|
-
isWritable: false
|
|
15588
|
-
}, {
|
|
15589
|
-
pubkey: params.authorizedPubkey,
|
|
15590
|
-
isSigner: true,
|
|
15591
|
-
isWritable: false
|
|
15592
|
-
}],
|
|
15593
|
-
programId: this.programId,
|
|
15594
|
-
data
|
|
15595
|
-
};
|
|
15596
|
-
return new TransactionInstruction(instructionData);
|
|
15806
|
+
static checkKeysLength(keys, expectedLength) {
|
|
15807
|
+
if (keys.length < expectedLength) {
|
|
15808
|
+
throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
|
|
15809
|
+
}
|
|
15597
15810
|
}
|
|
15811
|
+
|
|
15812
|
+
}
|
|
15813
|
+
class AddressLookupTableProgram {
|
|
15598
15814
|
/**
|
|
15599
|
-
*
|
|
15815
|
+
* @internal
|
|
15600
15816
|
*/
|
|
15817
|
+
constructor() {}
|
|
15601
15818
|
|
|
15602
|
-
|
|
15603
|
-
|
|
15604
|
-
const type =
|
|
15819
|
+
static createLookupTable(params) {
|
|
15820
|
+
const [lookupTableAddress, bumpSeed] = PublicKey.findProgramAddressSync([params.authority.toBuffer(), toBufferLE_1(BigInt(params.recentSlot), 8)], this.programId);
|
|
15821
|
+
const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable;
|
|
15605
15822
|
const data = encodeData(type, {
|
|
15606
|
-
|
|
15823
|
+
recentSlot: BigInt(params.recentSlot),
|
|
15824
|
+
bumpSeed: bumpSeed
|
|
15607
15825
|
});
|
|
15608
|
-
|
|
15609
|
-
|
|
15610
|
-
|
|
15611
|
-
|
|
15612
|
-
|
|
15613
|
-
|
|
15614
|
-
|
|
15615
|
-
|
|
15616
|
-
|
|
15617
|
-
|
|
15618
|
-
|
|
15619
|
-
|
|
15620
|
-
|
|
15621
|
-
|
|
15622
|
-
|
|
15623
|
-
|
|
15624
|
-
|
|
15625
|
-
|
|
15626
|
-
pubkey: params.authorizedPubkey,
|
|
15627
|
-
isSigner: true,
|
|
15628
|
-
isWritable: false
|
|
15629
|
-
}],
|
|
15826
|
+
const keys = [{
|
|
15827
|
+
pubkey: lookupTableAddress,
|
|
15828
|
+
isSigner: false,
|
|
15829
|
+
isWritable: true
|
|
15830
|
+
}, {
|
|
15831
|
+
pubkey: params.authority,
|
|
15832
|
+
isSigner: true,
|
|
15833
|
+
isWritable: false
|
|
15834
|
+
}, {
|
|
15835
|
+
pubkey: params.payer,
|
|
15836
|
+
isSigner: true,
|
|
15837
|
+
isWritable: true
|
|
15838
|
+
}, {
|
|
15839
|
+
pubkey: SystemProgram.programId,
|
|
15840
|
+
isSigner: false,
|
|
15841
|
+
isWritable: false
|
|
15842
|
+
}];
|
|
15843
|
+
return [new TransactionInstruction({
|
|
15630
15844
|
programId: this.programId,
|
|
15631
|
-
|
|
15632
|
-
|
|
15845
|
+
keys: keys,
|
|
15846
|
+
data: data
|
|
15847
|
+
}), lookupTableAddress];
|
|
15633
15848
|
}
|
|
15634
|
-
/**
|
|
15635
|
-
* Generate a transaction instruction that authorizes a new PublicKey as the authority
|
|
15636
|
-
* on a Nonce account.
|
|
15637
|
-
*/
|
|
15638
|
-
|
|
15639
15849
|
|
|
15640
|
-
static
|
|
15641
|
-
const type =
|
|
15642
|
-
const data = encodeData(type
|
|
15643
|
-
|
|
15644
|
-
|
|
15850
|
+
static freezeLookupTable(params) {
|
|
15851
|
+
const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.FreezeLookupTable;
|
|
15852
|
+
const data = encodeData(type);
|
|
15853
|
+
const keys = [{
|
|
15854
|
+
pubkey: params.lookupTable,
|
|
15855
|
+
isSigner: false,
|
|
15856
|
+
isWritable: true
|
|
15857
|
+
}, {
|
|
15858
|
+
pubkey: params.authority,
|
|
15859
|
+
isSigner: true,
|
|
15860
|
+
isWritable: false
|
|
15861
|
+
}];
|
|
15645
15862
|
return new TransactionInstruction({
|
|
15646
|
-
keys: [{
|
|
15647
|
-
pubkey: params.noncePubkey,
|
|
15648
|
-
isSigner: false,
|
|
15649
|
-
isWritable: true
|
|
15650
|
-
}, {
|
|
15651
|
-
pubkey: params.authorizedPubkey,
|
|
15652
|
-
isSigner: true,
|
|
15653
|
-
isWritable: false
|
|
15654
|
-
}],
|
|
15655
15863
|
programId: this.programId,
|
|
15656
|
-
|
|
15864
|
+
keys: keys,
|
|
15865
|
+
data: data
|
|
15657
15866
|
});
|
|
15658
15867
|
}
|
|
15659
|
-
/**
|
|
15660
|
-
* Generate a transaction instruction that allocates space in an account without funding
|
|
15661
|
-
*/
|
|
15662
15868
|
|
|
15869
|
+
static extendLookupTable(params) {
|
|
15870
|
+
const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.ExtendLookupTable;
|
|
15871
|
+
const data = encodeData(type, {
|
|
15872
|
+
addresses: params.addresses.map(addr => addr.toBytes())
|
|
15873
|
+
});
|
|
15874
|
+
const keys = [{
|
|
15875
|
+
pubkey: params.lookupTable,
|
|
15876
|
+
isSigner: false,
|
|
15877
|
+
isWritable: true
|
|
15878
|
+
}, {
|
|
15879
|
+
pubkey: params.authority,
|
|
15880
|
+
isSigner: true,
|
|
15881
|
+
isWritable: false
|
|
15882
|
+
}];
|
|
15663
15883
|
|
|
15664
|
-
|
|
15665
|
-
|
|
15666
|
-
|
|
15667
|
-
|
|
15668
|
-
if ('basePubkey' in params) {
|
|
15669
|
-
const type = SYSTEM_INSTRUCTION_LAYOUTS.AllocateWithSeed;
|
|
15670
|
-
data = encodeData(type, {
|
|
15671
|
-
base: toBuffer(params.basePubkey.toBuffer()),
|
|
15672
|
-
seed: params.seed,
|
|
15673
|
-
space: params.space,
|
|
15674
|
-
programId: toBuffer(params.programId.toBuffer())
|
|
15675
|
-
});
|
|
15676
|
-
keys = [{
|
|
15677
|
-
pubkey: params.accountPubkey,
|
|
15678
|
-
isSigner: false,
|
|
15884
|
+
if (params.payer) {
|
|
15885
|
+
keys.push({
|
|
15886
|
+
pubkey: params.payer,
|
|
15887
|
+
isSigner: true,
|
|
15679
15888
|
isWritable: true
|
|
15680
15889
|
}, {
|
|
15681
|
-
pubkey:
|
|
15682
|
-
isSigner:
|
|
15890
|
+
pubkey: SystemProgram.programId,
|
|
15891
|
+
isSigner: false,
|
|
15683
15892
|
isWritable: false
|
|
15684
|
-
}];
|
|
15685
|
-
} else {
|
|
15686
|
-
const type = SYSTEM_INSTRUCTION_LAYOUTS.Allocate;
|
|
15687
|
-
data = encodeData(type, {
|
|
15688
|
-
space: params.space
|
|
15689
15893
|
});
|
|
15690
|
-
keys = [{
|
|
15691
|
-
pubkey: params.accountPubkey,
|
|
15692
|
-
isSigner: true,
|
|
15693
|
-
isWritable: true
|
|
15694
|
-
}];
|
|
15695
15894
|
}
|
|
15696
15895
|
|
|
15697
15896
|
return new TransactionInstruction({
|
|
15698
|
-
keys,
|
|
15699
15897
|
programId: this.programId,
|
|
15700
|
-
|
|
15898
|
+
keys: keys,
|
|
15899
|
+
data: data
|
|
15900
|
+
});
|
|
15901
|
+
}
|
|
15902
|
+
|
|
15903
|
+
static deactivateLookupTable(params) {
|
|
15904
|
+
const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.DeactivateLookupTable;
|
|
15905
|
+
const data = encodeData(type);
|
|
15906
|
+
const keys = [{
|
|
15907
|
+
pubkey: params.lookupTable,
|
|
15908
|
+
isSigner: false,
|
|
15909
|
+
isWritable: true
|
|
15910
|
+
}, {
|
|
15911
|
+
pubkey: params.authority,
|
|
15912
|
+
isSigner: true,
|
|
15913
|
+
isWritable: false
|
|
15914
|
+
}];
|
|
15915
|
+
return new TransactionInstruction({
|
|
15916
|
+
programId: this.programId,
|
|
15917
|
+
keys: keys,
|
|
15918
|
+
data: data
|
|
15919
|
+
});
|
|
15920
|
+
}
|
|
15921
|
+
|
|
15922
|
+
static closeLookupTable(params) {
|
|
15923
|
+
const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CloseLookupTable;
|
|
15924
|
+
const data = encodeData(type);
|
|
15925
|
+
const keys = [{
|
|
15926
|
+
pubkey: params.lookupTable,
|
|
15927
|
+
isSigner: false,
|
|
15928
|
+
isWritable: true
|
|
15929
|
+
}, {
|
|
15930
|
+
pubkey: params.authority,
|
|
15931
|
+
isSigner: true,
|
|
15932
|
+
isWritable: false
|
|
15933
|
+
}, {
|
|
15934
|
+
pubkey: params.recipient,
|
|
15935
|
+
isSigner: false,
|
|
15936
|
+
isWritable: true
|
|
15937
|
+
}];
|
|
15938
|
+
return new TransactionInstruction({
|
|
15939
|
+
programId: this.programId,
|
|
15940
|
+
keys: keys,
|
|
15941
|
+
data: data
|
|
15701
15942
|
});
|
|
15702
15943
|
}
|
|
15703
15944
|
|
|
15704
15945
|
}
|
|
15705
|
-
|
|
15946
|
+
AddressLookupTableProgram.programId = new PublicKey('AddressLookupTab1e1111111111111111111111111');
|
|
15947
|
+
|
|
15948
|
+
const BPF_LOADER_DEPRECATED_PROGRAM_ID = new PublicKey('BPFLoader1111111111111111111111111111111111');
|
|
15949
|
+
|
|
15950
|
+
/**
|
|
15951
|
+
* Sign, send and confirm a transaction.
|
|
15952
|
+
*
|
|
15953
|
+
* If `commitment` option is not specified, defaults to 'max' commitment.
|
|
15954
|
+
*
|
|
15955
|
+
* @param {Connection} connection
|
|
15956
|
+
* @param {Transaction} transaction
|
|
15957
|
+
* @param {Array<Signer>} signers
|
|
15958
|
+
* @param {ConfirmOptions} [options]
|
|
15959
|
+
* @returns {Promise<TransactionSignature>}
|
|
15960
|
+
*/
|
|
15961
|
+
async function sendAndConfirmTransaction(connection, transaction, signers, options) {
|
|
15962
|
+
const sendOptions = options && {
|
|
15963
|
+
skipPreflight: options.skipPreflight,
|
|
15964
|
+
preflightCommitment: options.preflightCommitment || options.commitment,
|
|
15965
|
+
maxRetries: options.maxRetries,
|
|
15966
|
+
minContextSlot: options.minContextSlot
|
|
15967
|
+
};
|
|
15968
|
+
const signature = await connection.sendTransaction(transaction, signers, sendOptions);
|
|
15969
|
+
const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
|
|
15970
|
+
signature: signature,
|
|
15971
|
+
blockhash: transaction.recentBlockhash,
|
|
15972
|
+
lastValidBlockHeight: transaction.lastValidBlockHeight
|
|
15973
|
+
}, options && options.commitment)).value : (await connection.confirmTransaction(signature, options && options.commitment)).value;
|
|
15974
|
+
|
|
15975
|
+
if (status.err) {
|
|
15976
|
+
throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
|
|
15977
|
+
}
|
|
15978
|
+
|
|
15979
|
+
return signature;
|
|
15980
|
+
}
|
|
15981
|
+
|
|
15982
|
+
// zzz
|
|
15983
|
+
function sleep(ms) {
|
|
15984
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
15985
|
+
}
|
|
15706
15986
|
|
|
15707
15987
|
// rest of the Transaction fields
|
|
15708
15988
|
//
|
|
@@ -21556,8 +21836,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
21556
21836
|
*/
|
|
21557
21837
|
|
|
21558
21838
|
|
|
21559
|
-
async getBlock(slot,
|
|
21560
|
-
const
|
|
21839
|
+
async getBlock(slot, rawConfig) {
|
|
21840
|
+
const {
|
|
21841
|
+
commitment,
|
|
21842
|
+
config
|
|
21843
|
+
} = extractCommitmentFromConfig(rawConfig);
|
|
21844
|
+
|
|
21845
|
+
const args = this._buildArgsAtLeastConfirmed([slot], commitment, undefined
|
|
21846
|
+
/* encoding */
|
|
21847
|
+
, config);
|
|
21561
21848
|
|
|
21562
21849
|
const unsafeRes = await this._rpcRequest('getBlock', args);
|
|
21563
21850
|
const res = create(unsafeRes, GetBlockRpcResult);
|
|
@@ -21643,8 +21930,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
21643
21930
|
*/
|
|
21644
21931
|
|
|
21645
21932
|
|
|
21646
|
-
async getTransaction(signature,
|
|
21647
|
-
const
|
|
21933
|
+
async getTransaction(signature, rawConfig) {
|
|
21934
|
+
const {
|
|
21935
|
+
commitment,
|
|
21936
|
+
config
|
|
21937
|
+
} = extractCommitmentFromConfig(rawConfig);
|
|
21938
|
+
|
|
21939
|
+
const args = this._buildArgsAtLeastConfirmed([signature], commitment, undefined
|
|
21940
|
+
/* encoding */
|
|
21941
|
+
, config);
|
|
21648
21942
|
|
|
21649
21943
|
const unsafeRes = await this._rpcRequest('getTransaction', args);
|
|
21650
21944
|
const res = create(unsafeRes, GetTransactionRpcResult);
|
|
@@ -21666,8 +21960,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
21666
21960
|
*/
|
|
21667
21961
|
|
|
21668
21962
|
|
|
21669
|
-
async getParsedTransaction(signature,
|
|
21670
|
-
const
|
|
21963
|
+
async getParsedTransaction(signature, commitmentOrConfig) {
|
|
21964
|
+
const {
|
|
21965
|
+
commitment,
|
|
21966
|
+
config
|
|
21967
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
21968
|
+
|
|
21969
|
+
const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed', config);
|
|
21671
21970
|
|
|
21672
21971
|
const unsafeRes = await this._rpcRequest('getTransaction', args);
|
|
21673
21972
|
const res = create(unsafeRes, GetParsedTransactionRpcResult);
|
|
@@ -21683,9 +21982,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
21683
21982
|
*/
|
|
21684
21983
|
|
|
21685
21984
|
|
|
21686
|
-
async getParsedTransactions(signatures,
|
|
21985
|
+
async getParsedTransactions(signatures, commitmentOrConfig) {
|
|
21986
|
+
const {
|
|
21987
|
+
commitment,
|
|
21988
|
+
config
|
|
21989
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
21687
21990
|
const batch = signatures.map(signature => {
|
|
21688
|
-
const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed');
|
|
21991
|
+
const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed', config);
|
|
21689
21992
|
|
|
21690
21993
|
return {
|
|
21691
21994
|
methodName: 'getTransaction',
|
|
@@ -21710,9 +22013,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
21710
22013
|
*/
|
|
21711
22014
|
|
|
21712
22015
|
|
|
21713
|
-
async getTransactions(signatures,
|
|
22016
|
+
async getTransactions(signatures, commitmentOrConfig) {
|
|
22017
|
+
const {
|
|
22018
|
+
commitment,
|
|
22019
|
+
config
|
|
22020
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
21714
22021
|
const batch = signatures.map(signature => {
|
|
21715
|
-
const args = this._buildArgsAtLeastConfirmed([signature], commitment
|
|
22022
|
+
const args = this._buildArgsAtLeastConfirmed([signature], commitment, undefined
|
|
22023
|
+
/* encoding */
|
|
22024
|
+
, config);
|
|
21716
22025
|
|
|
21717
22026
|
return {
|
|
21718
22027
|
methodName: 'getTransaction',
|
|
@@ -22154,6 +22463,28 @@ var solanaWeb3 = (function (exports) {
|
|
|
22154
22463
|
this._pollingBlockhash = false;
|
|
22155
22464
|
}
|
|
22156
22465
|
}
|
|
22466
|
+
/**
|
|
22467
|
+
* get the stake minimum delegation
|
|
22468
|
+
*/
|
|
22469
|
+
|
|
22470
|
+
|
|
22471
|
+
async getStakeMinimumDelegation(config) {
|
|
22472
|
+
const {
|
|
22473
|
+
commitment,
|
|
22474
|
+
config: configArg
|
|
22475
|
+
} = extractCommitmentFromConfig(config);
|
|
22476
|
+
|
|
22477
|
+
const args = this._buildArgs([], commitment, 'base64', configArg);
|
|
22478
|
+
|
|
22479
|
+
const unsafeRes = await this._rpcRequest('getStakeMinimumDelegation', args);
|
|
22480
|
+
const res = create(unsafeRes, jsonRpcResultAndContext(number()));
|
|
22481
|
+
|
|
22482
|
+
if ('error' in res) {
|
|
22483
|
+
throw new SolanaJSONRPCError(res.error, `failed to get stake minimum delegation`);
|
|
22484
|
+
}
|
|
22485
|
+
|
|
22486
|
+
return res.result;
|
|
22487
|
+
}
|
|
22157
22488
|
/**
|
|
22158
22489
|
* Simulate a transaction
|
|
22159
22490
|
*/
|
|
@@ -30385,6 +30716,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
30385
30716
|
const LAMPORTS_PER_SOL = 1000000000;
|
|
30386
30717
|
|
|
30387
30718
|
exports.Account = Account;
|
|
30719
|
+
exports.AddressLookupTableInstruction = AddressLookupTableInstruction;
|
|
30720
|
+
exports.AddressLookupTableProgram = AddressLookupTableProgram;
|
|
30388
30721
|
exports.Authorized = Authorized;
|
|
30389
30722
|
exports.BLOCKHASH_CACHE_TIMEOUT_MS = BLOCKHASH_CACHE_TIMEOUT_MS;
|
|
30390
30723
|
exports.BPF_LOADER_DEPRECATED_PROGRAM_ID = BPF_LOADER_DEPRECATED_PROGRAM_ID;
|
|
@@ -30400,6 +30733,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
30400
30733
|
exports.FeeCalculatorLayout = FeeCalculatorLayout;
|
|
30401
30734
|
exports.Keypair = Keypair;
|
|
30402
30735
|
exports.LAMPORTS_PER_SOL = LAMPORTS_PER_SOL;
|
|
30736
|
+
exports.LOOKUP_TABLE_INSTRUCTION_LAYOUTS = LOOKUP_TABLE_INSTRUCTION_LAYOUTS;
|
|
30403
30737
|
exports.Loader = Loader;
|
|
30404
30738
|
exports.Lockup = Lockup;
|
|
30405
30739
|
exports.MAX_SEED_LENGTH = MAX_SEED_LENGTH;
|