@solana/web3.js 1.37.2 → 1.39.1
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/README.md +4 -3
- package/lib/index.browser.cjs.js +64 -4
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +64 -4
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +67 -7
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.esm.js +64 -4
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +64 -4
- 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 +2 -7
- package/src/connection.ts +10 -1
- package/src/transaction.ts +85 -0
- package/module.flow.js +0 -4412
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
declare module '@solana/web3.js' {
|
|
3
3
|
import {Buffer} from 'buffer';
|
|
4
|
+
import crossFetch from 'cross-fetch';
|
|
4
5
|
|
|
5
6
|
export class Struct {
|
|
6
7
|
constructor(properties: any);
|
|
@@ -1418,6 +1419,8 @@ declare module '@solana/web3.js' {
|
|
|
1418
1419
|
wsEndpoint?: string;
|
|
1419
1420
|
/** Optional HTTP headers object */
|
|
1420
1421
|
httpHeaders?: HttpHeaders;
|
|
1422
|
+
/** Optional custom fetch function */
|
|
1423
|
+
fetch?: typeof crossFetch;
|
|
1421
1424
|
/** Optional fetch middleware callback */
|
|
1422
1425
|
fetchMiddleware?: FetchMiddleware;
|
|
1423
1426
|
/** Optional Disable retrying calls when server responds with HTTP 429 (Too Many Requests) */
|
package/lib/index.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ import BN from 'bn.js';
|
|
|
4
4
|
import bs58 from 'bs58';
|
|
5
5
|
import { serialize, deserialize, deserializeUnchecked } from 'borsh';
|
|
6
6
|
import * as BufferLayout from '@solana/buffer-layout';
|
|
7
|
-
import
|
|
7
|
+
import crossFetch from 'cross-fetch';
|
|
8
8
|
import { coerce, instance, string, tuple, literal, unknown, union, type, optional, any, number, array, nullable, create, boolean, record, assert as assert$7 } from 'superstruct';
|
|
9
9
|
import { Client } from 'rpc-websockets';
|
|
10
10
|
import RpcClient from 'jayson/lib/client/browser';
|
|
@@ -2368,6 +2368,26 @@ class TransactionInstruction {
|
|
|
2368
2368
|
this.data = opts.data;
|
|
2369
2369
|
}
|
|
2370
2370
|
}
|
|
2371
|
+
/**
|
|
2372
|
+
* @internal
|
|
2373
|
+
*/
|
|
2374
|
+
|
|
2375
|
+
|
|
2376
|
+
toJSON() {
|
|
2377
|
+
return {
|
|
2378
|
+
keys: this.keys.map(({
|
|
2379
|
+
pubkey,
|
|
2380
|
+
isSigner,
|
|
2381
|
+
isWritable
|
|
2382
|
+
}) => ({
|
|
2383
|
+
pubkey: pubkey.toJSON(),
|
|
2384
|
+
isSigner,
|
|
2385
|
+
isWritable
|
|
2386
|
+
})),
|
|
2387
|
+
programId: this.programId.toJSON(),
|
|
2388
|
+
data: [...this.data]
|
|
2389
|
+
};
|
|
2390
|
+
}
|
|
2371
2391
|
|
|
2372
2392
|
}
|
|
2373
2393
|
/**
|
|
@@ -2407,8 +2427,33 @@ class Transaction {
|
|
|
2407
2427
|
this.instructions = [];
|
|
2408
2428
|
this.recentBlockhash = void 0;
|
|
2409
2429
|
this.nonceInfo = void 0;
|
|
2430
|
+
this._message = void 0;
|
|
2431
|
+
this._json = void 0;
|
|
2410
2432
|
opts && Object.assign(this, opts);
|
|
2411
2433
|
}
|
|
2434
|
+
/**
|
|
2435
|
+
* @internal
|
|
2436
|
+
*/
|
|
2437
|
+
|
|
2438
|
+
|
|
2439
|
+
toJSON() {
|
|
2440
|
+
return {
|
|
2441
|
+
recentBlockhash: this.recentBlockhash || null,
|
|
2442
|
+
feePayer: this.feePayer ? this.feePayer.toJSON() : null,
|
|
2443
|
+
nonceInfo: this.nonceInfo ? {
|
|
2444
|
+
nonce: this.nonceInfo.nonce,
|
|
2445
|
+
nonceInstruction: this.nonceInfo.nonceInstruction.toJSON()
|
|
2446
|
+
} : null,
|
|
2447
|
+
instructions: this.instructions.map(instruction => instruction.toJSON()),
|
|
2448
|
+
signatures: this.signatures.map(({
|
|
2449
|
+
publicKey,
|
|
2450
|
+
signature
|
|
2451
|
+
}) => ({
|
|
2452
|
+
publicKey: publicKey.toJSON(),
|
|
2453
|
+
signature: signature ? [...signature] : null
|
|
2454
|
+
}))
|
|
2455
|
+
};
|
|
2456
|
+
}
|
|
2412
2457
|
/**
|
|
2413
2458
|
* Add one or more instructions to this Transaction
|
|
2414
2459
|
*/
|
|
@@ -2436,6 +2481,14 @@ class Transaction {
|
|
|
2436
2481
|
|
|
2437
2482
|
|
|
2438
2483
|
compileMessage() {
|
|
2484
|
+
if (this._message) {
|
|
2485
|
+
if (JSON.stringify(this.toJSON()) !== JSON.stringify(this._json)) {
|
|
2486
|
+
throw new Error('Transaction mutated after being populated from Message');
|
|
2487
|
+
}
|
|
2488
|
+
|
|
2489
|
+
return this._message;
|
|
2490
|
+
}
|
|
2491
|
+
|
|
2439
2492
|
const {
|
|
2440
2493
|
nonceInfo
|
|
2441
2494
|
} = this;
|
|
@@ -2957,6 +3010,8 @@ class Transaction {
|
|
|
2957
3010
|
data: bs58.decode(instruction.data)
|
|
2958
3011
|
}));
|
|
2959
3012
|
});
|
|
3013
|
+
transaction._message = message;
|
|
3014
|
+
transaction._json = transaction.toJSON();
|
|
2960
3015
|
return transaction;
|
|
2961
3016
|
}
|
|
2962
3017
|
|
|
@@ -4391,7 +4446,8 @@ const BlockProductionResponseStruct = jsonRpcResultAndContext(type({
|
|
|
4391
4446
|
* A performance sample
|
|
4392
4447
|
*/
|
|
4393
4448
|
|
|
4394
|
-
function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRetryOnRateLimit) {
|
|
4449
|
+
function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit) {
|
|
4450
|
+
const fetch = customFetch ? customFetch : crossFetch;
|
|
4395
4451
|
let agentManager;
|
|
4396
4452
|
|
|
4397
4453
|
{
|
|
@@ -5199,6 +5255,7 @@ class Connection {
|
|
|
5199
5255
|
const useHttps = url.protocol === 'https:';
|
|
5200
5256
|
let wsEndpoint;
|
|
5201
5257
|
let httpHeaders;
|
|
5258
|
+
let fetch;
|
|
5202
5259
|
let fetchMiddleware;
|
|
5203
5260
|
let disableRetryOnRateLimit;
|
|
5204
5261
|
|
|
@@ -5209,13 +5266,14 @@ class Connection {
|
|
|
5209
5266
|
this._confirmTransactionInitialTimeout = commitmentOrConfig.confirmTransactionInitialTimeout;
|
|
5210
5267
|
wsEndpoint = commitmentOrConfig.wsEndpoint;
|
|
5211
5268
|
httpHeaders = commitmentOrConfig.httpHeaders;
|
|
5269
|
+
fetch = commitmentOrConfig.fetch;
|
|
5212
5270
|
fetchMiddleware = commitmentOrConfig.fetchMiddleware;
|
|
5213
5271
|
disableRetryOnRateLimit = commitmentOrConfig.disableRetryOnRateLimit;
|
|
5214
5272
|
}
|
|
5215
5273
|
|
|
5216
5274
|
this._rpcEndpoint = endpoint;
|
|
5217
5275
|
this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);
|
|
5218
|
-
this._rpcClient = createRpcClient(url.toString(), useHttps, httpHeaders, fetchMiddleware, disableRetryOnRateLimit);
|
|
5276
|
+
this._rpcClient = createRpcClient(url.toString(), useHttps, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit);
|
|
5219
5277
|
this._rpcRequest = createRpcRequest(this._rpcClient);
|
|
5220
5278
|
this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);
|
|
5221
5279
|
this._rpcWebSocket = new Client(this._rpcWsEndpoint, {
|
|
@@ -6730,7 +6788,9 @@ class Connection {
|
|
|
6730
6788
|
});
|
|
6731
6789
|
transaction.instructions = transactionOrMessage.instructions;
|
|
6732
6790
|
} else {
|
|
6733
|
-
transaction = Transaction.populate(transactionOrMessage);
|
|
6791
|
+
transaction = Transaction.populate(transactionOrMessage); // HACK: this function relies on mutating the populated transaction
|
|
6792
|
+
|
|
6793
|
+
transaction._message = transaction._json = undefined;
|
|
6734
6794
|
}
|
|
6735
6795
|
|
|
6736
6796
|
if (transaction.nonceInfo && signers) {
|