@solana/web3.js 2.0.0-preview.4 → 2.0.0-preview.4.20240730223910.ce0933a9fc71c65f57d24eed219c71a9f02e8bf2
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +164 -190
- package/dist/index.browser.cjs +1 -1
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.mjs +1 -1
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.development.js +93 -27
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.mjs +1 -1
- package/dist/index.native.mjs.map +1 -1
- package/dist/index.node.cjs +1 -1
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +1 -1
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.production.min.js +446 -440
- package/dist/types/compute-limit.d.ts +1 -1
- package/dist/types/compute-limit.d.ts.map +1 -1
- package/package.json +22 -22
@@ -4,7 +4,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
4
4
|
|
5
5
|
var __defProp = Object.defineProperty;
|
6
6
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
7
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
|
7
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
8
8
|
|
9
9
|
// ../errors/dist/index.browser.mjs
|
10
10
|
var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 1;
|
@@ -563,6 +563,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
563
563
|
}
|
564
564
|
const message = getErrorMessage(code, context);
|
565
565
|
super(message, errorOptions);
|
566
|
+
__publicField(this, "cause", this.cause);
|
566
567
|
__publicField(this, "context");
|
567
568
|
this.context = {
|
568
569
|
__code: code,
|
@@ -1974,7 +1975,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
1974
1975
|
var getF32Encoder = (config = {}) => numberEncoderFactory({
|
1975
1976
|
config,
|
1976
1977
|
name: "f32",
|
1977
|
-
set: (view, value, le) => view.setFloat32(0, value, le),
|
1978
|
+
set: (view, value, le) => view.setFloat32(0, Number(value), le),
|
1978
1979
|
size: 4
|
1979
1980
|
});
|
1980
1981
|
var getF32Decoder = (config = {}) => numberDecoderFactory({
|
@@ -1987,7 +1988,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
1987
1988
|
var getF64Encoder = (config = {}) => numberEncoderFactory({
|
1988
1989
|
config,
|
1989
1990
|
name: "f64",
|
1990
|
-
set: (view, value, le) => view.setFloat64(0, value, le),
|
1991
|
+
set: (view, value, le) => view.setFloat64(0, Number(value), le),
|
1991
1992
|
size: 8
|
1992
1993
|
});
|
1993
1994
|
var getF64Decoder = (config = {}) => numberDecoderFactory({
|
@@ -2027,7 +2028,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
2027
2028
|
config,
|
2028
2029
|
name: "i16",
|
2029
2030
|
range: [-Number("0x7fff") - 1, Number("0x7fff")],
|
2030
|
-
set: (view, value, le) => view.setInt16(0, value, le),
|
2031
|
+
set: (view, value, le) => view.setInt16(0, Number(value), le),
|
2031
2032
|
size: 2
|
2032
2033
|
});
|
2033
2034
|
var getI16Decoder = (config = {}) => numberDecoderFactory({
|
@@ -2041,7 +2042,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
2041
2042
|
config,
|
2042
2043
|
name: "i32",
|
2043
2044
|
range: [-Number("0x7fffffff") - 1, Number("0x7fffffff")],
|
2044
|
-
set: (view, value, le) => view.setInt32(0, value, le),
|
2045
|
+
set: (view, value, le) => view.setInt32(0, Number(value), le),
|
2045
2046
|
size: 4
|
2046
2047
|
});
|
2047
2048
|
var getI32Decoder = (config = {}) => numberDecoderFactory({
|
@@ -2068,7 +2069,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
2068
2069
|
var getI8Encoder = () => numberEncoderFactory({
|
2069
2070
|
name: "i8",
|
2070
2071
|
range: [-Number("0x7f") - 1, Number("0x7f")],
|
2071
|
-
set: (view, value) => view.setInt8(0, value),
|
2072
|
+
set: (view, value) => view.setInt8(0, Number(value)),
|
2072
2073
|
size: 1
|
2073
2074
|
});
|
2074
2075
|
var getI8Decoder = () => numberDecoderFactory({
|
@@ -2088,7 +2089,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
2088
2089
|
assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
|
2089
2090
|
const shortU16Bytes = [0];
|
2090
2091
|
for (let ii = 0; ; ii += 1) {
|
2091
|
-
const alignedValue = value >> ii * 7;
|
2092
|
+
const alignedValue = Number(value) >> ii * 7;
|
2092
2093
|
if (alignedValue === 0) {
|
2093
2094
|
break;
|
2094
2095
|
}
|
@@ -2150,7 +2151,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
2150
2151
|
config,
|
2151
2152
|
name: "u16",
|
2152
2153
|
range: [0, Number("0xffff")],
|
2153
|
-
set: (view, value, le) => view.setUint16(0, value, le),
|
2154
|
+
set: (view, value, le) => view.setUint16(0, Number(value), le),
|
2154
2155
|
size: 2
|
2155
2156
|
});
|
2156
2157
|
var getU16Decoder = (config = {}) => numberDecoderFactory({
|
@@ -2164,7 +2165,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
2164
2165
|
config,
|
2165
2166
|
name: "u32",
|
2166
2167
|
range: [0, Number("0xffffffff")],
|
2167
|
-
set: (view, value, le) => view.setUint32(0, value, le),
|
2168
|
+
set: (view, value, le) => view.setUint32(0, Number(value), le),
|
2168
2169
|
size: 4
|
2169
2170
|
});
|
2170
2171
|
var getU32Decoder = (config = {}) => numberDecoderFactory({
|
@@ -2191,7 +2192,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
2191
2192
|
var getU8Encoder = () => numberEncoderFactory({
|
2192
2193
|
name: "u8",
|
2193
2194
|
range: [0, Number("0xff")],
|
2194
|
-
set: (view, value) => view.setUint8(0, value),
|
2195
|
+
set: (view, value) => view.setUint8(0, Number(value)),
|
2195
2196
|
size: 1
|
2196
2197
|
});
|
2197
2198
|
var getU8Decoder = () => numberDecoderFactory({
|
@@ -3241,10 +3242,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3241
3242
|
payload,
|
3242
3243
|
signal: options == null ? void 0 : options.abortSignal
|
3243
3244
|
});
|
3244
|
-
|
3245
|
-
throw getSolanaErrorFromJsonRpcError(response.error);
|
3246
|
-
}
|
3247
|
-
return responseTransformer ? responseTransformer(response.result, methodName) : response.result;
|
3245
|
+
return responseTransformer ? responseTransformer(response, methodName) : response;
|
3248
3246
|
}
|
3249
3247
|
};
|
3250
3248
|
}
|
@@ -3480,12 +3478,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3480
3478
|
}
|
3481
3479
|
function getDefaultResponseTransformerForSolanaRpc(config) {
|
3482
3480
|
return (rawResponse, methodName) => {
|
3481
|
+
if ("error" in rawResponse) {
|
3482
|
+
throw getSolanaErrorFromJsonRpcError(rawResponse.error);
|
3483
|
+
}
|
3483
3484
|
const keyPaths = (config == null ? void 0 : config.allowedNumericKeyPaths) && methodName ? config.allowedNumericKeyPaths[methodName] : void 0;
|
3484
3485
|
const traverse = getTreeWalker([getBigIntUpcastVisitor(keyPaths != null ? keyPaths : [])]);
|
3485
3486
|
const initialState = {
|
3486
3487
|
keyPath: []
|
3487
3488
|
};
|
3488
|
-
return traverse(rawResponse, initialState);
|
3489
|
+
return traverse(rawResponse.result, initialState);
|
3489
3490
|
};
|
3490
3491
|
}
|
3491
3492
|
var jsonParsedTokenAccountsConfigs = [
|
@@ -3915,7 +3916,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3915
3916
|
reject(e3.target.reason);
|
3916
3917
|
};
|
3917
3918
|
signal.addEventListener("abort", handleAbort);
|
3918
|
-
responsePromise.then(resolve).finally(() => {
|
3919
|
+
responsePromise.then(resolve).catch(reject).finally(() => {
|
3919
3920
|
signal.removeEventListener("abort", handleAbort);
|
3920
3921
|
});
|
3921
3922
|
});
|
@@ -3949,7 +3950,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3949
3950
|
...config.headers ? normalizeHeaders2(config.headers) : void 0,
|
3950
3951
|
...{
|
3951
3952
|
// Keep these headers lowercase so they will override any user-supplied headers above.
|
3952
|
-
"solana-client": (_a = `js/${"2.0.0-preview.4"}`) != null ? _a : "UNKNOWN"
|
3953
|
+
"solana-client": (_a = `js/${"2.0.0-preview.4.20240730223910.ce0933a9fc71c65f57d24eed219c71a9f02e8bf2"}`) != null ? _a : "UNKNOWN"
|
3953
3954
|
}
|
3954
3955
|
}
|
3955
3956
|
}),
|
@@ -4052,7 +4053,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
4052
4053
|
if (!("params" in message) || message.params.subscription !== subscriptionId) {
|
4053
4054
|
continue;
|
4054
4055
|
}
|
4055
|
-
const notification = message.params
|
4056
|
+
const notification = message.params;
|
4056
4057
|
yield responseTransformer ? responseTransformer(notification, subscribeMethodName) : notification;
|
4057
4058
|
}
|
4058
4059
|
}
|
@@ -4490,7 +4491,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
4490
4491
|
safeCaptureStackTrace(error, createSolanaJsonRpcIntegerOverflowError2);
|
4491
4492
|
return error;
|
4492
4493
|
}
|
4493
|
-
var
|
4494
|
+
var DEFAULT_RPC_SUBSCRIPTIONS_CONFIG = {
|
4494
4495
|
defaultCommitment: "confirmed",
|
4495
4496
|
onIntegerOverflow(methodName, keyPath, value) {
|
4496
4497
|
throw createSolanaJsonRpcIntegerOverflowError2(methodName, keyPath, value);
|
@@ -4792,7 +4793,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
4792
4793
|
function createSolanaRpcSubscriptionsFromTransport(transport) {
|
4793
4794
|
return pipe(
|
4794
4795
|
createSubscriptionRpc({
|
4795
|
-
api: createSolanaRpcSubscriptionsApi(
|
4796
|
+
api: createSolanaRpcSubscriptionsApi(DEFAULT_RPC_SUBSCRIPTIONS_CONFIG),
|
4796
4797
|
transport
|
4797
4798
|
}),
|
4798
4799
|
(rpcSubscriptions) => getRpcSubscriptionsWithSubscriptionCoalescing({
|
@@ -4929,14 +4930,26 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
4929
4930
|
assertIsLamports(putativeLamports);
|
4930
4931
|
return putativeLamports;
|
4931
4932
|
}
|
4932
|
-
function
|
4933
|
-
return getMemoizedU64Encoder();
|
4933
|
+
function getDefaultLamportsEncoder() {
|
4934
|
+
return getLamportsEncoder(getMemoizedU64Encoder());
|
4935
|
+
}
|
4936
|
+
function getLamportsEncoder(innerEncoder) {
|
4937
|
+
return innerEncoder;
|
4938
|
+
}
|
4939
|
+
function getDefaultLamportsDecoder() {
|
4940
|
+
return getLamportsDecoder(getMemoizedU64Decoder());
|
4941
|
+
}
|
4942
|
+
function getLamportsDecoder(innerDecoder) {
|
4943
|
+
return transformDecoder(
|
4944
|
+
innerDecoder,
|
4945
|
+
(value) => lamports(typeof value === "bigint" ? value : BigInt(value))
|
4946
|
+
);
|
4934
4947
|
}
|
4935
|
-
function
|
4936
|
-
return
|
4948
|
+
function getDefaultLamportsCodec() {
|
4949
|
+
return combineCodec(getDefaultLamportsEncoder(), getDefaultLamportsDecoder());
|
4937
4950
|
}
|
4938
|
-
function getLamportsCodec() {
|
4939
|
-
return combineCodec(getLamportsEncoder(), getLamportsDecoder());
|
4951
|
+
function getLamportsCodec(innerCodec) {
|
4952
|
+
return combineCodec(getLamportsEncoder(innerCodec), getLamportsDecoder(innerCodec));
|
4940
4953
|
}
|
4941
4954
|
function isStringifiedBigInt(putativeBigInt) {
|
4942
4955
|
try {
|
@@ -5576,6 +5589,53 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
5576
5589
|
version: transaction.version
|
5577
5590
|
};
|
5578
5591
|
}
|
5592
|
+
function findAddressInLookupTables(address2, role, addressesByLookupTableAddress) {
|
5593
|
+
for (const [lookupTableAddress, addresses] of Object.entries(addressesByLookupTableAddress)) {
|
5594
|
+
for (let i = 0; i < addresses.length; i++) {
|
5595
|
+
if (address2 === addresses[i]) {
|
5596
|
+
return {
|
5597
|
+
address: address2,
|
5598
|
+
addressIndex: i,
|
5599
|
+
lookupTableAddress,
|
5600
|
+
role
|
5601
|
+
};
|
5602
|
+
}
|
5603
|
+
}
|
5604
|
+
}
|
5605
|
+
}
|
5606
|
+
function compressTransactionMessageUsingAddressLookupTables(transactionMessage, addressesByLookupTableAddress) {
|
5607
|
+
const lookupTableAddresses = new Set(Object.values(addressesByLookupTableAddress).flatMap((a) => a));
|
5608
|
+
const newInstructions = [];
|
5609
|
+
let updatedAnyInstructions = false;
|
5610
|
+
for (const instruction of transactionMessage.instructions) {
|
5611
|
+
if (!instruction.accounts) {
|
5612
|
+
newInstructions.push(instruction);
|
5613
|
+
continue;
|
5614
|
+
}
|
5615
|
+
const newAccounts = [];
|
5616
|
+
let updatedAnyAccounts = false;
|
5617
|
+
for (const account of instruction.accounts) {
|
5618
|
+
if ("lookupTableAddress" in account || !lookupTableAddresses.has(account.address) || isSignerRole(account.role)) {
|
5619
|
+
newAccounts.push(account);
|
5620
|
+
continue;
|
5621
|
+
}
|
5622
|
+
const lookupMetaAccount = findAddressInLookupTables(
|
5623
|
+
account.address,
|
5624
|
+
account.role,
|
5625
|
+
addressesByLookupTableAddress
|
5626
|
+
);
|
5627
|
+
newAccounts.push(Object.freeze(lookupMetaAccount));
|
5628
|
+
updatedAnyAccounts = true;
|
5629
|
+
updatedAnyInstructions = true;
|
5630
|
+
}
|
5631
|
+
newInstructions.push(
|
5632
|
+
Object.freeze(updatedAnyAccounts ? { ...instruction, accounts: newAccounts } : instruction)
|
5633
|
+
);
|
5634
|
+
}
|
5635
|
+
return Object.freeze(
|
5636
|
+
updatedAnyInstructions ? { ...transactionMessage, instructions: newInstructions } : transactionMessage
|
5637
|
+
);
|
5638
|
+
}
|
5579
5639
|
function createTransactionMessage({
|
5580
5640
|
version
|
5581
5641
|
}) {
|
@@ -6893,6 +6953,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
6893
6953
|
|
6894
6954
|
exports.AccountRole = AccountRole;
|
6895
6955
|
exports.BASE_ACCOUNT_SIZE = BASE_ACCOUNT_SIZE;
|
6956
|
+
exports.DEFAULT_RPC_CONFIG = DEFAULT_RPC_CONFIG;
|
6957
|
+
exports.DEFAULT_RPC_SUBSCRIPTIONS_CONFIG = DEFAULT_RPC_SUBSCRIPTIONS_CONFIG;
|
6896
6958
|
exports.Endian = Endian;
|
6897
6959
|
exports.SOLANA_ERROR__ACCOUNTS__ACCOUNT_NOT_FOUND = SOLANA_ERROR__ACCOUNTS__ACCOUNT_NOT_FOUND;
|
6898
6960
|
exports.SOLANA_ERROR__ACCOUNTS__EXPECTED_ALL_ACCOUNTS_TO_BE_DECODED = SOLANA_ERROR__ACCOUNTS__EXPECTED_ALL_ACCOUNTS_TO_BE_DECODED;
|
@@ -7167,6 +7229,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
7167
7229
|
exports.commitmentComparator = commitmentComparator;
|
7168
7230
|
exports.compileTransaction = compileTransaction;
|
7169
7231
|
exports.compileTransactionMessage = compileTransactionMessage;
|
7232
|
+
exports.compressTransactionMessageUsingAddressLookupTables = compressTransactionMessageUsingAddressLookupTables;
|
7170
7233
|
exports.containsBytes = containsBytes;
|
7171
7234
|
exports.createAddressWithSeed = createAddressWithSeed;
|
7172
7235
|
exports.createCodec = createCodec;
|
@@ -7260,6 +7323,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
7260
7323
|
exports.getDataEnumCodec = getDataEnumCodec;
|
7261
7324
|
exports.getDataEnumDecoder = getDataEnumDecoder;
|
7262
7325
|
exports.getDataEnumEncoder = getDataEnumEncoder;
|
7326
|
+
exports.getDefaultLamportsCodec = getDefaultLamportsCodec;
|
7327
|
+
exports.getDefaultLamportsDecoder = getDefaultLamportsDecoder;
|
7328
|
+
exports.getDefaultLamportsEncoder = getDefaultLamportsEncoder;
|
7263
7329
|
exports.getDiscriminatedUnionCodec = getDiscriminatedUnionCodec;
|
7264
7330
|
exports.getDiscriminatedUnionDecoder = getDiscriminatedUnionDecoder;
|
7265
7331
|
exports.getDiscriminatedUnionEncoder = getDiscriminatedUnionEncoder;
|
@@ -7452,5 +7518,5 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
7452
7518
|
return exports;
|
7453
7519
|
|
7454
7520
|
})({});
|
7455
|
-
//# sourceMappingURL=
|
7521
|
+
//# sourceMappingURL=index.development.js.map
|
7456
7522
|
//# sourceMappingURL=index.development.js.map
|