@solana/web3.js 2.0.0-rc.0 → 2.0.0-rc.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 -4
- package/dist/index.development.js +111 -5
- package/dist/index.development.js.map +1 -1
- package/dist/index.production.min.js +534 -531
- package/package.json +18 -18
package/README.md
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
[code-style-prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square
|
|
8
8
|
[code-style-prettier-url]: https://github.com/prettier/prettier
|
|
9
|
-
[npm-downloads-image]: https://img.shields.io/npm/dm/@solana/web3.js/
|
|
10
|
-
[npm-image]: https://img.shields.io/npm/v/@solana/web3.js/
|
|
11
|
-
[npm-url]: https://www.npmjs.com/package/@solana/web3.js/v/
|
|
9
|
+
[npm-downloads-image]: https://img.shields.io/npm/dm/@solana/web3.js/rc.svg?style=flat
|
|
10
|
+
[npm-image]: https://img.shields.io/npm/v/@solana/web3.js/rc.svg?style=flat
|
|
11
|
+
[npm-url]: https://www.npmjs.com/package/@solana/web3.js/v/rc
|
|
12
12
|
[semantic-release-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
|
|
13
13
|
[semantic-release-url]: https://github.com/semantic-release/semantic-release
|
|
14
14
|
|
|
@@ -18,7 +18,7 @@ This is the JavaScript SDK for building Solana apps for Node, web, and React Nat
|
|
|
18
18
|
|
|
19
19
|
## Functions
|
|
20
20
|
|
|
21
|
-
In addition to
|
|
21
|
+
In addition to reexporting functions from packages in the `@solana/*` namespace, this package offers additional helpers for building Solana applications, with sensible defaults.
|
|
22
22
|
|
|
23
23
|
### `airdropFactory({rpc, rpcSubscriptions})`
|
|
24
24
|
|
|
@@ -60,6 +60,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
60
60
|
var SOLANA_ERROR__SUBTLE_CRYPTO__GENERATE_FUNCTION_UNIMPLEMENTED = 3610004;
|
|
61
61
|
var SOLANA_ERROR__SUBTLE_CRYPTO__SIGN_FUNCTION_UNIMPLEMENTED = 3610005;
|
|
62
62
|
var SOLANA_ERROR__SUBTLE_CRYPTO__VERIFY_FUNCTION_UNIMPLEMENTED = 3610006;
|
|
63
|
+
var SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY = 3610007;
|
|
63
64
|
var SOLANA_ERROR__CRYPTO__RANDOM_VALUES_FUNCTION_UNIMPLEMENTED = 3611e3;
|
|
64
65
|
var SOLANA_ERROR__KEYS__INVALID_KEY_PAIR_BYTE_LENGTH = 3704e3;
|
|
65
66
|
var SOLANA_ERROR__KEYS__INVALID_PRIVATE_KEY_BYTE_LENGTH = 3704001;
|
|
@@ -384,6 +385,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
384
385
|
[SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS]: "More than one `TransactionSendingSigner` was identified.",
|
|
385
386
|
[SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING]: "No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction.",
|
|
386
387
|
[SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED]: "Wallet account signers do not support signing multiple messages/transactions in a single operation",
|
|
388
|
+
[SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY]: "Cannot export a non-extractable key.",
|
|
387
389
|
[SOLANA_ERROR__SUBTLE_CRYPTO__DIGEST_UNIMPLEMENTED]: "No digest implementation could be found.",
|
|
388
390
|
[SOLANA_ERROR__SUBTLE_CRYPTO__DISALLOWED_IN_INSECURE_CONTEXT]: "Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",
|
|
389
391
|
[SOLANA_ERROR__SUBTLE_CRYPTO__ED25519_ALGORITHM_UNIMPLEMENTED]: "This runtime does not support the generation of Ed25519 key pairs.\n\nInstall @solana/webcrypto-ed25519-polyfill and call its `install` function before generating keys in environments that do not support Ed25519.\n\nFor a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.",
|
|
@@ -3093,6 +3095,26 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
3093
3095
|
const privateKeyBytesPkcs8 = addPkcs8Header(bytes);
|
|
3094
3096
|
return await crypto.subtle.importKey("pkcs8", privateKeyBytesPkcs8, "Ed25519", extractable != null ? extractable : false, ["sign"]);
|
|
3095
3097
|
}
|
|
3098
|
+
async function getPublicKeyFromPrivateKey(privateKey, extractable = false) {
|
|
3099
|
+
assertKeyExporterIsAvailable();
|
|
3100
|
+
if (privateKey.extractable === false) {
|
|
3101
|
+
throw new SolanaError(SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY, { key: privateKey });
|
|
3102
|
+
}
|
|
3103
|
+
const jwk = await crypto.subtle.exportKey("jwk", privateKey);
|
|
3104
|
+
return await crypto.subtle.importKey(
|
|
3105
|
+
"jwk",
|
|
3106
|
+
{
|
|
3107
|
+
crv: "Ed25519",
|
|
3108
|
+
ext: extractable,
|
|
3109
|
+
key_ops: ["verify"],
|
|
3110
|
+
kty: "OKP",
|
|
3111
|
+
x: jwk.x
|
|
3112
|
+
},
|
|
3113
|
+
"Ed25519",
|
|
3114
|
+
extractable,
|
|
3115
|
+
["verify"]
|
|
3116
|
+
);
|
|
3117
|
+
}
|
|
3096
3118
|
var base58Encoder;
|
|
3097
3119
|
function assertIsSignature(putativeSignature) {
|
|
3098
3120
|
if (!base58Encoder) base58Encoder = getBase58Encoder();
|
|
@@ -3181,6 +3203,27 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
3181
3203
|
}
|
|
3182
3204
|
return { privateKey, publicKey };
|
|
3183
3205
|
}
|
|
3206
|
+
async function createKeyPairFromPrivateKeyBytes(bytes, extractable = false) {
|
|
3207
|
+
const privateKeyPromise = createPrivateKeyFromBytes(bytes, extractable);
|
|
3208
|
+
const [publicKey, privateKey] = await Promise.all([
|
|
3209
|
+
// This nested promise makes things efficient by
|
|
3210
|
+
// creating the public key in parallel with the
|
|
3211
|
+
// second private key creation, if it is needed.
|
|
3212
|
+
(extractable ? privateKeyPromise : createPrivateKeyFromBytes(
|
|
3213
|
+
bytes,
|
|
3214
|
+
true
|
|
3215
|
+
/* extractable */
|
|
3216
|
+
)).then(
|
|
3217
|
+
async (privateKey2) => await getPublicKeyFromPrivateKey(
|
|
3218
|
+
privateKey2,
|
|
3219
|
+
true
|
|
3220
|
+
/* extractable */
|
|
3221
|
+
)
|
|
3222
|
+
),
|
|
3223
|
+
privateKeyPromise
|
|
3224
|
+
]);
|
|
3225
|
+
return { privateKey, publicKey };
|
|
3226
|
+
}
|
|
3184
3227
|
|
|
3185
3228
|
// ../programs/dist/index.browser.mjs
|
|
3186
3229
|
function isProgramError(error, transactionMessage, programAddress, code) {
|
|
@@ -3950,7 +3993,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
3950
3993
|
...config.headers ? normalizeHeaders2(config.headers) : void 0,
|
|
3951
3994
|
...{
|
|
3952
3995
|
// Keep these headers lowercase so they will override any user-supplied headers above.
|
|
3953
|
-
"solana-client": (_a = `js/${"2.0.0-rc.
|
|
3996
|
+
"solana-client": (_a = `js/${"2.0.0-rc.1"}`) != null ? _a : "UNKNOWN"
|
|
3954
3997
|
}
|
|
3955
3998
|
}
|
|
3956
3999
|
}),
|
|
@@ -4280,6 +4323,63 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
4280
4323
|
return memoizedKeypaths2;
|
|
4281
4324
|
}
|
|
4282
4325
|
|
|
4326
|
+
// ../promises/dist/index.browser.mjs
|
|
4327
|
+
function isObject(value) {
|
|
4328
|
+
return value !== null && (typeof value === "object" || typeof value === "function");
|
|
4329
|
+
}
|
|
4330
|
+
function addRaceContender(contender) {
|
|
4331
|
+
const deferreds = /* @__PURE__ */ new Set();
|
|
4332
|
+
const record = { deferreds, settled: false };
|
|
4333
|
+
Promise.resolve(contender).then(
|
|
4334
|
+
(value) => {
|
|
4335
|
+
for (const { resolve } of deferreds) {
|
|
4336
|
+
resolve(value);
|
|
4337
|
+
}
|
|
4338
|
+
deferreds.clear();
|
|
4339
|
+
record.settled = true;
|
|
4340
|
+
},
|
|
4341
|
+
(err) => {
|
|
4342
|
+
for (const { reject } of deferreds) {
|
|
4343
|
+
reject(err);
|
|
4344
|
+
}
|
|
4345
|
+
deferreds.clear();
|
|
4346
|
+
record.settled = true;
|
|
4347
|
+
}
|
|
4348
|
+
);
|
|
4349
|
+
return record;
|
|
4350
|
+
}
|
|
4351
|
+
var wm = /* @__PURE__ */ new WeakMap();
|
|
4352
|
+
async function safeRace(contenders) {
|
|
4353
|
+
let deferred;
|
|
4354
|
+
const result = new Promise((resolve, reject) => {
|
|
4355
|
+
deferred = { reject, resolve };
|
|
4356
|
+
for (const contender of contenders) {
|
|
4357
|
+
if (!isObject(contender)) {
|
|
4358
|
+
Promise.resolve(contender).then(resolve, reject);
|
|
4359
|
+
continue;
|
|
4360
|
+
}
|
|
4361
|
+
let record = wm.get(contender);
|
|
4362
|
+
if (record === void 0) {
|
|
4363
|
+
record = addRaceContender(contender);
|
|
4364
|
+
record.deferreds.add(deferred);
|
|
4365
|
+
wm.set(contender, record);
|
|
4366
|
+
} else if (record.settled) {
|
|
4367
|
+
Promise.resolve(contender).then(resolve, reject);
|
|
4368
|
+
} else {
|
|
4369
|
+
record.deferreds.add(deferred);
|
|
4370
|
+
}
|
|
4371
|
+
}
|
|
4372
|
+
});
|
|
4373
|
+
return await result.finally(() => {
|
|
4374
|
+
for (const contender of contenders) {
|
|
4375
|
+
if (isObject(contender)) {
|
|
4376
|
+
const record = wm.get(contender);
|
|
4377
|
+
record.deferreds.delete(deferred);
|
|
4378
|
+
}
|
|
4379
|
+
}
|
|
4380
|
+
});
|
|
4381
|
+
}
|
|
4382
|
+
|
|
4283
4383
|
// ../rpc-subscriptions-transport-websocket/dist/index.browser.mjs
|
|
4284
4384
|
var e2 = globalThis.WebSocket;
|
|
4285
4385
|
var EXPLICIT_ABORT_TOKEN2;
|
|
@@ -4653,7 +4753,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
4653
4753
|
try {
|
|
4654
4754
|
const iterator = iterable[Symbol.asyncIterator]();
|
|
4655
4755
|
while (true) {
|
|
4656
|
-
const iteratorResult = await
|
|
4756
|
+
const iteratorResult = await safeRace([iterator.next(), abortPromise]);
|
|
4657
4757
|
if (iteratorResult.done) {
|
|
4658
4758
|
return;
|
|
4659
4759
|
} else {
|
|
@@ -6188,6 +6288,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
6188
6288
|
async function createKeyPairSignerFromBytes(bytes, extractable) {
|
|
6189
6289
|
return await createSignerFromKeyPair(await createKeyPairFromBytes(bytes, extractable));
|
|
6190
6290
|
}
|
|
6291
|
+
async function createKeyPairSignerFromPrivateKeyBytes(bytes, extractable) {
|
|
6292
|
+
return await createSignerFromKeyPair(await createKeyPairFromPrivateKeyBytes(bytes, extractable));
|
|
6293
|
+
}
|
|
6191
6294
|
function isMessageModifyingSigner(value) {
|
|
6192
6295
|
return isAddress(value.address) && "modifyAndSignMessages" in value && typeof value.modifyAndSignMessages === "function";
|
|
6193
6296
|
}
|
|
@@ -6490,7 +6593,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
6490
6593
|
}
|
|
6491
6594
|
})();
|
|
6492
6595
|
try {
|
|
6493
|
-
return await
|
|
6596
|
+
return await safeRace([nonceAccountDidAdvancePromise, nonceIsAlreadyInvalidPromise]);
|
|
6494
6597
|
} finally {
|
|
6495
6598
|
abortController.abort();
|
|
6496
6599
|
}
|
|
@@ -6531,7 +6634,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
6531
6634
|
}
|
|
6532
6635
|
})();
|
|
6533
6636
|
try {
|
|
6534
|
-
return await
|
|
6637
|
+
return await safeRace([signatureDidCommitPromise, signatureStatusLookupPromise]);
|
|
6535
6638
|
} finally {
|
|
6536
6639
|
abortController.abort();
|
|
6537
6640
|
}
|
|
@@ -6573,7 +6676,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
6573
6676
|
...config,
|
|
6574
6677
|
abortSignal: abortController.signal
|
|
6575
6678
|
});
|
|
6576
|
-
return await
|
|
6679
|
+
return await safeRace([
|
|
6577
6680
|
getRecentSignatureConfirmationPromise({
|
|
6578
6681
|
abortSignal: abortController.signal,
|
|
6579
6682
|
commitment,
|
|
@@ -7112,6 +7215,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
7112
7215
|
exports.SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS = SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS;
|
|
7113
7216
|
exports.SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING = SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING;
|
|
7114
7217
|
exports.SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED = SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED;
|
|
7218
|
+
exports.SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY = SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY;
|
|
7115
7219
|
exports.SOLANA_ERROR__SUBTLE_CRYPTO__DIGEST_UNIMPLEMENTED = SOLANA_ERROR__SUBTLE_CRYPTO__DIGEST_UNIMPLEMENTED;
|
|
7116
7220
|
exports.SOLANA_ERROR__SUBTLE_CRYPTO__DISALLOWED_IN_INSECURE_CONTEXT = SOLANA_ERROR__SUBTLE_CRYPTO__DISALLOWED_IN_INSECURE_CONTEXT;
|
|
7117
7221
|
exports.SOLANA_ERROR__SUBTLE_CRYPTO__ED25519_ALGORITHM_UNIMPLEMENTED = SOLANA_ERROR__SUBTLE_CRYPTO__ED25519_ALGORITHM_UNIMPLEMENTED;
|
|
@@ -7238,7 +7342,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
7238
7342
|
exports.createDefaultRpcTransport = createDefaultRpcTransport;
|
|
7239
7343
|
exports.createEncoder = createEncoder;
|
|
7240
7344
|
exports.createKeyPairFromBytes = createKeyPairFromBytes;
|
|
7345
|
+
exports.createKeyPairFromPrivateKeyBytes = createKeyPairFromPrivateKeyBytes;
|
|
7241
7346
|
exports.createKeyPairSignerFromBytes = createKeyPairSignerFromBytes;
|
|
7347
|
+
exports.createKeyPairSignerFromPrivateKeyBytes = createKeyPairSignerFromPrivateKeyBytes;
|
|
7242
7348
|
exports.createNoopSigner = createNoopSigner;
|
|
7243
7349
|
exports.createPrivateKeyFromBytes = createPrivateKeyFromBytes;
|
|
7244
7350
|
exports.createRpc = createRpc;
|