@solana/web3.js 2.0.0-experimental.ba21818 → 2.0.0-experimental.ba9b4c7
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/dist/index.browser.cjs +296 -75
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +289 -74
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +721 -238
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +287 -74
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +296 -75
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +287 -74
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +54 -47
- package/dist/types/airdrop-confirmer.d.ts +20 -0
- package/dist/types/airdrop.d.ts +23 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/send-transaction.d.ts +44 -0
- package/dist/types/transaction-confirmation-strategy-racer.d.ts +10 -0
- package/dist/types/{transaction-confirmation-strategy-signature.d.ts → transaction-confirmation-strategy-recent-signature.d.ts} +3 -3
- package/dist/types/transaction-confirmation-strategy-timeout.d.ts +8 -0
- package/dist/types/transaction-confirmation.d.ts +16 -18
- package/package.json +13 -13
|
@@ -224,6 +224,17 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
224
224
|
maxSize: encoder.maxSize
|
|
225
225
|
};
|
|
226
226
|
}
|
|
227
|
+
function mapDecoder(decoder, map) {
|
|
228
|
+
return {
|
|
229
|
+
decode: (bytes2, offset = 0) => {
|
|
230
|
+
const [value, length] = decoder.decode(bytes2, offset);
|
|
231
|
+
return [map(value, bytes2, offset), length];
|
|
232
|
+
},
|
|
233
|
+
description: decoder.description,
|
|
234
|
+
fixedSize: decoder.fixedSize,
|
|
235
|
+
maxSize: decoder.maxSize
|
|
236
|
+
};
|
|
237
|
+
}
|
|
227
238
|
|
|
228
239
|
// ../codecs-strings/dist/index.browser.js
|
|
229
240
|
init_env_shim();
|
|
@@ -286,6 +297,46 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
286
297
|
const bytesLength = length ?? bytes2.byteLength;
|
|
287
298
|
return bytes2.buffer.slice(bytesOffset, bytesOffset + bytesLength);
|
|
288
299
|
}
|
|
300
|
+
var getShortU16Encoder = (options = {}) => ({
|
|
301
|
+
description: options.description ?? "shortU16",
|
|
302
|
+
encode: (value) => {
|
|
303
|
+
assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
|
|
304
|
+
const bytes2 = [0];
|
|
305
|
+
for (let ii = 0; ; ii += 1) {
|
|
306
|
+
const alignedValue = value >> ii * 7;
|
|
307
|
+
if (alignedValue === 0) {
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
const nextSevenBits = 127 & alignedValue;
|
|
311
|
+
bytes2[ii] = nextSevenBits;
|
|
312
|
+
if (ii > 0) {
|
|
313
|
+
bytes2[ii - 1] |= 128;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return new Uint8Array(bytes2);
|
|
317
|
+
},
|
|
318
|
+
fixedSize: null,
|
|
319
|
+
maxSize: 3
|
|
320
|
+
});
|
|
321
|
+
var getShortU16Decoder = (options = {}) => ({
|
|
322
|
+
decode: (bytes2, offset = 0) => {
|
|
323
|
+
let value = 0;
|
|
324
|
+
let byteCount = 0;
|
|
325
|
+
while (++byteCount) {
|
|
326
|
+
const byteIndex = byteCount - 1;
|
|
327
|
+
const currentByte = bytes2[offset + byteIndex];
|
|
328
|
+
const nextSevenBits = 127 & currentByte;
|
|
329
|
+
value |= nextSevenBits << byteIndex * 7;
|
|
330
|
+
if ((currentByte & 128) === 0) {
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return [value, offset + byteCount];
|
|
335
|
+
},
|
|
336
|
+
description: options.description ?? "shortU16",
|
|
337
|
+
fixedSize: null,
|
|
338
|
+
maxSize: 3
|
|
339
|
+
});
|
|
289
340
|
var getU32Encoder = (options = {}) => numberEncoderFactory({
|
|
290
341
|
name: "u32",
|
|
291
342
|
options,
|
|
@@ -299,6 +350,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
299
350
|
options,
|
|
300
351
|
size: 4
|
|
301
352
|
});
|
|
353
|
+
var getU8Encoder = (options = {}) => numberEncoderFactory({
|
|
354
|
+
name: "u8",
|
|
355
|
+
options,
|
|
356
|
+
range: [0, Number("0xff")],
|
|
357
|
+
set: (view, value) => view.setUint8(0, value),
|
|
358
|
+
size: 1
|
|
359
|
+
});
|
|
360
|
+
var getU8Decoder = (options = {}) => numberDecoderFactory({
|
|
361
|
+
get: (view) => view.getUint8(0),
|
|
362
|
+
name: "u8",
|
|
363
|
+
options,
|
|
364
|
+
size: 1
|
|
365
|
+
});
|
|
366
|
+
var getU8Codec = (options = {}) => combineCodec(getU8Encoder(options), getU8Decoder(options));
|
|
302
367
|
|
|
303
368
|
// ../codecs-strings/dist/index.browser.js
|
|
304
369
|
function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
|
|
@@ -1175,17 +1240,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1175
1240
|
}
|
|
1176
1241
|
};
|
|
1177
1242
|
|
|
1178
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u8.mjs
|
|
1179
|
-
init_env_shim();
|
|
1180
|
-
var u8 = (options = {}) => numberFactory({
|
|
1181
|
-
name: "u8",
|
|
1182
|
-
size: 1,
|
|
1183
|
-
range: [0, Number("0xff")],
|
|
1184
|
-
set: (view, value) => view.setUint8(0, Number(value)),
|
|
1185
|
-
get: (view) => view.getUint8(0),
|
|
1186
|
-
options
|
|
1187
|
-
});
|
|
1188
|
-
|
|
1189
1243
|
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
|
|
1190
1244
|
init_env_shim();
|
|
1191
1245
|
var u32 = (options = {}) => numberFactory({
|
|
@@ -1450,6 +1504,188 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1450
1504
|
}
|
|
1451
1505
|
};
|
|
1452
1506
|
}
|
|
1507
|
+
|
|
1508
|
+
// ../codecs-data-structures/dist/index.browser.js
|
|
1509
|
+
init_env_shim();
|
|
1510
|
+
function sumCodecSizes(sizes) {
|
|
1511
|
+
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
1512
|
+
}
|
|
1513
|
+
function decodeArrayLikeCodecSize(size, childrenSizes, bytes2, offset) {
|
|
1514
|
+
if (typeof size === "number") {
|
|
1515
|
+
return [size, offset];
|
|
1516
|
+
}
|
|
1517
|
+
if (typeof size === "object") {
|
|
1518
|
+
return size.decode(bytes2, offset);
|
|
1519
|
+
}
|
|
1520
|
+
if (size === "remainder") {
|
|
1521
|
+
const childrenSize = sumCodecSizes(childrenSizes);
|
|
1522
|
+
if (childrenSize === null) {
|
|
1523
|
+
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
1524
|
+
}
|
|
1525
|
+
const remainder = bytes2.slice(offset).length;
|
|
1526
|
+
if (remainder % childrenSize !== 0) {
|
|
1527
|
+
throw new Error(
|
|
1528
|
+
`The remainder of the byte array (${remainder} bytes) cannot be split into chunks of ${childrenSize} bytes. Codecs of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${remainder} modulo ${childrenSize} should be equal to zero.`
|
|
1529
|
+
);
|
|
1530
|
+
}
|
|
1531
|
+
return [remainder / childrenSize, offset];
|
|
1532
|
+
}
|
|
1533
|
+
throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(size)}`);
|
|
1534
|
+
}
|
|
1535
|
+
function getArrayLikeCodecSizeDescription(size) {
|
|
1536
|
+
return typeof size === "object" ? size.description : `${size}`;
|
|
1537
|
+
}
|
|
1538
|
+
function getArrayLikeCodecSizeFromChildren(size, childrenSizes) {
|
|
1539
|
+
if (typeof size !== "number")
|
|
1540
|
+
return null;
|
|
1541
|
+
if (size === 0)
|
|
1542
|
+
return 0;
|
|
1543
|
+
const childrenSize = sumCodecSizes(childrenSizes);
|
|
1544
|
+
return childrenSize === null ? null : childrenSize * size;
|
|
1545
|
+
}
|
|
1546
|
+
function getArrayLikeCodecSizePrefix(size, realSize) {
|
|
1547
|
+
return typeof size === "object" ? size.encode(realSize) : new Uint8Array();
|
|
1548
|
+
}
|
|
1549
|
+
function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
|
|
1550
|
+
if (expected !== actual) {
|
|
1551
|
+
throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
function arrayCodecHelper(item, size, description) {
|
|
1555
|
+
if (size === "remainder" && item.fixedSize === null) {
|
|
1556
|
+
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
1557
|
+
}
|
|
1558
|
+
return {
|
|
1559
|
+
description: description ?? `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
|
|
1560
|
+
fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
|
|
1561
|
+
maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
|
|
1562
|
+
};
|
|
1563
|
+
}
|
|
1564
|
+
function getArrayEncoder(item, options = {}) {
|
|
1565
|
+
const size = options.size ?? getU32Encoder();
|
|
1566
|
+
return {
|
|
1567
|
+
...arrayCodecHelper(item, size, options.description),
|
|
1568
|
+
encode: (value) => {
|
|
1569
|
+
if (typeof size === "number") {
|
|
1570
|
+
assertValidNumberOfItemsForCodec("array", size, value.length);
|
|
1571
|
+
}
|
|
1572
|
+
return mergeBytes([getArrayLikeCodecSizePrefix(size, value.length), ...value.map((v) => item.encode(v))]);
|
|
1573
|
+
}
|
|
1574
|
+
};
|
|
1575
|
+
}
|
|
1576
|
+
function getArrayDecoder(item, options = {}) {
|
|
1577
|
+
const size = options.size ?? getU32Decoder();
|
|
1578
|
+
return {
|
|
1579
|
+
...arrayCodecHelper(item, size, options.description),
|
|
1580
|
+
decode: (bytes2, offset = 0) => {
|
|
1581
|
+
if (typeof size === "object" && bytes2.slice(offset).length === 0) {
|
|
1582
|
+
return [[], offset];
|
|
1583
|
+
}
|
|
1584
|
+
const [resolvedSize, newOffset] = decodeArrayLikeCodecSize(size, [item.fixedSize], bytes2, offset);
|
|
1585
|
+
offset = newOffset;
|
|
1586
|
+
const values = [];
|
|
1587
|
+
for (let i = 0; i < resolvedSize; i += 1) {
|
|
1588
|
+
const [value, newOffset2] = item.decode(bytes2, offset);
|
|
1589
|
+
values.push(value);
|
|
1590
|
+
offset = newOffset2;
|
|
1591
|
+
}
|
|
1592
|
+
return [values, offset];
|
|
1593
|
+
}
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1596
|
+
function getBytesEncoder(options = {}) {
|
|
1597
|
+
const size = options.size ?? "variable";
|
|
1598
|
+
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
1599
|
+
const description = options.description ?? `bytes(${sizeDescription})`;
|
|
1600
|
+
const byteEncoder = {
|
|
1601
|
+
description,
|
|
1602
|
+
encode: (value) => value,
|
|
1603
|
+
fixedSize: null,
|
|
1604
|
+
maxSize: null
|
|
1605
|
+
};
|
|
1606
|
+
if (size === "variable") {
|
|
1607
|
+
return byteEncoder;
|
|
1608
|
+
}
|
|
1609
|
+
if (typeof size === "number") {
|
|
1610
|
+
return fixEncoder(byteEncoder, size, description);
|
|
1611
|
+
}
|
|
1612
|
+
return {
|
|
1613
|
+
...byteEncoder,
|
|
1614
|
+
encode: (value) => {
|
|
1615
|
+
const contentBytes = byteEncoder.encode(value);
|
|
1616
|
+
const lengthBytes = size.encode(contentBytes.length);
|
|
1617
|
+
return mergeBytes([lengthBytes, contentBytes]);
|
|
1618
|
+
}
|
|
1619
|
+
};
|
|
1620
|
+
}
|
|
1621
|
+
function getBytesDecoder(options = {}) {
|
|
1622
|
+
const size = options.size ?? "variable";
|
|
1623
|
+
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
1624
|
+
const description = options.description ?? `bytes(${sizeDescription})`;
|
|
1625
|
+
const byteDecoder = {
|
|
1626
|
+
decode: (bytes2, offset = 0) => {
|
|
1627
|
+
const slice = bytes2.slice(offset);
|
|
1628
|
+
return [slice, offset + slice.length];
|
|
1629
|
+
},
|
|
1630
|
+
description,
|
|
1631
|
+
fixedSize: null,
|
|
1632
|
+
maxSize: null
|
|
1633
|
+
};
|
|
1634
|
+
if (size === "variable") {
|
|
1635
|
+
return byteDecoder;
|
|
1636
|
+
}
|
|
1637
|
+
if (typeof size === "number") {
|
|
1638
|
+
return fixDecoder(byteDecoder, size, description);
|
|
1639
|
+
}
|
|
1640
|
+
return {
|
|
1641
|
+
...byteDecoder,
|
|
1642
|
+
decode: (bytes2, offset = 0) => {
|
|
1643
|
+
assertByteArrayIsNotEmptyForCodec("bytes", bytes2, offset);
|
|
1644
|
+
const [lengthBigInt, lengthOffset] = size.decode(bytes2, offset);
|
|
1645
|
+
const length = Number(lengthBigInt);
|
|
1646
|
+
offset = lengthOffset;
|
|
1647
|
+
const contentBytes = bytes2.slice(offset, offset + length);
|
|
1648
|
+
assertByteArrayHasEnoughBytesForCodec("bytes", length, contentBytes);
|
|
1649
|
+
const [value, contentOffset] = byteDecoder.decode(contentBytes);
|
|
1650
|
+
offset += contentOffset;
|
|
1651
|
+
return [value, offset];
|
|
1652
|
+
}
|
|
1653
|
+
};
|
|
1654
|
+
}
|
|
1655
|
+
function structCodecHelper(fields, description) {
|
|
1656
|
+
const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
|
|
1657
|
+
return {
|
|
1658
|
+
description: description ?? `struct(${fieldDescriptions})`,
|
|
1659
|
+
fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
|
|
1660
|
+
maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
|
|
1661
|
+
};
|
|
1662
|
+
}
|
|
1663
|
+
function getStructEncoder(fields, options = {}) {
|
|
1664
|
+
return {
|
|
1665
|
+
...structCodecHelper(fields, options.description),
|
|
1666
|
+
encode: (struct2) => {
|
|
1667
|
+
const fieldBytes = fields.map(([key, codec]) => codec.encode(struct2[key]));
|
|
1668
|
+
return mergeBytes(fieldBytes);
|
|
1669
|
+
}
|
|
1670
|
+
};
|
|
1671
|
+
}
|
|
1672
|
+
function getStructDecoder(fields, options = {}) {
|
|
1673
|
+
return {
|
|
1674
|
+
...structCodecHelper(fields, options.description),
|
|
1675
|
+
decode: (bytes2, offset = 0) => {
|
|
1676
|
+
const struct2 = {};
|
|
1677
|
+
fields.forEach(([key, codec]) => {
|
|
1678
|
+
const [value, newOffset] = codec.decode(bytes2, offset);
|
|
1679
|
+
offset = newOffset;
|
|
1680
|
+
struct2[key] = value;
|
|
1681
|
+
});
|
|
1682
|
+
return [struct2, offset];
|
|
1683
|
+
}
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
function getStructCodec(fields, options = {}) {
|
|
1687
|
+
return combineCodec(getStructEncoder(fields, options), getStructDecoder(fields, options));
|
|
1688
|
+
}
|
|
1453
1689
|
function getUnsignedTransaction(transaction) {
|
|
1454
1690
|
if ("signatures" in transaction) {
|
|
1455
1691
|
const {
|
|
@@ -1471,8 +1707,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1471
1707
|
) {
|
|
1472
1708
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
1473
1709
|
}
|
|
1474
|
-
const
|
|
1475
|
-
const numBytes =
|
|
1710
|
+
const bytes2 = base58.serialize(putativeBlockhash);
|
|
1711
|
+
const numBytes = bytes2.byteLength;
|
|
1476
1712
|
if (numBytes !== 32) {
|
|
1477
1713
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
1478
1714
|
}
|
|
@@ -1882,137 +2118,161 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1882
2118
|
signatures
|
|
1883
2119
|
};
|
|
1884
2120
|
}
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
};
|
|
1894
|
-
}
|
|
1895
|
-
function getAddressTableLookupCodec() {
|
|
1896
|
-
return struct(
|
|
1897
|
-
[
|
|
2121
|
+
var lookupTableAddressDescription = "The address of the address lookup table account from which instruction addresses should be looked up" ;
|
|
2122
|
+
var writableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as writeable" ;
|
|
2123
|
+
var readableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as read-only" ;
|
|
2124
|
+
var addressTableLookupDescription = "A pointer to the address of an address lookup table, along with the readonly/writeable indices of the addresses that should be loaded from it" ;
|
|
2125
|
+
var memoizedAddressTableLookupEncoder;
|
|
2126
|
+
function getAddressTableLookupEncoder() {
|
|
2127
|
+
if (!memoizedAddressTableLookupEncoder) {
|
|
2128
|
+
memoizedAddressTableLookupEncoder = getStructEncoder(
|
|
1898
2129
|
[
|
|
1899
|
-
"lookupTableAddress",
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
2130
|
+
["lookupTableAddress", getAddressEncoder({ description: lookupTableAddressDescription })],
|
|
2131
|
+
[
|
|
2132
|
+
"writableIndices",
|
|
2133
|
+
getArrayEncoder(getU8Encoder(), {
|
|
2134
|
+
description: writableIndicesDescription,
|
|
2135
|
+
size: getShortU16Encoder()
|
|
2136
|
+
})
|
|
2137
|
+
],
|
|
2138
|
+
[
|
|
2139
|
+
"readableIndices",
|
|
2140
|
+
getArrayEncoder(getU8Encoder(), {
|
|
2141
|
+
description: readableIndicesDescription,
|
|
2142
|
+
size: getShortU16Encoder()
|
|
2143
|
+
})
|
|
2144
|
+
]
|
|
1905
2145
|
],
|
|
2146
|
+
{ description: addressTableLookupDescription }
|
|
2147
|
+
);
|
|
2148
|
+
}
|
|
2149
|
+
return memoizedAddressTableLookupEncoder;
|
|
2150
|
+
}
|
|
2151
|
+
var memoizedAddressTableLookupDecoder;
|
|
2152
|
+
function getAddressTableLookupDecoder() {
|
|
2153
|
+
if (!memoizedAddressTableLookupDecoder) {
|
|
2154
|
+
memoizedAddressTableLookupDecoder = getStructDecoder(
|
|
1906
2155
|
[
|
|
1907
|
-
"
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
2156
|
+
["lookupTableAddress", getAddressDecoder({ description: lookupTableAddressDescription })],
|
|
2157
|
+
[
|
|
2158
|
+
"writableIndices",
|
|
2159
|
+
getArrayDecoder(getU8Decoder(), {
|
|
2160
|
+
description: writableIndicesDescription,
|
|
2161
|
+
size: getShortU16Decoder()
|
|
2162
|
+
})
|
|
2163
|
+
],
|
|
2164
|
+
[
|
|
2165
|
+
"readableIndices",
|
|
2166
|
+
getArrayDecoder(getU8Decoder(), {
|
|
2167
|
+
description: readableIndicesDescription,
|
|
2168
|
+
size: getShortU16Decoder()
|
|
2169
|
+
})
|
|
2170
|
+
]
|
|
1914
2171
|
],
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
);
|
|
2172
|
+
{ description: addressTableLookupDescription }
|
|
2173
|
+
);
|
|
2174
|
+
}
|
|
2175
|
+
return memoizedAddressTableLookupDecoder;
|
|
2176
|
+
}
|
|
2177
|
+
function getAddressTableLookupCodec() {
|
|
2178
|
+
return combineCodec(getAddressTableLookupEncoder(), getAddressTableLookupDecoder());
|
|
2179
|
+
}
|
|
2180
|
+
var memoizedU8Codec;
|
|
2181
|
+
function getMemoizedU8Codec() {
|
|
2182
|
+
if (!memoizedU8Codec)
|
|
2183
|
+
memoizedU8Codec = getU8Codec();
|
|
2184
|
+
return memoizedU8Codec;
|
|
1929
2185
|
}
|
|
2186
|
+
function getMemoizedU8CodecDescription(description) {
|
|
2187
|
+
const codec = getMemoizedU8Codec();
|
|
2188
|
+
return {
|
|
2189
|
+
...codec,
|
|
2190
|
+
description: description ?? codec.description
|
|
2191
|
+
};
|
|
2192
|
+
}
|
|
2193
|
+
var numSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" ;
|
|
2194
|
+
var numReadonlySignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction, but may not be writable" ;
|
|
2195
|
+
var numReadonlyNonSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" ;
|
|
2196
|
+
var messageHeaderDescription = "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" ;
|
|
1930
2197
|
function getMessageHeaderCodec() {
|
|
1931
|
-
return
|
|
2198
|
+
return getStructCodec(
|
|
1932
2199
|
[
|
|
1933
|
-
[
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
{
|
|
1937
|
-
description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction"
|
|
1938
|
-
}
|
|
1939
|
-
)
|
|
1940
|
-
],
|
|
1941
|
-
[
|
|
1942
|
-
"numReadonlySignerAccounts",
|
|
1943
|
-
u8(
|
|
1944
|
-
{
|
|
1945
|
-
description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction, but may not be writable"
|
|
1946
|
-
}
|
|
1947
|
-
)
|
|
1948
|
-
],
|
|
1949
|
-
[
|
|
1950
|
-
"numReadonlyNonSignerAccounts",
|
|
1951
|
-
u8(
|
|
1952
|
-
{
|
|
1953
|
-
description: "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable"
|
|
1954
|
-
}
|
|
1955
|
-
)
|
|
1956
|
-
]
|
|
2200
|
+
["numSignerAccounts", getMemoizedU8CodecDescription(numSignerAccountsDescription)],
|
|
2201
|
+
["numReadonlySignerAccounts", getMemoizedU8CodecDescription(numReadonlySignerAccountsDescription)],
|
|
2202
|
+
["numReadonlyNonSignerAccounts", getMemoizedU8CodecDescription(numReadonlyNonSignerAccountsDescription)]
|
|
1957
2203
|
],
|
|
1958
2204
|
{
|
|
1959
|
-
description:
|
|
1960
|
-
}
|
|
2205
|
+
description: messageHeaderDescription
|
|
2206
|
+
}
|
|
1961
2207
|
);
|
|
1962
2208
|
}
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
)
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
)
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
}
|
|
1992
|
-
]
|
|
1993
|
-
]),
|
|
1994
|
-
(value) => {
|
|
1995
|
-
if (value.accountIndices !== void 0 && value.data !== void 0) {
|
|
1996
|
-
return value;
|
|
2209
|
+
var programAddressIndexDescription = "The index of the program being called, according to the well-ordered accounts list for this transaction" ;
|
|
2210
|
+
var accountIndexDescription = "The index of an account, according to the well-ordered accounts list for this transaction" ;
|
|
2211
|
+
var accountIndicesDescription = "An optional list of account indices, according to the well-ordered accounts list for this transaction, in the order in which the program being called expects them" ;
|
|
2212
|
+
var dataDescription = "An optional buffer of data passed to the instruction" ;
|
|
2213
|
+
var memoizedGetInstructionEncoder;
|
|
2214
|
+
function getInstructionEncoder() {
|
|
2215
|
+
if (!memoizedGetInstructionEncoder) {
|
|
2216
|
+
memoizedGetInstructionEncoder = mapEncoder(
|
|
2217
|
+
getStructEncoder([
|
|
2218
|
+
["programAddressIndex", getU8Encoder({ description: programAddressIndexDescription })],
|
|
2219
|
+
[
|
|
2220
|
+
"accountIndices",
|
|
2221
|
+
getArrayEncoder(getU8Encoder({ description: accountIndexDescription }), {
|
|
2222
|
+
description: accountIndicesDescription,
|
|
2223
|
+
size: getShortU16Encoder()
|
|
2224
|
+
})
|
|
2225
|
+
],
|
|
2226
|
+
["data", getBytesEncoder({ description: dataDescription, size: getShortU16Encoder() })]
|
|
2227
|
+
]),
|
|
2228
|
+
// Convert an instruction to have all fields defined
|
|
2229
|
+
(instruction) => {
|
|
2230
|
+
if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
|
|
2231
|
+
return instruction;
|
|
2232
|
+
}
|
|
2233
|
+
return {
|
|
2234
|
+
...instruction,
|
|
2235
|
+
accountIndices: instruction.accountIndices ?? [],
|
|
2236
|
+
data: instruction.data ?? new Uint8Array(0)
|
|
2237
|
+
};
|
|
1997
2238
|
}
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2239
|
+
);
|
|
2240
|
+
}
|
|
2241
|
+
return memoizedGetInstructionEncoder;
|
|
2242
|
+
}
|
|
2243
|
+
var memoizedGetInstructionDecoder;
|
|
2244
|
+
function getInstructionDecoder() {
|
|
2245
|
+
if (!memoizedGetInstructionDecoder) {
|
|
2246
|
+
memoizedGetInstructionDecoder = mapDecoder(
|
|
2247
|
+
getStructDecoder([
|
|
2248
|
+
["programAddressIndex", getU8Decoder({ description: programAddressIndexDescription })],
|
|
2249
|
+
[
|
|
2250
|
+
"accountIndices",
|
|
2251
|
+
getArrayDecoder(getU8Decoder({ description: accountIndexDescription }), {
|
|
2252
|
+
description: accountIndicesDescription,
|
|
2253
|
+
size: getShortU16Decoder()
|
|
2254
|
+
})
|
|
2255
|
+
],
|
|
2256
|
+
["data", getBytesDecoder({ description: dataDescription, size: getShortU16Decoder() })]
|
|
2257
|
+
]),
|
|
2258
|
+
// Convert an instruction to exclude optional fields if they are empty
|
|
2259
|
+
(instruction) => {
|
|
2260
|
+
if (instruction.accountIndices.length && instruction.data.byteLength) {
|
|
2261
|
+
return instruction;
|
|
2262
|
+
}
|
|
2263
|
+
const { accountIndices, data, ...rest } = instruction;
|
|
2264
|
+
return {
|
|
2265
|
+
...rest,
|
|
2266
|
+
...accountIndices.length ? { accountIndices } : null,
|
|
2267
|
+
...data.byteLength ? { data } : null
|
|
2268
|
+
};
|
|
2007
2269
|
}
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
}
|
|
2015
|
-
);
|
|
2270
|
+
);
|
|
2271
|
+
}
|
|
2272
|
+
return memoizedGetInstructionDecoder;
|
|
2273
|
+
}
|
|
2274
|
+
function getInstructionCodec() {
|
|
2275
|
+
return combineCodec(getInstructionEncoder(), getInstructionDecoder());
|
|
2016
2276
|
}
|
|
2017
2277
|
var VERSION_FLAG_MASK = 128;
|
|
2018
2278
|
var BASE_CONFIG = {
|
|
@@ -2020,8 +2280,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2020
2280
|
fixedSize: null,
|
|
2021
2281
|
maxSize: 1
|
|
2022
2282
|
};
|
|
2023
|
-
function decode(
|
|
2024
|
-
const firstByte =
|
|
2283
|
+
function decode(bytes2, offset = 0) {
|
|
2284
|
+
const firstByte = bytes2[offset];
|
|
2025
2285
|
if ((firstByte & VERSION_FLAG_MASK) === 0) {
|
|
2026
2286
|
return ["legacy", offset];
|
|
2027
2287
|
} else {
|
|
@@ -2090,18 +2350,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2090
2350
|
).serialize(compiledMessage);
|
|
2091
2351
|
}
|
|
2092
2352
|
}
|
|
2093
|
-
function
|
|
2094
|
-
const codec = getAddressCodec();
|
|
2095
|
-
return {
|
|
2096
|
-
description: codec.description,
|
|
2097
|
-
deserialize: codec.decode,
|
|
2098
|
-
fixedSize: codec.fixedSize,
|
|
2099
|
-
maxSize: codec.maxSize,
|
|
2100
|
-
serialize: codec.encode
|
|
2101
|
-
};
|
|
2102
|
-
}
|
|
2103
|
-
function transactionVersionSerializerCompat() {
|
|
2104
|
-
const codec = getTransactionVersionCodec();
|
|
2353
|
+
function toSerializer(codec) {
|
|
2105
2354
|
return {
|
|
2106
2355
|
description: codec.description,
|
|
2107
2356
|
deserialize: codec.decode,
|
|
@@ -2112,11 +2361,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2112
2361
|
}
|
|
2113
2362
|
function getPreludeStructSerializerTuple() {
|
|
2114
2363
|
return [
|
|
2115
|
-
["version",
|
|
2116
|
-
["header", getMessageHeaderCodec()],
|
|
2364
|
+
["version", toSerializer(getTransactionVersionCodec())],
|
|
2365
|
+
["header", toSerializer(getMessageHeaderCodec())],
|
|
2117
2366
|
[
|
|
2118
2367
|
"staticAccounts",
|
|
2119
|
-
array(
|
|
2368
|
+
array(toSerializer(getAddressCodec()), {
|
|
2120
2369
|
description: "A compact-array of static account addresses belonging to this transaction" ,
|
|
2121
2370
|
size: shortU16()
|
|
2122
2371
|
})
|
|
@@ -2131,7 +2380,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2131
2380
|
],
|
|
2132
2381
|
[
|
|
2133
2382
|
"instructions",
|
|
2134
|
-
array(getInstructionCodec(), {
|
|
2383
|
+
array(toSerializer(getInstructionCodec()), {
|
|
2135
2384
|
description: "A compact-array of instructions belonging to this transaction" ,
|
|
2136
2385
|
size: shortU16()
|
|
2137
2386
|
})
|
|
@@ -2139,7 +2388,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2139
2388
|
];
|
|
2140
2389
|
}
|
|
2141
2390
|
function getAddressTableLookupsSerializer() {
|
|
2142
|
-
return array(getAddressTableLookupCodec(), {
|
|
2391
|
+
return array(toSerializer(getAddressTableLookupCodec()), {
|
|
2143
2392
|
...{ description: "A compact array of address table lookups belonging to this transaction" } ,
|
|
2144
2393
|
size: shortU16()
|
|
2145
2394
|
});
|
|
@@ -2185,8 +2434,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2185
2434
|
) {
|
|
2186
2435
|
throw new Error("Expected input string to decode to a byte array of length 64.");
|
|
2187
2436
|
}
|
|
2188
|
-
const
|
|
2189
|
-
const numBytes =
|
|
2437
|
+
const bytes2 = base58.serialize(putativeTransactionSignature);
|
|
2438
|
+
const numBytes = bytes2.byteLength;
|
|
2190
2439
|
if (numBytes !== 64) {
|
|
2191
2440
|
throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
|
|
2192
2441
|
}
|
|
@@ -2204,8 +2453,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2204
2453
|
) {
|
|
2205
2454
|
return false;
|
|
2206
2455
|
}
|
|
2207
|
-
const
|
|
2208
|
-
const numBytes =
|
|
2456
|
+
const bytes2 = base58.serialize(putativeTransactionSignature);
|
|
2457
|
+
const numBytes = bytes2.byteLength;
|
|
2209
2458
|
if (numBytes !== 64) {
|
|
2210
2459
|
return false;
|
|
2211
2460
|
}
|
|
@@ -2217,13 +2466,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2217
2466
|
return signature;
|
|
2218
2467
|
}
|
|
2219
2468
|
function getSignatureFromTransaction(transaction) {
|
|
2220
|
-
const
|
|
2221
|
-
if (!
|
|
2469
|
+
const signatureBytes = transaction.signatures[transaction.feePayer];
|
|
2470
|
+
if (!signatureBytes) {
|
|
2222
2471
|
throw new Error(
|
|
2223
2472
|
"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
|
|
2224
2473
|
);
|
|
2225
2474
|
}
|
|
2226
|
-
|
|
2475
|
+
const transactionSignature2 = base58.deserialize(signatureBytes)[0];
|
|
2476
|
+
return transactionSignature2;
|
|
2227
2477
|
}
|
|
2228
2478
|
async function signTransaction(keyPairs, transaction) {
|
|
2229
2479
|
const compiledMessage = compileMessage(transaction);
|
|
@@ -2257,15 +2507,43 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2257
2507
|
}
|
|
2258
2508
|
}
|
|
2259
2509
|
|
|
2260
|
-
// src/
|
|
2510
|
+
// src/airdrop.ts
|
|
2261
2511
|
init_env_shim();
|
|
2262
2512
|
|
|
2263
|
-
//
|
|
2513
|
+
// src/airdrop-confirmer.ts
|
|
2264
2514
|
init_env_shim();
|
|
2265
|
-
|
|
2266
|
-
|
|
2515
|
+
|
|
2516
|
+
// src/transaction-confirmation-strategy-racer.ts
|
|
2517
|
+
init_env_shim();
|
|
2518
|
+
async function raceStrategies(signature, config, getSpecificStrategiesForRace) {
|
|
2519
|
+
const { abortSignal: callerAbortSignal, commitment, getRecentSignatureConfirmationPromise } = config;
|
|
2520
|
+
callerAbortSignal.throwIfAborted();
|
|
2521
|
+
const abortController = new AbortController();
|
|
2522
|
+
function handleAbort() {
|
|
2523
|
+
abortController.abort();
|
|
2524
|
+
}
|
|
2525
|
+
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
2526
|
+
try {
|
|
2527
|
+
const specificStrategies = getSpecificStrategiesForRace({
|
|
2528
|
+
...config,
|
|
2529
|
+
abortSignal: abortController.signal
|
|
2530
|
+
});
|
|
2531
|
+
return await Promise.race([
|
|
2532
|
+
getRecentSignatureConfirmationPromise({
|
|
2533
|
+
abortSignal: abortController.signal,
|
|
2534
|
+
commitment,
|
|
2535
|
+
signature
|
|
2536
|
+
}),
|
|
2537
|
+
...specificStrategies
|
|
2538
|
+
]);
|
|
2539
|
+
} finally {
|
|
2540
|
+
abortController.abort();
|
|
2541
|
+
}
|
|
2267
2542
|
}
|
|
2268
2543
|
|
|
2544
|
+
// src/transaction-confirmation-strategy-recent-signature.ts
|
|
2545
|
+
init_env_shim();
|
|
2546
|
+
|
|
2269
2547
|
// ../rpc-core/dist/index.browser.js
|
|
2270
2548
|
init_env_shim();
|
|
2271
2549
|
function getCommitmentScore(commitment) {
|
|
@@ -2791,6 +3069,144 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2791
3069
|
return createSolanaRpcSubscriptionsApi(config);
|
|
2792
3070
|
}
|
|
2793
3071
|
|
|
3072
|
+
// src/transaction-confirmation-strategy-recent-signature.ts
|
|
3073
|
+
function createRecentSignatureConfirmationPromiseFactory(rpc, rpcSubscriptions) {
|
|
3074
|
+
return async function getRecentSignatureConfirmationPromise({
|
|
3075
|
+
abortSignal: callerAbortSignal,
|
|
3076
|
+
commitment,
|
|
3077
|
+
signature
|
|
3078
|
+
}) {
|
|
3079
|
+
const abortController = new AbortController();
|
|
3080
|
+
function handleAbort() {
|
|
3081
|
+
abortController.abort();
|
|
3082
|
+
}
|
|
3083
|
+
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
3084
|
+
const signatureStatusNotifications = await rpcSubscriptions.signatureNotifications(signature, { commitment }).subscribe({ abortSignal: abortController.signal });
|
|
3085
|
+
const signatureDidCommitPromise = (async () => {
|
|
3086
|
+
for await (const signatureStatusNotification of signatureStatusNotifications) {
|
|
3087
|
+
if (signatureStatusNotification.value.err) {
|
|
3088
|
+
throw new Error(`The transaction with signature \`${signature}\` failed.`, {
|
|
3089
|
+
cause: signatureStatusNotification.value.err
|
|
3090
|
+
});
|
|
3091
|
+
} else {
|
|
3092
|
+
return;
|
|
3093
|
+
}
|
|
3094
|
+
}
|
|
3095
|
+
})();
|
|
3096
|
+
const signatureStatusLookupPromise = (async () => {
|
|
3097
|
+
const { value: signatureStatusResults } = await rpc.getSignatureStatuses([signature]).send({ abortSignal: abortController.signal });
|
|
3098
|
+
const signatureStatus = signatureStatusResults[0];
|
|
3099
|
+
if (signatureStatus && signatureStatus.confirmationStatus && commitmentComparator(signatureStatus.confirmationStatus, commitment) >= 0) {
|
|
3100
|
+
return;
|
|
3101
|
+
} else {
|
|
3102
|
+
await new Promise(() => {
|
|
3103
|
+
});
|
|
3104
|
+
}
|
|
3105
|
+
})();
|
|
3106
|
+
try {
|
|
3107
|
+
return await Promise.race([signatureDidCommitPromise, signatureStatusLookupPromise]);
|
|
3108
|
+
} finally {
|
|
3109
|
+
abortController.abort();
|
|
3110
|
+
}
|
|
3111
|
+
};
|
|
3112
|
+
}
|
|
3113
|
+
|
|
3114
|
+
// src/transaction-confirmation-strategy-timeout.ts
|
|
3115
|
+
init_env_shim();
|
|
3116
|
+
async function getTimeoutPromise({ abortSignal: callerAbortSignal, commitment }) {
|
|
3117
|
+
return await new Promise((_, reject) => {
|
|
3118
|
+
const handleAbort = (e3) => {
|
|
3119
|
+
clearTimeout(timeoutId);
|
|
3120
|
+
const abortError = new DOMException(e3.target.reason, "AbortError");
|
|
3121
|
+
reject(abortError);
|
|
3122
|
+
};
|
|
3123
|
+
callerAbortSignal.addEventListener("abort", handleAbort);
|
|
3124
|
+
const timeoutMs = commitment === "processed" ? 3e4 : 6e4;
|
|
3125
|
+
const startMs = performance.now();
|
|
3126
|
+
const timeoutId = (
|
|
3127
|
+
// We use `setTimeout` instead of `AbortSignal.timeout()` because we want to measure
|
|
3128
|
+
// elapsed time instead of active time.
|
|
3129
|
+
// See https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static
|
|
3130
|
+
setTimeout(() => {
|
|
3131
|
+
const elapsedMs = performance.now() - startMs;
|
|
3132
|
+
reject(new DOMException(`Timeout elapsed after ${elapsedMs} ms`, "TimeoutError"));
|
|
3133
|
+
}, timeoutMs)
|
|
3134
|
+
);
|
|
3135
|
+
});
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3138
|
+
// src/airdrop-confirmer.ts
|
|
3139
|
+
function createDefaultSignatureOnlyRecentTransactionConfirmer({
|
|
3140
|
+
rpc,
|
|
3141
|
+
rpcSubscriptions
|
|
3142
|
+
}) {
|
|
3143
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
3144
|
+
rpc,
|
|
3145
|
+
rpcSubscriptions
|
|
3146
|
+
);
|
|
3147
|
+
return async function confirmSignatureOnlyRecentTransaction(config) {
|
|
3148
|
+
await waitForRecentTransactionConfirmationUntilTimeout({
|
|
3149
|
+
...config,
|
|
3150
|
+
getRecentSignatureConfirmationPromise,
|
|
3151
|
+
getTimeoutPromise
|
|
3152
|
+
});
|
|
3153
|
+
};
|
|
3154
|
+
}
|
|
3155
|
+
async function waitForRecentTransactionConfirmationUntilTimeout(config) {
|
|
3156
|
+
await raceStrategies(
|
|
3157
|
+
config.signature,
|
|
3158
|
+
config,
|
|
3159
|
+
function getSpecificStrategiesForRace({ abortSignal, commitment, getTimeoutPromise: getTimeoutPromise2 }) {
|
|
3160
|
+
return [
|
|
3161
|
+
getTimeoutPromise2({
|
|
3162
|
+
abortSignal,
|
|
3163
|
+
commitment
|
|
3164
|
+
})
|
|
3165
|
+
];
|
|
3166
|
+
}
|
|
3167
|
+
);
|
|
3168
|
+
}
|
|
3169
|
+
|
|
3170
|
+
// src/airdrop.ts
|
|
3171
|
+
function createDefaultAirdropRequester({ rpc, rpcSubscriptions }) {
|
|
3172
|
+
const confirmSignatureOnlyTransaction = createDefaultSignatureOnlyRecentTransactionConfirmer({
|
|
3173
|
+
rpc,
|
|
3174
|
+
rpcSubscriptions
|
|
3175
|
+
});
|
|
3176
|
+
return async function requestAirdrop(config) {
|
|
3177
|
+
return await requestAndConfirmAirdrop({
|
|
3178
|
+
...config,
|
|
3179
|
+
confirmSignatureOnlyTransaction,
|
|
3180
|
+
rpc
|
|
3181
|
+
});
|
|
3182
|
+
};
|
|
3183
|
+
}
|
|
3184
|
+
async function requestAndConfirmAirdrop({
|
|
3185
|
+
abortSignal,
|
|
3186
|
+
commitment,
|
|
3187
|
+
confirmSignatureOnlyTransaction,
|
|
3188
|
+
lamports,
|
|
3189
|
+
recipientAddress,
|
|
3190
|
+
rpc
|
|
3191
|
+
}) {
|
|
3192
|
+
const airdropTransactionSignature = await rpc.requestAirdrop(recipientAddress, lamports, { commitment }).send({ abortSignal });
|
|
3193
|
+
await confirmSignatureOnlyTransaction({
|
|
3194
|
+
abortSignal,
|
|
3195
|
+
commitment,
|
|
3196
|
+
signature: airdropTransactionSignature
|
|
3197
|
+
});
|
|
3198
|
+
return airdropTransactionSignature;
|
|
3199
|
+
}
|
|
3200
|
+
|
|
3201
|
+
// src/rpc.ts
|
|
3202
|
+
init_env_shim();
|
|
3203
|
+
|
|
3204
|
+
// ../functional/dist/index.browser.js
|
|
3205
|
+
init_env_shim();
|
|
3206
|
+
function pipe(init, ...fns) {
|
|
3207
|
+
return fns.reduce((acc, fn) => fn(acc), init);
|
|
3208
|
+
}
|
|
3209
|
+
|
|
2794
3210
|
// ../rpc-transport/dist/index.browser.js
|
|
2795
3211
|
init_env_shim();
|
|
2796
3212
|
var SolanaJsonRpcError = class extends Error {
|
|
@@ -3675,6 +4091,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
3675
4091
|
);
|
|
3676
4092
|
}
|
|
3677
4093
|
|
|
4094
|
+
// src/send-transaction.ts
|
|
4095
|
+
init_env_shim();
|
|
4096
|
+
|
|
3678
4097
|
// src/transaction-confirmation.ts
|
|
3679
4098
|
init_env_shim();
|
|
3680
4099
|
|
|
@@ -3766,99 +4185,44 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
3766
4185
|
};
|
|
3767
4186
|
}
|
|
3768
4187
|
|
|
3769
|
-
// src/transaction-confirmation-strategy-signature.ts
|
|
3770
|
-
init_env_shim();
|
|
3771
|
-
function createSignatureConfirmationPromiseFactory(rpc, rpcSubscriptions) {
|
|
3772
|
-
return async function getSignatureConfirmationPromise({ abortSignal: callerAbortSignal, commitment, signature }) {
|
|
3773
|
-
const abortController = new AbortController();
|
|
3774
|
-
function handleAbort() {
|
|
3775
|
-
abortController.abort();
|
|
3776
|
-
}
|
|
3777
|
-
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
3778
|
-
const signatureStatusNotifications = await rpcSubscriptions.signatureNotifications(signature, { commitment }).subscribe({ abortSignal: abortController.signal });
|
|
3779
|
-
const signatureDidCommitPromise = (async () => {
|
|
3780
|
-
for await (const signatureStatusNotification of signatureStatusNotifications) {
|
|
3781
|
-
if (signatureStatusNotification.value.err) {
|
|
3782
|
-
throw new Error(`The transaction with signature \`${signature}\` failed.`, {
|
|
3783
|
-
cause: signatureStatusNotification.value.err
|
|
3784
|
-
});
|
|
3785
|
-
} else {
|
|
3786
|
-
return;
|
|
3787
|
-
}
|
|
3788
|
-
}
|
|
3789
|
-
})();
|
|
3790
|
-
const signatureStatusLookupPromise = (async () => {
|
|
3791
|
-
const { value: signatureStatusResults } = await rpc.getSignatureStatuses([signature]).send({ abortSignal: abortController.signal });
|
|
3792
|
-
const signatureStatus = signatureStatusResults[0];
|
|
3793
|
-
if (signatureStatus && signatureStatus.confirmationStatus && commitmentComparator(signatureStatus.confirmationStatus, commitment) >= 0) {
|
|
3794
|
-
return;
|
|
3795
|
-
} else {
|
|
3796
|
-
await new Promise(() => {
|
|
3797
|
-
});
|
|
3798
|
-
}
|
|
3799
|
-
})();
|
|
3800
|
-
try {
|
|
3801
|
-
return await Promise.race([signatureDidCommitPromise, signatureStatusLookupPromise]);
|
|
3802
|
-
} finally {
|
|
3803
|
-
abortController.abort();
|
|
3804
|
-
}
|
|
3805
|
-
};
|
|
3806
|
-
}
|
|
3807
|
-
|
|
3808
4188
|
// src/transaction-confirmation.ts
|
|
3809
|
-
async function raceStrategies(config, getSpecificStrategiesForRace) {
|
|
3810
|
-
const { abortSignal: callerAbortSignal, commitment, getSignatureConfirmationPromise, transaction } = config;
|
|
3811
|
-
callerAbortSignal.throwIfAborted();
|
|
3812
|
-
const signature = getSignatureFromTransaction(transaction);
|
|
3813
|
-
const abortController = new AbortController();
|
|
3814
|
-
function handleAbort() {
|
|
3815
|
-
abortController.abort();
|
|
3816
|
-
}
|
|
3817
|
-
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
3818
|
-
try {
|
|
3819
|
-
const specificStrategies = getSpecificStrategiesForRace({
|
|
3820
|
-
...config,
|
|
3821
|
-
abortSignal: abortController.signal
|
|
3822
|
-
});
|
|
3823
|
-
return await Promise.race([
|
|
3824
|
-
getSignatureConfirmationPromise({
|
|
3825
|
-
abortSignal: abortController.signal,
|
|
3826
|
-
commitment,
|
|
3827
|
-
signature
|
|
3828
|
-
}),
|
|
3829
|
-
...specificStrategies
|
|
3830
|
-
]);
|
|
3831
|
-
} finally {
|
|
3832
|
-
abortController.abort();
|
|
3833
|
-
}
|
|
3834
|
-
}
|
|
3835
4189
|
function createDefaultDurableNonceTransactionConfirmer({
|
|
3836
4190
|
rpc,
|
|
3837
4191
|
rpcSubscriptions
|
|
3838
4192
|
}) {
|
|
3839
4193
|
const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions);
|
|
3840
|
-
const
|
|
3841
|
-
|
|
4194
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
4195
|
+
rpc,
|
|
4196
|
+
rpcSubscriptions
|
|
4197
|
+
);
|
|
4198
|
+
return async function confirmDurableNonceTransaction(config) {
|
|
3842
4199
|
await waitForDurableNonceTransactionConfirmation({
|
|
3843
4200
|
...config,
|
|
3844
4201
|
getNonceInvalidationPromise,
|
|
3845
|
-
|
|
4202
|
+
getRecentSignatureConfirmationPromise
|
|
3846
4203
|
});
|
|
3847
4204
|
};
|
|
3848
4205
|
}
|
|
3849
|
-
function
|
|
4206
|
+
function createDefaultRecentTransactionConfirmer({
|
|
4207
|
+
rpc,
|
|
4208
|
+
rpcSubscriptions
|
|
4209
|
+
}) {
|
|
3850
4210
|
const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory(rpcSubscriptions);
|
|
3851
|
-
const
|
|
3852
|
-
|
|
3853
|
-
|
|
4211
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
4212
|
+
rpc,
|
|
4213
|
+
rpcSubscriptions
|
|
4214
|
+
);
|
|
4215
|
+
return async function confirmRecentTransaction(config) {
|
|
4216
|
+
await waitForRecentTransactionConfirmation({
|
|
3854
4217
|
...config,
|
|
3855
4218
|
getBlockHeightExceedencePromise,
|
|
3856
|
-
|
|
4219
|
+
getRecentSignatureConfirmationPromise
|
|
3857
4220
|
});
|
|
3858
4221
|
};
|
|
3859
4222
|
}
|
|
3860
4223
|
async function waitForDurableNonceTransactionConfirmation(config) {
|
|
3861
4224
|
await raceStrategies(
|
|
4225
|
+
getSignatureFromTransaction(config.transaction),
|
|
3862
4226
|
config,
|
|
3863
4227
|
function getSpecificStrategiesForRace({ abortSignal, commitment, getNonceInvalidationPromise, transaction }) {
|
|
3864
4228
|
return [
|
|
@@ -3872,8 +4236,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
3872
4236
|
}
|
|
3873
4237
|
);
|
|
3874
4238
|
}
|
|
3875
|
-
async function
|
|
4239
|
+
async function waitForRecentTransactionConfirmation(config) {
|
|
3876
4240
|
await raceStrategies(
|
|
4241
|
+
getSignatureFromTransaction(config.transaction),
|
|
3877
4242
|
config,
|
|
3878
4243
|
function getSpecificStrategiesForRace({ abortSignal, getBlockHeightExceedencePromise, transaction }) {
|
|
3879
4244
|
return [
|
|
@@ -3886,6 +4251,117 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
3886
4251
|
);
|
|
3887
4252
|
}
|
|
3888
4253
|
|
|
4254
|
+
// src/send-transaction.ts
|
|
4255
|
+
function getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, config) {
|
|
4256
|
+
if (
|
|
4257
|
+
// The developer has supplied no value for `preflightCommitment`.
|
|
4258
|
+
!config?.preflightCommitment && // The value of `commitment` is lower than the server default of `preflightCommitment`.
|
|
4259
|
+
commitmentComparator(
|
|
4260
|
+
commitment,
|
|
4261
|
+
"finalized"
|
|
4262
|
+
/* default value of `preflightCommitment` */
|
|
4263
|
+
) < 0
|
|
4264
|
+
) {
|
|
4265
|
+
return {
|
|
4266
|
+
...config,
|
|
4267
|
+
// In the common case, it is unlikely that you want to simulate a transaction at
|
|
4268
|
+
// `finalized` commitment when your standard of commitment for confirming the
|
|
4269
|
+
// transaction is lower. Cap the simulation commitment level to the level of the
|
|
4270
|
+
// confirmation commitment.
|
|
4271
|
+
preflightCommitment: commitment
|
|
4272
|
+
};
|
|
4273
|
+
}
|
|
4274
|
+
return config;
|
|
4275
|
+
}
|
|
4276
|
+
async function sendTransaction_INTERNAL({
|
|
4277
|
+
abortSignal,
|
|
4278
|
+
commitment,
|
|
4279
|
+
rpc,
|
|
4280
|
+
transaction,
|
|
4281
|
+
sendTransactionConfig
|
|
4282
|
+
}) {
|
|
4283
|
+
const base64EncodedWireTransaction = getBase64EncodedWireTransaction(transaction);
|
|
4284
|
+
return await rpc.sendTransaction(base64EncodedWireTransaction, {
|
|
4285
|
+
...getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, sendTransactionConfig),
|
|
4286
|
+
encoding: "base64"
|
|
4287
|
+
}).send({ abortSignal });
|
|
4288
|
+
}
|
|
4289
|
+
function createDefaultDurableNonceTransactionSender({
|
|
4290
|
+
rpc,
|
|
4291
|
+
rpcSubscriptions
|
|
4292
|
+
}) {
|
|
4293
|
+
const confirmDurableNonceTransaction = createDefaultDurableNonceTransactionConfirmer({
|
|
4294
|
+
rpc,
|
|
4295
|
+
rpcSubscriptions
|
|
4296
|
+
});
|
|
4297
|
+
return async function sendDurableNonceTransaction(transaction, config) {
|
|
4298
|
+
await sendAndConfirmDurableNonceTransaction({
|
|
4299
|
+
...config,
|
|
4300
|
+
confirmDurableNonceTransaction,
|
|
4301
|
+
rpc,
|
|
4302
|
+
transaction
|
|
4303
|
+
});
|
|
4304
|
+
};
|
|
4305
|
+
}
|
|
4306
|
+
function createDefaultTransactionSender({ rpc, rpcSubscriptions }) {
|
|
4307
|
+
const confirmRecentTransaction = createDefaultRecentTransactionConfirmer({
|
|
4308
|
+
rpc,
|
|
4309
|
+
rpcSubscriptions
|
|
4310
|
+
});
|
|
4311
|
+
return async function sendTransaction(transaction, config) {
|
|
4312
|
+
await sendAndConfirmTransaction({
|
|
4313
|
+
...config,
|
|
4314
|
+
confirmRecentTransaction,
|
|
4315
|
+
rpc,
|
|
4316
|
+
transaction
|
|
4317
|
+
});
|
|
4318
|
+
};
|
|
4319
|
+
}
|
|
4320
|
+
async function sendAndConfirmDurableNonceTransaction({
|
|
4321
|
+
abortSignal,
|
|
4322
|
+
commitment,
|
|
4323
|
+
confirmDurableNonceTransaction,
|
|
4324
|
+
rpc,
|
|
4325
|
+
transaction,
|
|
4326
|
+
...sendTransactionConfig
|
|
4327
|
+
}) {
|
|
4328
|
+
const transactionSignature2 = await sendTransaction_INTERNAL({
|
|
4329
|
+
abortSignal,
|
|
4330
|
+
commitment,
|
|
4331
|
+
rpc,
|
|
4332
|
+
sendTransactionConfig,
|
|
4333
|
+
transaction
|
|
4334
|
+
});
|
|
4335
|
+
await confirmDurableNonceTransaction({
|
|
4336
|
+
abortSignal,
|
|
4337
|
+
commitment,
|
|
4338
|
+
transaction
|
|
4339
|
+
});
|
|
4340
|
+
return transactionSignature2;
|
|
4341
|
+
}
|
|
4342
|
+
async function sendAndConfirmTransaction({
|
|
4343
|
+
abortSignal,
|
|
4344
|
+
commitment,
|
|
4345
|
+
confirmRecentTransaction,
|
|
4346
|
+
rpc,
|
|
4347
|
+
transaction,
|
|
4348
|
+
...sendTransactionConfig
|
|
4349
|
+
}) {
|
|
4350
|
+
const transactionSignature2 = await sendTransaction_INTERNAL({
|
|
4351
|
+
abortSignal,
|
|
4352
|
+
commitment,
|
|
4353
|
+
rpc,
|
|
4354
|
+
sendTransactionConfig,
|
|
4355
|
+
transaction
|
|
4356
|
+
});
|
|
4357
|
+
await confirmRecentTransaction({
|
|
4358
|
+
abortSignal,
|
|
4359
|
+
commitment,
|
|
4360
|
+
transaction
|
|
4361
|
+
});
|
|
4362
|
+
return transactionSignature2;
|
|
4363
|
+
}
|
|
4364
|
+
|
|
3889
4365
|
exports.AccountRole = AccountRole;
|
|
3890
4366
|
exports.address = address;
|
|
3891
4367
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
@@ -3896,12 +4372,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
3896
4372
|
exports.assertIsTransactionSignature = assertIsTransactionSignature;
|
|
3897
4373
|
exports.createAddressWithSeed = createAddressWithSeed;
|
|
3898
4374
|
exports.createBlockHeightExceedencePromiseFactory = createBlockHeightExceedencePromiseFactory;
|
|
4375
|
+
exports.createDefaultAirdropRequester = createDefaultAirdropRequester;
|
|
3899
4376
|
exports.createDefaultDurableNonceTransactionConfirmer = createDefaultDurableNonceTransactionConfirmer;
|
|
4377
|
+
exports.createDefaultDurableNonceTransactionSender = createDefaultDurableNonceTransactionSender;
|
|
4378
|
+
exports.createDefaultRecentTransactionConfirmer = createDefaultRecentTransactionConfirmer;
|
|
3900
4379
|
exports.createDefaultRpcSubscriptionsTransport = createDefaultRpcSubscriptionsTransport;
|
|
3901
4380
|
exports.createDefaultRpcTransport = createDefaultRpcTransport;
|
|
3902
|
-
exports.
|
|
4381
|
+
exports.createDefaultTransactionSender = createDefaultTransactionSender;
|
|
3903
4382
|
exports.createNonceInvalidationPromiseFactory = createNonceInvalidationPromiseFactory;
|
|
3904
|
-
exports.
|
|
4383
|
+
exports.createRecentSignatureConfirmationPromiseFactory = createRecentSignatureConfirmationPromiseFactory;
|
|
3905
4384
|
exports.createSolanaRpc = createSolanaRpc;
|
|
3906
4385
|
exports.createSolanaRpcSubscriptions = createSolanaRpcSubscriptions;
|
|
3907
4386
|
exports.createSolanaRpcSubscriptions_UNSTABLE = createSolanaRpcSubscriptions_UNSTABLE;
|
|
@@ -3919,12 +4398,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
3919
4398
|
exports.getSignatureFromTransaction = getSignatureFromTransaction;
|
|
3920
4399
|
exports.getTransactionEncoder = getTransactionEncoder;
|
|
3921
4400
|
exports.isAddress = isAddress;
|
|
4401
|
+
exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
|
|
3922
4402
|
exports.isProgramDerivedAddress = isProgramDerivedAddress;
|
|
3923
4403
|
exports.isSignerRole = isSignerRole;
|
|
3924
4404
|
exports.isTransactionSignature = isTransactionSignature;
|
|
3925
4405
|
exports.isWritableRole = isWritableRole;
|
|
3926
4406
|
exports.mergeRoles = mergeRoles;
|
|
3927
4407
|
exports.prependTransactionInstruction = prependTransactionInstruction;
|
|
4408
|
+
exports.requestAndConfirmAirdrop = requestAndConfirmAirdrop;
|
|
4409
|
+
exports.sendAndConfirmDurableNonceTransaction = sendAndConfirmDurableNonceTransaction;
|
|
4410
|
+
exports.sendAndConfirmTransaction = sendAndConfirmTransaction;
|
|
3928
4411
|
exports.setTransactionFeePayer = setTransactionFeePayer;
|
|
3929
4412
|
exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
|
|
3930
4413
|
exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
|
|
@@ -3935,7 +4418,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
3935
4418
|
exports.upgradeRoleToWritable = upgradeRoleToWritable;
|
|
3936
4419
|
exports.verifySignature = verifySignature;
|
|
3937
4420
|
exports.waitForDurableNonceTransactionConfirmation = waitForDurableNonceTransactionConfirmation;
|
|
3938
|
-
exports.
|
|
4421
|
+
exports.waitForRecentTransactionConfirmation = waitForRecentTransactionConfirmation;
|
|
3939
4422
|
|
|
3940
4423
|
return exports;
|
|
3941
4424
|
|