@solana/web3.js 1.47.1 → 1.47.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/web3.js",
3
- "version": "1.47.1",
3
+ "version": "1.47.4",
4
4
  "description": "Solana Javascript API",
5
5
  "keywords": [
6
6
  "api",
@@ -23,6 +23,7 @@
23
23
  "./lib/index.cjs.js": "./lib/index.browser.cjs.js",
24
24
  "./lib/index.esm.js": "./lib/index.browser.esm.js"
25
25
  },
26
+ "react-native": "lib/index.native.js",
26
27
  "main": "lib/index.cjs.js",
27
28
  "module": "lib/index.esm.js",
28
29
  "types": "lib/index.d.ts",
@@ -68,6 +69,7 @@
68
69
  "jayson": "^3.4.4",
69
70
  "js-sha3": "^0.8.0",
70
71
  "node-fetch": "2",
72
+ "react-native-url-polyfill": "^1.3.0",
71
73
  "rpc-websockets": "^7.5.0",
72
74
  "secp256k1": "^4.0.2",
73
75
  "superstruct": "^0.14.2",
@@ -0,0 +1,4 @@
1
+ export const Headers = globalThis.Headers;
2
+ export const Request = globalThis.Request;
3
+ export const Response = globalThis.Response;
4
+ export default globalThis.fetch;
package/src/connection.ts CHANGED
@@ -24,6 +24,7 @@ import type {Struct} from 'superstruct';
24
24
  import {Client as RpcWebSocketClient} from 'rpc-websockets';
25
25
  import RpcClient from 'jayson/lib/client/browser';
26
26
 
27
+ import {URL} from './util/url-impl';
27
28
  import {AgentManager} from './agent-manager';
28
29
  import {EpochSchedule} from './epoch-schedule';
29
30
  import {SendTransactionError, SolanaJSONRPCError} from './errors';
@@ -41,7 +42,7 @@ import {
41
42
  TransactionExpiredBlockheightExceededError,
42
43
  TransactionExpiredTimeoutError,
43
44
  } from './util/tx-expiry-custom-errors';
44
- import {makeWebsocketUrl} from './util/url';
45
+ import {makeWebsocketUrl} from './util/makeWebsocketUrl';
45
46
  import type {Blockhash} from './blockhash';
46
47
  import type {FeeCalculator} from './fee-calculator';
47
48
  import type {TransactionSignature} from './transaction';
@@ -711,13 +712,20 @@ export type SimulatedTransactionAccountInfo = {
711
712
  rentEpoch?: number;
712
713
  };
713
714
 
715
+ export type TransactionReturnDataEncoding = 'base64';
716
+
717
+ export type TransactionReturnData = {
718
+ programId: string;
719
+ data: [string, TransactionReturnDataEncoding];
720
+ };
721
+
714
722
  export type SimulatedTransactionResponse = {
715
723
  err: TransactionError | string | null;
716
724
  logs: Array<string> | null;
717
725
  accounts?: (SimulatedTransactionAccountInfo | null)[] | null;
718
726
  unitsConsumed?: number;
727
+ returnData?: TransactionReturnData | null;
719
728
  };
720
-
721
729
  const SimulatedTransactionResponseStruct = jsonRpcResultAndContext(
722
730
  pick({
723
731
  err: nullable(union([pick({}), string()])),
@@ -738,6 +746,14 @@ const SimulatedTransactionResponseStruct = jsonRpcResultAndContext(
738
746
  ),
739
747
  ),
740
748
  unitsConsumed: optional(number()),
749
+ returnData: optional(
750
+ nullable(
751
+ pick({
752
+ programId: string(),
753
+ data: tuple([string(), literal('base64')]),
754
+ }),
755
+ ),
756
+ ),
741
757
  }),
742
758
  );
743
759
 
@@ -3051,15 +3067,6 @@ export class Connection {
3051
3067
  }
3052
3068
  });
3053
3069
 
