@solana/web3.js 1.42.0 → 1.43.2
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 +111 -588
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +110 -586
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +164 -62
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +54 -11
- package/lib/index.esm.js +162 -59
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +26048 -26051
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +6 -4
- package/lib/index.iife.min.js.map +1 -1
- package/package.json +8 -7
- package/src/__forks__/browser/fetch-impl.ts +4 -0
- package/src/compute-budget.ts +92 -3
- package/src/connection.ts +24 -19
- package/src/fetch-impl.ts +13 -0
- package/src/system-program.ts +1 -1
- package/src/transaction.ts +0 -1
- package/src/util/bigint.ts +43 -0
- package/src/util/send-and-confirm-raw-transaction.ts +6 -6
package/lib/index.cjs.js
CHANGED
|
@@ -8,13 +8,13 @@ var BN = require('bn.js');
|
|
|
8
8
|
var bs58 = require('bs58');
|
|
9
9
|
var borsh = require('borsh');
|
|
10
10
|
var BufferLayout = require('@solana/buffer-layout');
|
|
11
|
-
var
|
|
12
|
-
var crossFetch = require('cross-fetch');
|
|
11
|
+
var bigintBuffer = require('bigint-buffer');
|
|
13
12
|
var superstruct = require('superstruct');
|
|
14
13
|
var rpcWebsockets = require('rpc-websockets');
|
|
15
14
|
var RpcClient = require('jayson/lib/client/browser');
|
|
16
15
|
var http = require('http');
|
|
17
16
|
var https = require('https');
|
|
17
|
+
var nodeFetch = require('node-fetch');
|
|
18
18
|
var secp256k1 = require('secp256k1');
|
|
19
19
|
var sha3 = require('js-sha3');
|
|
20
20
|
|
|
@@ -42,10 +42,10 @@ var nacl__default = /*#__PURE__*/_interopDefaultLegacy(nacl);
|
|
|
42
42
|
var BN__default = /*#__PURE__*/_interopDefaultLegacy(BN);
|
|
43
43
|
var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
|
|
44
44
|
var BufferLayout__namespace = /*#__PURE__*/_interopNamespace(BufferLayout);
|
|
45
|
-
var crossFetch__default = /*#__PURE__*/_interopDefaultLegacy(crossFetch);
|
|
46
45
|
var RpcClient__default = /*#__PURE__*/_interopDefaultLegacy(RpcClient);
|
|
47
46
|
var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
|
|
48
47
|
var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
|
|
48
|
+
var nodeFetch__namespace = /*#__PURE__*/_interopNamespace(nodeFetch);
|
|
49
49
|
var secp256k1__default = /*#__PURE__*/_interopDefaultLegacy(secp256k1);
|
|
50
50
|
var sha3__default = /*#__PURE__*/_interopDefaultLegacy(sha3);
|
|
51
51
|
|
|
@@ -79,43 +79,52 @@ var inherits$1 = {exports: {}};
|
|
|
79
79
|
|
|
80
80
|
var inherits_browser = {exports: {}};
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
82
|
+
var hasRequiredInherits_browser;
|
|
83
|
+
|
|
84
|
+
function requireInherits_browser () {
|
|
85
|
+
if (hasRequiredInherits_browser) return inherits_browser.exports;
|
|
86
|
+
hasRequiredInherits_browser = 1;
|
|
87
|
+
if (typeof Object.create === 'function') {
|
|
88
|
+
// implementation from standard node.js 'util' module
|
|
89
|
+
inherits_browser.exports = function inherits(ctor, superCtor) {
|
|
90
|
+
if (superCtor) {
|
|
91
|
+
ctor.super_ = superCtor;
|
|
92
|
+
ctor.prototype = Object.create(superCtor.prototype, {
|
|
93
|
+
constructor: {
|
|
94
|
+
value: ctor,
|
|
95
|
+
enumerable: false,
|
|
96
|
+
writable: true,
|
|
97
|
+
configurable: true
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
} else {
|
|
103
|
+
// old school shim for old browsers
|
|
104
|
+
inherits_browser.exports = function inherits(ctor, superCtor) {
|
|
105
|
+
if (superCtor) {
|
|
106
|
+
ctor.super_ = superCtor;
|
|
107
|
+
var TempCtor = function () {};
|
|
108
|
+
TempCtor.prototype = superCtor.prototype;
|
|
109
|
+
ctor.prototype = new TempCtor();
|
|
110
|
+
ctor.prototype.constructor = ctor;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return inherits_browser.exports;
|
|
108
115
|
}
|
|
109
116
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
(function (module) {
|
|
118
|
+
try {
|
|
119
|
+
var util = require('util');
|
|
120
|
+
/* istanbul ignore next */
|
|
121
|
+
if (typeof util.inherits !== 'function') throw '';
|
|
122
|
+
module.exports = util.inherits;
|
|
123
|
+
} catch (e) {
|
|
124
|
+
/* istanbul ignore next */
|
|
125
|
+
module.exports = requireInherits_browser();
|
|
126
|
+
}
|
|
127
|
+
} (inherits$1));
|
|
119
128
|
|
|
120
129
|
var assert$5 = minimalisticAssert;
|
|
121
130
|
var inherits = inherits$1.exports;
|
|
@@ -1307,22 +1316,22 @@ Hmac.prototype.digest = function digest(enc) {
|
|
|
1307
1316
|
};
|
|
1308
1317
|
|
|
1309
1318
|
(function (exports) {
|
|
1310
|
-
var hash = exports;
|
|
1311
|
-
|
|
1312
|
-
hash.utils = utils$9;
|
|
1313
|
-
hash.common = common$5;
|
|
1314
|
-
hash.sha = sha;
|
|
1315
|
-
hash.ripemd = ripemd;
|
|
1316
|
-
hash.hmac = hmac;
|
|
1317
|
-
|
|
1318
|
-
// Proxy hash functions to the main object
|
|
1319
|
-
hash.sha1 = hash.sha.sha1;
|
|
1320
|
-
hash.sha256 = hash.sha.sha256;
|
|
1321
|
-
hash.sha224 = hash.sha.sha224;
|
|
1322
|
-
hash.sha384 = hash.sha.sha384;
|
|
1323
|
-
hash.sha512 = hash.sha.sha512;
|
|
1324
|
-
hash.ripemd160 = hash.ripemd.ripemd160;
|
|
1325
|
-
}(hash$1));
|
|
1319
|
+
var hash = exports;
|
|
1320
|
+
|
|
1321
|
+
hash.utils = utils$9;
|
|
1322
|
+
hash.common = common$5;
|
|
1323
|
+
hash.sha = sha;
|
|
1324
|
+
hash.ripemd = ripemd;
|
|
1325
|
+
hash.hmac = hmac;
|
|
1326
|
+
|
|
1327
|
+
// Proxy hash functions to the main object
|
|
1328
|
+
hash.sha1 = hash.sha.sha1;
|
|
1329
|
+
hash.sha256 = hash.sha.sha256;
|
|
1330
|
+
hash.sha224 = hash.sha.sha224;
|
|
1331
|
+
hash.sha384 = hash.sha.sha384;
|
|
1332
|
+
hash.sha512 = hash.sha.sha512;
|
|
1333
|
+
hash.ripemd160 = hash.ripemd.ripemd160;
|
|
1334
|
+
} (hash$1));
|
|
1326
1335
|
|
|
1327
1336
|
var hash = hash$1;
|
|
1328
1337
|
|
|
@@ -2840,8 +2849,6 @@ class Transaction {
|
|
|
2840
2849
|
const message = this._compile();
|
|
2841
2850
|
|
|
2842
2851
|
this._partialSign(message, ...uniqueSigners);
|
|
2843
|
-
|
|
2844
|
-
this._verifySignatures(message.serialize(), true);
|
|
2845
2852
|
}
|
|
2846
2853
|
/**
|
|
2847
2854
|
* Partially sign a transaction with the specified accounts. All accounts must
|
|
@@ -3221,6 +3228,38 @@ class NonceAccount {
|
|
|
3221
3228
|
|
|
3222
3229
|
}
|
|
3223
3230
|
|
|
3231
|
+
const encodeDecode = layout => {
|
|
3232
|
+
const decode = layout.decode.bind(layout);
|
|
3233
|
+
const encode = layout.encode.bind(layout);
|
|
3234
|
+
return {
|
|
3235
|
+
decode,
|
|
3236
|
+
encode
|
|
3237
|
+
};
|
|
3238
|
+
};
|
|
3239
|
+
|
|
3240
|
+
const bigInt = length => property => {
|
|
3241
|
+
const layout = BufferLayout.blob(length, property);
|
|
3242
|
+
const {
|
|
3243
|
+
encode,
|
|
3244
|
+
decode
|
|
3245
|
+
} = encodeDecode(layout);
|
|
3246
|
+
const bigIntLayout = layout;
|
|
3247
|
+
|
|
3248
|
+
bigIntLayout.decode = (buffer$1, offset) => {
|
|
3249
|
+
const src = decode(buffer$1, offset);
|
|
3250
|
+
return bigintBuffer.toBigIntLE(buffer.Buffer.from(src));
|
|
3251
|
+
};
|
|
3252
|
+
|
|
3253
|
+
bigIntLayout.encode = (bigInt, buffer, offset) => {
|
|
3254
|
+
const src = bigintBuffer.toBufferLE(bigInt, length);
|
|
3255
|
+
return encode(src, buffer, offset);
|
|
3256
|
+
};
|
|
3257
|
+
|
|
3258
|
+
return bigIntLayout;
|
|
3259
|
+
};
|
|
3260
|
+
|
|
3261
|
+
const u64 = bigInt(8);
|
|
3262
|
+
|
|
3224
3263
|
/**
|
|
3225
3264
|
* Create account system transaction params
|
|
3226
3265
|
*/
|
|
@@ -3522,7 +3561,7 @@ const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
|
3522
3561
|
},
|
|
3523
3562
|
Transfer: {
|
|
3524
3563
|
index: 2,
|
|
3525
|
-
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'),
|
|
3564
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), u64('lamports')])
|
|
3526
3565
|
},
|
|
3527
3566
|
CreateWithSeed: {
|
|
3528
3567
|
index: 3,
|
|
@@ -3558,7 +3597,7 @@ const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
|
3558
3597
|
},
|
|
3559
3598
|
TransferWithSeed: {
|
|
3560
3599
|
index: 11,
|
|
3561
|
-
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'),
|
|
3600
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), u64('lamports'), rustString('seed'), publicKey('programId')])
|
|
3562
3601
|
}
|
|
3563
3602
|
});
|
|
3564
3603
|
/**
|
|
@@ -4199,6 +4238,34 @@ class ComputeBudgetInstruction {
|
|
|
4199
4238
|
bytes
|
|
4200
4239
|
};
|
|
4201
4240
|
}
|
|
4241
|
+
/**
|
|
4242
|
+
* Decode set compute unit limit compute budget instruction and retrieve the instruction params.
|
|
4243
|
+
*/
|
|
4244
|
+
|
|
4245
|
+
|
|
4246
|
+
static decodeSetComputeUnitLimit(instruction) {
|
|
4247
|
+
this.checkProgramId(instruction.programId);
|
|
4248
|
+
const {
|
|
4249
|
+
units
|
|
4250
|
+
} = decodeData(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.SetComputeUnitLimit, instruction.data);
|
|
4251
|
+
return {
|
|
4252
|
+
units
|
|
4253
|
+
};
|
|
4254
|
+
}
|
|
4255
|
+
/**
|
|
4256
|
+
* Decode set compute unit price compute budget instruction and retrieve the instruction params.
|
|
4257
|
+
*/
|
|
4258
|
+
|
|
4259
|
+
|
|
4260
|
+
static decodeSetComputeUnitPrice(instruction) {
|
|
4261
|
+
this.checkProgramId(instruction.programId);
|
|
4262
|
+
const {
|
|
4263
|
+
microLamports
|
|
4264
|
+
} = decodeData(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.SetComputeUnitPrice, instruction.data);
|
|
4265
|
+
return {
|
|
4266
|
+
microLamports
|
|
4267
|
+
};
|
|
4268
|
+
}
|
|
4202
4269
|
/**
|
|
4203
4270
|
* @internal
|
|
4204
4271
|
*/
|
|
@@ -4227,6 +4294,14 @@ const COMPUTE_BUDGET_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
|
4227
4294
|
RequestHeapFrame: {
|
|
4228
4295
|
index: 1,
|
|
4229
4296
|
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u8('instruction'), BufferLayout__namespace.u32('bytes')])
|
|
4297
|
+
},
|
|
4298
|
+
SetComputeUnitLimit: {
|
|
4299
|
+
index: 2,
|
|
4300
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u8('instruction'), BufferLayout__namespace.u32('units')])
|
|
4301
|
+
},
|
|
4302
|
+
SetComputeUnitPrice: {
|
|
4303
|
+
index: 3,
|
|
4304
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u8('instruction'), u64('microLamports')])
|
|
4230
4305
|
}
|
|
4231
4306
|
});
|
|
4232
4307
|
/**
|
|
@@ -4263,6 +4338,28 @@ class ComputeBudgetProgram {
|
|
|
4263
4338
|
});
|
|
4264
4339
|
}
|
|
4265
4340
|
|
|
4341
|
+
static setComputeUnitLimit(params) {
|
|
4342
|
+
const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.SetComputeUnitLimit;
|
|
4343
|
+
const data = encodeData(type, params);
|
|
4344
|
+
return new TransactionInstruction({
|
|
4345
|
+
keys: [],
|
|
4346
|
+
programId: this.programId,
|
|
4347
|
+
data
|
|
4348
|
+
});
|
|
4349
|
+
}
|
|
4350
|
+
|
|
4351
|
+
static setComputeUnitPrice(params) {
|
|
4352
|
+
const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.SetComputeUnitPrice;
|
|
4353
|
+
const data = encodeData(type, {
|
|
4354
|
+
microLamports: BigInt(params.microLamports)
|
|
4355
|
+
});
|
|
4356
|
+
return new TransactionInstruction({
|
|
4357
|
+
keys: [],
|
|
4358
|
+
programId: this.programId,
|
|
4359
|
+
data
|
|
4360
|
+
});
|
|
4361
|
+
}
|
|
4362
|
+
|
|
4266
4363
|
}
|
|
4267
4364
|
ComputeBudgetProgram.programId = new PublicKey('ComputeBudget111111111111111111111111111111');
|
|
4268
4365
|
|
|
@@ -4496,6 +4593,11 @@ class SendTransactionError extends Error {
|
|
|
4496
4593
|
|
|
4497
4594
|
}
|
|
4498
4595
|
|
|
4596
|
+
async function fetchImpl (input, init) {
|
|
4597
|
+
const processedInput = typeof input === 'string' && input.slice(0, 2) === '//' ? 'https:' + input : input;
|
|
4598
|
+
return await nodeFetch__namespace.default(processedInput, init);
|
|
4599
|
+
}
|
|
4600
|
+
|
|
4499
4601
|
// TODO: These constants should be removed in favor of reading them out of a
|
|
4500
4602
|
// Syscall account
|
|
4501
4603
|
|
|
@@ -4745,7 +4847,7 @@ const BlockProductionResponseStruct = jsonRpcResultAndContext(superstruct.type({
|
|
|
4745
4847
|
*/
|
|
4746
4848
|
|
|
4747
4849
|
function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit) {
|
|
4748
|
-
const fetch = customFetch ? customFetch :
|
|
4850
|
+
const fetch = customFetch ? customFetch : fetchImpl;
|
|
4749
4851
|
let agentManager;
|
|
4750
4852
|
|
|
4751
4853
|
{
|
|
@@ -4755,10 +4857,10 @@ function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddlewar
|
|
|
4755
4857
|
let fetchWithMiddleware;
|
|
4756
4858
|
|
|
4757
4859
|
if (fetchMiddleware) {
|
|
4758
|
-
fetchWithMiddleware = async (
|
|
4860
|
+
fetchWithMiddleware = async (info, init) => {
|
|
4759
4861
|
const modifiedFetchArgs = await new Promise((resolve, reject) => {
|
|
4760
4862
|
try {
|
|
4761
|
-
fetchMiddleware(
|
|
4863
|
+
fetchMiddleware(info, init, (modifiedInfo, modifiedInit) => resolve([modifiedInfo, modifiedInit]));
|
|
4762
4864
|
} catch (error) {
|
|
4763
4865
|
reject(error);
|
|
4764
4866
|
}
|
|
@@ -9704,7 +9806,7 @@ VoteProgram.space = 3731;
|
|
|
9704
9806
|
*
|
|
9705
9807
|
* @param {Connection} connection
|
|
9706
9808
|
* @param {Buffer} rawTransaction
|
|
9707
|
-
* @param {
|
|
9809
|
+
* @param {BlockheightBasedTransactionConfirmationStrategy} confirmationStrategy
|
|
9708
9810
|
* @param {ConfirmOptions} [options]
|
|
9709
9811
|
* @returns {Promise<TransactionSignature>}
|
|
9710
9812
|
*/
|