@solana/web3.js 1.29.3 → 1.31.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/module.flow.js CHANGED
@@ -799,6 +799,22 @@ declare module "@solana/web3.js" {
799
799
  ...
800
800
  };
801
801
 
802
+ /**
803
+ * Configuration object for changing `getSupply` request behavior
804
+ */
805
+ declare export type GetSupplyConfig = {
806
+ /**
807
+ * The level of commitment desired
808
+ */
809
+ commitment?: Commitment,
810
+
811
+ /**
812
+ * Exclude non circulating accounts list from response
813
+ */
814
+ excludeNonCirculatingAccountsList?: boolean,
815
+ ...
816
+ };
817
+
802
818
  /**
803
819
  * Configuration object for changing query behavior
804
820
  */
@@ -2121,7 +2137,9 @@ declare module "@solana/web3.js" {
2121
2137
  /**
2122
2138
  * Fetch information about the current supply
2123
2139
  */
2124
- getSupply(commitment?: Commitment): Promise<RpcResponseAndContext<Supply>>;
2140
+ getSupply(
2141
+ config?: GetSupplyConfig | Commitment
2142
+ ): Promise<RpcResponseAndContext<Supply>>;
2125
2143
 
2126
2144
  /**
2127
2145
  * Fetch the current supply of a token mint
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/web3.js",
3
- "version": "1.29.3",
3
+ "version": "1.31.0",
4
4
  "description": "Solana Javascript API",
5
5
  "keywords": [
6
6
  "api",
@@ -63,13 +63,13 @@
63
63
  },
64
64
  "dependencies": {
65
65
  "@babel/runtime": "^7.12.5",
66
+ "@ethersproject/sha2": "^5.5.0",
66
67
  "@solana/buffer-layout": "^3.0.0",
67
68
  "bn.js": "^5.0.0",
68
69
  "borsh": "^0.4.0",
69
70
  "bs58": "^4.0.1",
70
71
  "buffer": "6.0.1",
71
72
  "cross-fetch": "^3.1.4",
72
- "ethers": "^5.5.1",
73
73
  "jayson": "^3.4.4",
74
74
  "js-sha3": "^0.8.0",
75
75
  "rpc-websockets": "^7.4.2",
@@ -84,8 +84,8 @@
84
84
  "@babel/preset-env": "^7.12.11",
85
85
  "@babel/preset-typescript": "^7.12.16",
86
86
  "@babel/register": "^7.12.13",
87
- "@commitlint/config-conventional": "^13.1.0",
88
- "@commitlint/travis-cli": "^13.1.0",
87
+ "@commitlint/config-conventional": "^14.1.0",
88
+ "@commitlint/travis-cli": "^14.1.0",
89
89
  "@rollup/plugin-alias": "^3.1.2",
90
90
  "@rollup/plugin-babel": "^5.2.3",
91
91
  "@rollup/plugin-commonjs": "^21.0.0",
@@ -112,13 +112,13 @@
112
112
  "cross-env": "7.0.3",
113
113
  "eslint": "^7.19.0",
114
114
  "eslint-config-prettier": "^8.0.0",
115
- "eslint-plugin-import": "2.25.2",
115
+ "eslint-plugin-import": "2.25.3",
116
116
  "eslint-plugin-mocha": "^9.0.0",
117
117
  "eslint-plugin-prettier": "^4.0.0",
118
118
  "esm": "^3.2.25",
119
119
  "flow-bin": "^0.150.0",
120
120
  "flowgen": "^1.13.0",
121
- "http-server": "^13.0.0",
121
+ "http-server": "^14.0.0",
122
122
  "mocha": "^8.2.1",
123
123
  "mocha-headless-chrome": "^3.1.0",
124
124
  "mockttp": "^2.0.1",
@@ -126,14 +126,14 @@
126
126
  "npm-run-all": "^4.1.5",
127
127
  "nyc": "^15.1.0",
128
128
  "prettier": "^2.3.0",
129
- "puppeteer": "^10.2.0",
129
+ "puppeteer": "^11.0.0",
130
130
  "rimraf": "3.0.2",
131
- "rollup": "2.58.0",
131
+ "rollup": "2.60.0",
132
132
  "rollup-plugin-dts": "^4.0.0",
133
133
  "rollup-plugin-node-polyfills": "^0.2.1",
134
134
  "rollup-plugin-terser": "^7.0.2",
135
135
  "semantic-release": "^18.0.0",
136
- "sinon": "^11.0.0",
136
+ "sinon": "^12.0.0",
137
137
  "start-server-and-test": "^1.12.0",
138
138
  "ts-node": "^10.0.0",
139
139
  "tslib": "^2.1.0",
package/src/account.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as nacl from 'tweetnacl';
1
+ import nacl from 'tweetnacl';
2
2
  import type {SignKeyPair as KeyPair} from 'tweetnacl';
3
3
  import type {Buffer} from 'buffer';
4
4
 
package/src/connection.ts CHANGED
@@ -265,6 +265,16 @@ export type GetLargestAccountsConfig = {
265
265
  filter?: LargestAccountsFilter;
266
266
  };
267
267
 
268
+ /**
269
+ * Configuration object for changing `getSupply` request behavior
270
+ */
271
+ export type GetSupplyConfig = {
272
+ /** The level of commitment desired */
273
+ commitment?: Commitment;
274
+ /** Exclude non circulating accounts list from response */
275
+ excludeNonCirculatingAccountsList?: boolean;
276
+ };
277
+
268
278
  /**
269
279
  * Configuration object for changing query behavior
270
280
  */
@@ -2222,10 +2232,23 @@ export class Connection {
2222
2232
  * Fetch information about the current supply
2223
2233
  */
2224
2234
  async getSupply(
2225
- commitment?: Commitment,
2235
+ config?: GetSupplyConfig | Commitment,
2226
2236
  ): Promise<RpcResponseAndContext<Supply>> {
2227
- const args = this._buildArgs([], commitment);
2228
- const unsafeRes = await this._rpcRequest('getSupply', args);
2237
+ let configArg: GetSupplyConfig = {};
2238
+ if (typeof config === 'string') {
2239
+ configArg = {commitment: config};
2240
+ } else if (config) {
2241
+ configArg = {
2242
+ ...config,
2243
+ commitment: (config && config.commitment) || this.commitment,
2244
+ };
2245
+ } else {
2246
+ configArg = {
2247
+ commitment: this.commitment,
2248
+ };
2249
+ }
2250
+
2251
+ const unsafeRes = await this._rpcRequest('getSupply', [configArg]);
2229
2252
  const res = create(unsafeRes, GetSupplyRpcResult);
2230
2253
  if ('error' in res) {
2231
2254
  throw new Error('failed to get supply: ' + res.error.message);
@@ -2794,13 +2817,11 @@ export class Connection {
2794
2817
  * @deprecated Deprecated since v1.2.8. Please use {@link getSupply} instead.
2795
2818
  */
2796
2819
  async getTotalSupply(commitment?: Commitment): Promise<number> {
2797
- const args = this._buildArgs([], commitment);
2798
- const unsafeRes = await this._rpcRequest('getSupply', args);
2799
- const res = create(unsafeRes, GetSupplyRpcResult);
2800
- if ('error' in res) {
2801
- throw new Error('failed to get total supply: ' + res.error.message);
2802
- }
2803
- return res.result.value.total;
2820
+ const result = await this.getSupply({
2821
+ commitment,
2822
+ excludeNonCirculatingAccountsList: true,
2823
+ });
2824
+ return result.value.total;
2804
2825
  }
2805
2826
 
2806
2827
  /**
package/src/keypair.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as nacl from 'tweetnacl';
1
+ import nacl from 'tweetnacl';
2
2
 
3
3
  import {PublicKey} from './publickey';
4
4
 
package/src/publickey.ts CHANGED
@@ -2,7 +2,7 @@ import BN from 'bn.js';
2
2
  import bs58 from 'bs58';
3
3
  import {Buffer} from 'buffer';
4
4
  import nacl from 'tweetnacl';
5
- import {ethers} from 'ethers';
5
+ import {sha256} from '@ethersproject/sha2';
6
6
 
7
7
  import {Struct, SOLANA_SCHEMA} from './util/borsh-schema';
8
8
  import {toBuffer} from './util/to-buffer';
@@ -131,7 +131,7 @@ export class PublicKey extends Struct {
131
131
  Buffer.from(seed),
132
132
  programId.toBuffer(),
133
133
  ]);
134
- const hash = ethers.utils.sha256(new Uint8Array(buffer)).slice(2);
134
+ const hash = sha256(new Uint8Array(buffer)).slice(2);
135
135
  return new PublicKey(Buffer.from(hash, 'hex'));
136
136
  }
137
137
 
@@ -155,7 +155,7 @@ export class PublicKey extends Struct {
155
155
  programId.toBuffer(),
156
156
  Buffer.from('ProgramDerivedAddress'),
157
157
  ]);
158
- let hash = ethers.utils.sha256(new Uint8Array(buffer)).slice(2);
158
+ let hash = sha256(new Uint8Array(buffer)).slice(2);
159
159
  let publicKeyBytes = new BN(hash, 16).toArray(undefined, 32);
160
160
  if (is_on_curve(publicKeyBytes)) {
161
161
  throw new Error(`Invalid seeds, address must fall off the curve`);
@@ -1,7 +1,7 @@
1
1
  import {Buffer} from 'buffer';
2
2
  import * as BufferLayout from '@solana/buffer-layout';
3
3
  import secp256k1 from 'secp256k1';
4
- import {keccak_256} from 'js-sha3';
4
+ import sha3 from 'js-sha3';
5
5
 
6
6
  import {PublicKey} from './publickey';
7
7
  import {TransactionInstruction} from './transaction';
@@ -86,9 +86,9 @@ export class Secp256k1Program {
86
86
  );
87
87
 
88
88
  try {
89
- return Buffer.from(keccak_256.update(toBuffer(publicKey)).digest()).slice(
90
- -ETHEREUM_ADDRESS_BYTES,
91
- );
89
+ return Buffer.from(
90
+ sha3.keccak_256.update(toBuffer(publicKey)).digest(),
91
+ ).slice(-ETHEREUM_ADDRESS_BYTES);
92
92
  } catch (error) {
93
93
  throw new Error(`Error constructing Ethereum address: ${error}`);
94
94
  }
@@ -197,7 +197,7 @@ export class Secp256k1Program {
197
197
  const privateKey = toBuffer(pkey);
198
198
  const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte
199
199
  const messageHash = Buffer.from(
200
- keccak_256.update(toBuffer(message)).digest(),
200
+ sha3.keccak_256.update(toBuffer(message)).digest(),
201
201
  );
202
202
  const {signature, recid: recoveryId} = ecdsaSign(messageHash, privateKey);
203
203