@solana/web3.js 1.29.2 → 1.30.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.esm.js +1785 -184
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +1791 -185
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +12 -1
- package/lib/index.esm.js +1793 -186
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +28733 -29237
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +30 -30
- package/lib/index.iife.min.js.map +1 -1
- package/module.flow.js +20 -2
- package/package.json +6 -6
- package/src/connection.ts +31 -10
- package/src/publickey.ts +5 -3
package/module.flow.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Flowtype definitions for index
|
|
3
3
|
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.
|
|
4
|
+
* Flowgen v1.15.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
declare module "@solana/web3.js" {
|
|
@@ -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(
|
|
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.
|
|
3
|
+
"version": "1.30.2",
|
|
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
|
-
"crypto-hash": "^1.2.2",
|
|
73
73
|
"jayson": "^3.4.4",
|
|
74
74
|
"js-sha3": "^0.8.0",
|
|
75
75
|
"rpc-websockets": "^7.4.2",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"@commitlint/travis-cli": "^13.1.0",
|
|
89
89
|
"@rollup/plugin-alias": "^3.1.2",
|
|
90
90
|
"@rollup/plugin-babel": "^5.2.3",
|
|
91
|
-
"@rollup/plugin-commonjs": "^
|
|
91
|
+
"@rollup/plugin-commonjs": "^21.0.0",
|
|
92
92
|
"@rollup/plugin-json": "^4.1.0",
|
|
93
93
|
"@rollup/plugin-multi-entry": "^4.0.0",
|
|
94
94
|
"@rollup/plugin-node-resolve": "^13.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.
|
|
115
|
+
"eslint-plugin-import": "2.25.2",
|
|
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": "^
|
|
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",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"prettier": "^2.3.0",
|
|
129
129
|
"puppeteer": "^10.2.0",
|
|
130
130
|
"rimraf": "3.0.2",
|
|
131
|
-
"rollup": "2.
|
|
131
|
+
"rollup": "2.58.3",
|
|
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",
|
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
|
-
|
|
2235
|
+
config?: GetSupplyConfig | Commitment,
|
|
2226
2236
|
): Promise<RpcResponseAndContext<Supply>> {
|
|
2227
|
-
|
|
2228
|
-
|
|
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
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
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/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 {sha256} from '
|
|
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';
|
|
@@ -120,6 +120,7 @@ export class PublicKey extends Struct {
|
|
|
120
120
|
* The program ID will also serve as the owner of the public key, giving
|
|
121
121
|
* it permission to write data to the account.
|
|
122
122
|
*/
|
|
123
|
+
/* eslint-disable require-await */
|
|
123
124
|
static async createWithSeed(
|
|
124
125
|
fromPublicKey: PublicKey,
|
|
125
126
|
seed: string,
|
|
@@ -130,13 +131,14 @@ export class PublicKey extends Struct {
|
|
|
130
131
|
Buffer.from(seed),
|
|
131
132
|
programId.toBuffer(),
|
|
132
133
|
]);
|
|
133
|
-
const hash =
|
|
134
|
+
const hash = sha256(new Uint8Array(buffer)).slice(2);
|
|
134
135
|
return new PublicKey(Buffer.from(hash, 'hex'));
|
|
135
136
|
}
|
|
136
137
|
|
|
137
138
|
/**
|
|
138
139
|
* Derive a program address from seeds and a program ID.
|
|
139
140
|
*/
|
|
141
|
+
/* eslint-disable require-await */
|
|
140
142
|
static async createProgramAddress(
|
|
141
143
|
seeds: Array<Buffer | Uint8Array>,
|
|
142
144
|
programId: PublicKey,
|
|
@@ -153,7 +155,7 @@ export class PublicKey extends Struct {
|
|
|
153
155
|
programId.toBuffer(),
|
|
154
156
|
Buffer.from('ProgramDerivedAddress'),
|
|
155
157
|
]);
|
|
156
|
-
let hash =
|
|
158
|
+
let hash = sha256(new Uint8Array(buffer)).slice(2);
|
|
157
159
|
let publicKeyBytes = new BN(hash, 16).toArray(undefined, 32);
|
|
158
160
|
if (is_on_curve(publicKeyBytes)) {
|
|
159
161
|
throw new Error(`Invalid seeds, address must fall off the curve`);
|