@solana/web3.js 1.41.2 → 1.41.5
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 +93 -9
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +139 -56
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +110 -12
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +40 -4
- package/lib/index.esm.js +157 -60
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +12206 -12122
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +2 -2
- package/lib/index.iife.min.js.map +1 -1
- package/package.json +4 -3
- package/src/index.ts +1 -0
- package/src/system-program.ts +39 -10
- package/src/transaction.ts +4 -6
package/lib/index.browser.cjs.js
CHANGED
|
@@ -2521,11 +2521,7 @@ class Transaction {
|
|
|
2521
2521
|
|
|
2522
2522
|
|
|
2523
2523
|
compileMessage() {
|
|
2524
|
-
if (this._message) {
|
|
2525
|
-
if (JSON.stringify(this.toJSON()) !== JSON.stringify(this._json)) {
|
|
2526
|
-
throw new Error('Transaction message mutated after being populated from Message');
|
|
2527
|
-
}
|
|
2528
|
-
|
|
2524
|
+
if (this._message && JSON.stringify(this.toJSON()) === JSON.stringify(this._json)) {
|
|
2529
2525
|
return this._message;
|
|
2530
2526
|
}
|
|
2531
2527
|
|
|
@@ -3099,6 +3095,92 @@ function sleep(ms) {
|
|
|
3099
3095
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
3100
3096
|
}
|
|
3101
3097
|
|
|
3098
|
+
const encodeDecode = (layout) => {
|
|
3099
|
+
const decode = layout.decode.bind(layout);
|
|
3100
|
+
const encode = layout.encode.bind(layout);
|
|
3101
|
+
return { decode, encode };
|
|
3102
|
+
};
|
|
3103
|
+
|
|
3104
|
+
var browser = {};
|
|
3105
|
+
|
|
3106
|
+
Object.defineProperty(browser, "__esModule", { value: true });
|
|
3107
|
+
/**
|
|
3108
|
+
* Convert a little-endian buffer into a BigInt.
|
|
3109
|
+
* @param buf The little-endian buffer to convert
|
|
3110
|
+
* @returns A BigInt with the little-endian representation of buf.
|
|
3111
|
+
*/
|
|
3112
|
+
function toBigIntLE(buf) {
|
|
3113
|
+
{
|
|
3114
|
+
const reversed = Buffer.from(buf);
|
|
3115
|
+
reversed.reverse();
|
|
3116
|
+
const hex = reversed.toString('hex');
|
|
3117
|
+
if (hex.length === 0) {
|
|
3118
|
+
return BigInt(0);
|
|
3119
|
+
}
|
|
3120
|
+
return BigInt(`0x${hex}`);
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
3123
|
+
var toBigIntLE_1 = browser.toBigIntLE = toBigIntLE;
|
|
3124
|
+
/**
|
|
3125
|
+
* Convert a big-endian buffer into a BigInt
|
|
3126
|
+
* @param buf The big-endian buffer to convert.
|
|
3127
|
+
* @returns A BigInt with the big-endian representation of buf.
|
|
3128
|
+
*/
|
|
3129
|
+
function toBigIntBE(buf) {
|
|
3130
|
+
{
|
|
3131
|
+
const hex = buf.toString('hex');
|
|
3132
|
+
if (hex.length === 0) {
|
|
3133
|
+
return BigInt(0);
|
|
3134
|
+
}
|
|
3135
|
+
return BigInt(`0x${hex}`);
|
|
3136
|
+
}
|
|
3137
|
+
}
|
|
3138
|
+
browser.toBigIntBE = toBigIntBE;
|
|
3139
|
+
/**
|
|
3140
|
+
* Convert a BigInt to a little-endian buffer.
|
|
3141
|
+
* @param num The BigInt to convert.
|
|
3142
|
+
* @param width The number of bytes that the resulting buffer should be.
|
|
3143
|
+
* @returns A little-endian buffer representation of num.
|
|
3144
|
+
*/
|
|
3145
|
+
function toBufferLE(num, width) {
|
|
3146
|
+
{
|
|
3147
|
+
const hex = num.toString(16);
|
|
3148
|
+
const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
|
|
3149
|
+
buffer.reverse();
|
|
3150
|
+
return buffer;
|
|
3151
|
+
}
|
|
3152
|
+
}
|
|
3153
|
+
var toBufferLE_1 = browser.toBufferLE = toBufferLE;
|
|
3154
|
+
/**
|
|
3155
|
+
* Convert a BigInt to a big-endian buffer.
|
|
3156
|
+
* @param num The BigInt to convert.
|
|
3157
|
+
* @param width The number of bytes that the resulting buffer should be.
|
|
3158
|
+
* @returns A big-endian buffer representation of num.
|
|
3159
|
+
*/
|
|
3160
|
+
function toBufferBE(num, width) {
|
|
3161
|
+
{
|
|
3162
|
+
const hex = num.toString(16);
|
|
3163
|
+
return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3166
|
+
browser.toBufferBE = toBufferBE;
|
|
3167
|
+
|
|
3168
|
+
const bigInt = (length) => (property) => {
|
|
3169
|
+
const layout = BufferLayout.blob(length, property);
|
|
3170
|
+
const { encode, decode } = encodeDecode(layout);
|
|
3171
|
+
const bigIntLayout = layout;
|
|
3172
|
+
bigIntLayout.decode = (buffer, offset) => {
|
|
3173
|
+
const src = decode(buffer, offset);
|
|
3174
|
+
return toBigIntLE_1(Buffer.from(src));
|
|
3175
|
+
};
|
|
3176
|
+
bigIntLayout.encode = (bigInt, buffer, offset) => {
|
|
3177
|
+
const src = toBufferLE_1(bigInt, length);
|
|
3178
|
+
return encode(src, buffer, offset);
|
|
3179
|
+
};
|
|
3180
|
+
return bigIntLayout;
|
|
3181
|
+
};
|
|
3182
|
+
const u64 = bigInt(8);
|
|
3183
|
+
|
|
3102
3184
|
/**
|
|
3103
3185
|
* Populate a buffer of instruction data using an InstructionType
|
|
3104
3186
|
* @internal
|
|
@@ -3488,7 +3570,7 @@ const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
|
3488
3570
|
},
|
|
3489
3571
|
Transfer: {
|
|
3490
3572
|
index: 2,
|
|
3491
|
-
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'),
|
|
3573
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), u64('lamports')])
|
|
3492
3574
|
},
|
|
3493
3575
|
CreateWithSeed: {
|
|
3494
3576
|
index: 3,
|
|
@@ -3524,7 +3606,7 @@ const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
|
3524
3606
|
},
|
|
3525
3607
|
TransferWithSeed: {
|
|
3526
3608
|
index: 11,
|
|
3527
|
-
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'),
|
|
3609
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), u64('lamports'), rustString('seed'), publicKey('programId')])
|
|
3528
3610
|
}
|
|
3529
3611
|
});
|
|
3530
3612
|
/**
|
|
@@ -3577,7 +3659,7 @@ class SystemProgram {
|
|
|
3577
3659
|
if ('basePubkey' in params) {
|
|
3578
3660
|
const type = SYSTEM_INSTRUCTION_LAYOUTS.TransferWithSeed;
|
|
3579
3661
|
data = encodeData(type, {
|
|
3580
|
-
lamports: params.lamports,
|
|
3662
|
+
lamports: BigInt(params.lamports),
|
|
3581
3663
|
seed: params.seed,
|
|
3582
3664
|
programId: toBuffer(params.programId.toBuffer())
|
|
3583
3665
|
});
|
|
@@ -3597,7 +3679,7 @@ class SystemProgram {
|
|
|
3597
3679
|
} else {
|
|
3598
3680
|
const type = SYSTEM_INSTRUCTION_LAYOUTS.Transfer;
|
|
3599
3681
|
data = encodeData(type, {
|
|
3600
|
-
lamports: params.lamports
|
|
3682
|
+
lamports: BigInt(params.lamports)
|
|
3601
3683
|
});
|
|
3602
3684
|
keys = [{
|
|
3603
3685
|
pubkey: params.fromPubkey,
|
|
@@ -10181,7 +10263,9 @@ exports.MAX_SEED_LENGTH = MAX_SEED_LENGTH;
|
|
|
10181
10263
|
exports.Message = Message;
|
|
10182
10264
|
exports.NONCE_ACCOUNT_LENGTH = NONCE_ACCOUNT_LENGTH;
|
|
10183
10265
|
exports.NonceAccount = NonceAccount;
|
|
10266
|
+
exports.PACKET_DATA_SIZE = PACKET_DATA_SIZE;
|
|
10184
10267
|
exports.PublicKey = PublicKey;
|
|
10268
|
+
exports.SIGNATURE_LENGTH_IN_BYTES = SIGNATURE_LENGTH_IN_BYTES;
|
|
10185
10269
|
exports.SOLANA_SCHEMA = SOLANA_SCHEMA;
|
|
10186
10270
|
exports.STAKE_CONFIG_ID = STAKE_CONFIG_ID;
|
|
10187
10271
|
exports.STAKE_INSTRUCTION_LAYOUTS = STAKE_INSTRUCTION_LAYOUTS;
|