3054
- const checkBlockHeight = async () => {
3055
- try {
3056
- const blockHeight = await this.getBlockHeight(commitment);
3057
- return blockHeight;
3058
- } catch (_e) {
3059
- return -1;
3060
- }
3061
- };
3062
-
3063
3070
  const expiryPromise = new Promise<
3064
3071
  | {__type: TransactionStatus.BLOCKHEIGHT_EXCEEDED}
3065
3072
  | {__type: TransactionStatus.TIMED_OUT; timeoutMs: number}
@@ -3088,6 +3095,14 @@ export class Connection {
3088
3095
  } else {
3089
3096
  let config =
3090
3097
  strategy as BlockheightBasedTransactionConfirmationStrategy;
3098
+ const checkBlockHeight = async () => {
3099
+ try {
3100
+ const blockHeight = await this.getBlockHeight(commitment);
3101
+ return blockHeight;
3102
+ } catch (_e) {
3103
+ return -1;
3104
+ }
3105
+ };
3091
3106
  (async () => {
3092
3107
  let currentBlockHeight = await checkBlockHeight();
3093
3108
  if (done) return;
@@ -3431,10 +3446,9 @@ export class Connection {
3431
3446
  async getRecentPerformanceSamples(
3432
3447
  limit?: number,
3433
3448
  ): Promise<Array<PerfSample>> {
3434
- const args = this._buildArgs(limit ? [limit] : []);
3435
3449
  const unsafeRes = await this._rpcRequest(
3436
3450
  'getRecentPerformanceSamples',
3437
- args,
3451
+ limit ? [limit] : [],
3438
3452
  );
3439
3453
  const res = create(unsafeRes, GetRecentPerformanceSamplesRpcResult);
3440
3454
  if ('error' in res) {
@@ -258,17 +258,25 @@ export class Transaction {
258
258
  ) {
259
259
  if (!opts) {
260
260
  return;
261
- } else if (
262
- Object.prototype.hasOwnProperty.call(opts, 'lastValidBlockHeight')
263
- ) {
264
- const newOpts = opts as TransactionBlockhashCtor;
265
- Object.assign(this, newOpts);
266
- this.recentBlockhash = newOpts.blockhash;
267
- this.lastValidBlockHeight = newOpts.lastValidBlockHeight;
261
+ }
262
+ if (opts.feePayer) {
263
+ this.feePayer = opts.feePayer;
264
+ }
265
+ if (opts.signatures) {
266
+ this.signatures = opts.signatures;
267
+ }
268
+ if (Object.prototype.hasOwnProperty.call(opts, 'lastValidBlockHeight')) {
269
+ const {blockhash, lastValidBlockHeight} =
270
+ opts as TransactionBlockhashCtor;
271
+ this.recentBlockhash = blockhash;
272
+ this.lastValidBlockHeight = lastValidBlockHeight;
268
273
  } else {
269
- const oldOpts = opts as TransactionCtorFields_DEPRECATED;
270
- Object.assign(this, oldOpts);
271
- this.recentBlockhash = oldOpts.recentBlockhash;
274
+ const {recentBlockhash, nonceInfo} =
275
+ opts as TransactionCtorFields_DEPRECATED;
276
+ if (nonceInfo) {
277
+ this.nonceInfo = nonceInfo;
278
+ }
279
+ this.recentBlockhash = recentBlockhash;
272
280
  }
273
281
  }
274
282
 
@@ -0,0 +1,2 @@
1
+ export {default} from 'react-native-url-polyfill';
2
+ export * from 'react-native-url-polyfill';
@@ -1,3 +1,5 @@
1
+ import {URL} from './url-impl';
2
+
1
3
  export function makeWebsocketUrl(endpoint: string) {
2
4
  let url = new URL(endpoint);
3
5
  const useHttps = url.protocol === 'https:';
@@ -0,0 +1,2 @@
1
+ export const URL = globalThis.URL;
2
+ export const URLSearchParams = globalThis.URLSearchParams;