@solana/web3.js 1.78.3 → 2.0.0-experimental.0108bc7

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.
Files changed (106) hide show
  1. package/README.md +56 -112
  2. package/dist/index.browser.cjs +172 -0
  3. package/dist/index.browser.cjs.map +1 -0
  4. package/dist/index.browser.js +139 -0
  5. package/dist/index.browser.js.map +1 -0
  6. package/dist/index.development.js +2287 -0
  7. package/dist/index.development.js.map +1 -0
  8. package/dist/index.native.js +141 -0
  9. package/dist/index.native.js.map +1 -0
  10. package/dist/index.node.cjs +172 -0
  11. package/dist/index.node.cjs.map +1 -0
  12. package/dist/index.node.js +141 -0
  13. package/dist/index.node.js.map +1 -0
  14. package/dist/index.production.min.js +42 -0
  15. package/dist/types/index.d.ts +7 -0
  16. package/dist/types/index.d.ts.map +1 -0
  17. package/dist/types/rpc-default-config.d.ts +3 -0
  18. package/dist/types/rpc-default-config.d.ts.map +1 -0
  19. package/dist/types/rpc-integer-overflow-error.d.ts +8 -0
  20. package/dist/types/rpc-integer-overflow-error.d.ts.map +1 -0
  21. package/dist/types/rpc-request-coalescer.d.ts +5 -0
  22. package/dist/types/rpc-request-coalescer.d.ts.map +1 -0
  23. package/dist/types/rpc-request-deduplication.d.ts +2 -0
  24. package/dist/types/rpc-request-deduplication.d.ts.map +1 -0
  25. package/dist/types/rpc-transport.d.ts +4 -0
  26. package/dist/types/rpc-transport.d.ts.map +1 -0
  27. package/dist/types/rpc.d.ts +5 -0
  28. package/dist/types/rpc.d.ts.map +1 -0
  29. package/package.json +83 -110
  30. package/lib/index.browser.cjs.js +0 -13599
  31. package/lib/index.browser.cjs.js.map +0 -1
  32. package/lib/index.browser.esm.js +0 -13482
  33. package/lib/index.browser.esm.js.map +0 -1
  34. package/lib/index.cjs.js +0 -15910
  35. package/lib/index.cjs.js.map +0 -1
  36. package/lib/index.d.ts +0 -3947
  37. package/lib/index.esm.js +0 -15787
  38. package/lib/index.esm.js.map +0 -1
  39. package/lib/index.iife.js +0 -30621
  40. package/lib/index.iife.js.map +0 -1
  41. package/lib/index.iife.min.js +0 -20
  42. package/lib/index.iife.min.js.map +0 -1
  43. package/lib/index.native.js +0 -13599
  44. package/lib/index.native.js.map +0 -1
  45. package/src/__forks__/browser/fetch-impl.ts +0 -4
  46. package/src/__forks__/browser/rpc-websocket-factory.ts +0 -1
  47. package/src/__forks__/react-native/fetch-impl.ts +0 -4
  48. package/src/__forks__/react-native/rpc-websocket-factory.ts +0 -1
  49. package/src/account-data.ts +0 -39
  50. package/src/account.ts +0 -55
  51. package/src/blockhash.ts +0 -4
  52. package/src/bpf-loader-deprecated.ts +0 -5
  53. package/src/bpf-loader.ts +0 -45
  54. package/src/connection.ts +0 -6796
  55. package/src/epoch-schedule.ts +0 -102
  56. package/src/errors.ts +0 -50
  57. package/src/fee-calculator.ts +0 -18
  58. package/src/fetch-impl.ts +0 -16
  59. package/src/index.ts +0 -24
  60. package/src/instruction.ts +0 -58
  61. package/src/keypair.ts +0 -102
  62. package/src/layout.ts +0 -188
  63. package/src/loader.ts +0 -267
  64. package/src/message/account-keys.ts +0 -79
  65. package/src/message/compiled-keys.ts +0 -165
  66. package/src/message/index.ts +0 -47
  67. package/src/message/legacy.ts +0 -326
  68. package/src/message/v0.ts +0 -496
  69. package/src/message/versioned.ts +0 -36
  70. package/src/nonce-account.ts +0 -82
  71. package/src/programs/address-lookup-table/index.ts +0 -435
  72. package/src/programs/address-lookup-table/state.ts +0 -84
  73. package/src/programs/compute-budget.ts +0 -281
  74. package/src/programs/ed25519.ts +0 -157
  75. package/src/programs/index.ts +0 -7
  76. package/src/programs/secp256k1.ts +0 -228
  77. package/src/programs/stake.ts +0 -935
  78. package/src/programs/system.ts +0 -1048
  79. package/src/programs/vote.ts +0 -543
  80. package/src/publickey.ts +0 -259
  81. package/src/rpc-websocket-factory.ts +0 -4
  82. package/src/rpc-websocket.ts +0 -79
  83. package/src/sysvar.ts +0 -37
  84. package/src/timing.ts +0 -23
  85. package/src/transaction/constants.ts +0 -12
  86. package/src/transaction/expiry-custom-errors.ts +0 -48
  87. package/src/transaction/index.ts +0 -5
  88. package/src/transaction/legacy.ts +0 -948
  89. package/src/transaction/message.ts +0 -140
  90. package/src/transaction/versioned.ts +0 -126
  91. package/src/utils/assert.ts +0 -8
  92. package/src/utils/bigint.ts +0 -43
  93. package/src/utils/borsh-schema.ts +0 -38
  94. package/src/utils/cluster.ts +0 -35
  95. package/src/utils/ed25519.ts +0 -43
  96. package/src/utils/index.ts +0 -5
  97. package/src/utils/makeWebsocketUrl.ts +0 -26
  98. package/src/utils/promise-timeout.ts +0 -14
  99. package/src/utils/secp256k1.ts +0 -11
  100. package/src/utils/send-and-confirm-raw-transaction.ts +0 -102
  101. package/src/utils/send-and-confirm-transaction.ts +0 -98
  102. package/src/utils/shortvec-encoding.ts +0 -28
  103. package/src/utils/sleep.ts +0 -4
  104. package/src/utils/to-buffer.ts +0 -11
  105. package/src/validator-info.ts +0 -104
  106. package/src/vote-account.ts +0 -236
@@ -1,140 +0,0 @@
1
- import {AccountKeysFromLookups} from '../message/account-keys';
2
- import assert from '../utils/assert';
3
- import {toBuffer} from '../utils/to-buffer';
4
- import {Blockhash} from '../blockhash';
5
- import {Message, MessageV0, VersionedMessage} from '../message';
6
- import {PublicKey} from '../publickey';
7
- import {AddressLookupTableAccount} from '../programs';
8
- import {AccountMeta, TransactionInstruction} from './legacy';
9
-
10
- export type TransactionMessageArgs = {
11
- payerKey: PublicKey;
12
- instructions: Array<TransactionInstruction>;
13
- recentBlockhash: Blockhash;
14
- };
15
-
16
- export type DecompileArgs =
17
- | {
18
- accountKeysFromLookups: AccountKeysFromLookups;
19
- }
20
- | {
21
- addressLookupTableAccounts: AddressLookupTableAccount[];
22
- };
23
-
24
- export class TransactionMessage {
25
- payerKey: PublicKey;
26
- instructions: Array<TransactionInstruction>;
27
- recentBlockhash: Blockhash;
28
-
29
- constructor(args: TransactionMessageArgs) {
30
- this.payerKey = args.payerKey;
31
- this.instructions = args.instructions;
32
- this.recentBlockhash = args.recentBlockhash;
33
- }
34
-
35
- static decompile(
36
- message: VersionedMessage,
37
- args?: DecompileArgs,
38
- ): TransactionMessage {
39
- const {header, compiledInstructions, recentBlockhash} = message;
40
-
41
- const {
42
- numRequiredSignatures,
43
- numReadonlySignedAccounts,
44
- numReadonlyUnsignedAccounts,
45
- } = header;
46
-
47
- const numWritableSignedAccounts =
48
- numRequiredSignatures - numReadonlySignedAccounts;
49
- assert(numWritableSignedAccounts > 0, 'Message header is invalid');
50
-
51
- const numWritableUnsignedAccounts =
52
- message.staticAccountKeys.length -
53
- numRequiredSignatures -
54
- numReadonlyUnsignedAccounts;
55
- assert(numWritableUnsignedAccounts >= 0, 'Message header is invalid');
56
-
57
- const accountKeys = message.getAccountKeys(args);
58
- const payerKey = accountKeys.get(0);
59
- if (payerKey === undefined) {
60
- throw new Error(
61
- 'Failed to decompile message because no account keys were found',
62
- );
63
- }
64
-
65
- const instructions: TransactionInstruction[] = [];
66
- for (const compiledIx of compiledInstructions) {
67
- const keys: AccountMeta[] = [];
68
-
69
- for (const keyIndex of compiledIx.accountKeyIndexes) {
70
- const pubkey = accountKeys.get(keyIndex);
71
- if (pubkey === undefined) {
72
- throw new Error(
73
- `Failed to find key for account key index ${keyIndex}`,
74
- );
75
- }
76
-
77
- const isSigner = keyIndex < numRequiredSignatures;
78
-
79
- let isWritable;
80
- if (isSigner) {
81
- isWritable = keyIndex < numWritableSignedAccounts;
82
- } else if (keyIndex < accountKeys.staticAccountKeys.length) {
83
- isWritable =
84
- keyIndex - numRequiredSignatures < numWritableUnsignedAccounts;
85
- } else {
86
- isWritable =
87
- keyIndex - accountKeys.staticAccountKeys.length <
88
- // accountKeysFromLookups cannot be undefined because we already found a pubkey for this index above
89
- accountKeys.accountKeysFromLookups!.writable.length;
90
- }
91
-
92
- keys.push({
93
- pubkey,
94
- isSigner: keyIndex < header.numRequiredSignatures,
95
- isWritable,
96
- });
97
- }
98
-
99
- const programId = accountKeys.get(compiledIx.programIdIndex);
100
- if (programId === undefined) {
101
- throw new Error(
102
- `Failed to find program id for program id index ${compiledIx.programIdIndex}`,
103
- );
104
- }
105
-
106
- instructions.push(
107
- new TransactionInstruction({
108
- programId,
109
- data: toBuffer(compiledIx.data),
110
- keys,
111
- }),
112
- );
113
- }
114
-
115
- return new TransactionMessage({
116
- payerKey,
117
- instructions,
118
- recentBlockhash,
119
- });
120
- }
121
-
122
- compileToLegacyMessage(): Message {
123
- return Message.compile({
124
- payerKey: this.payerKey,
125
- recentBlockhash: this.recentBlockhash,
126
- instructions: this.instructions,
127
- });
128
- }
129
-
130
- compileToV0Message(
131
- addressLookupTableAccounts?: AddressLookupTableAccount[],
132
- ): MessageV0 {
133
- return MessageV0.compile({
134
- payerKey: this.payerKey,
135
- recentBlockhash: this.recentBlockhash,
136
- instructions: this.instructions,
137
- addressLookupTableAccounts,
138
- });
139
- }
140
- }
@@ -1,126 +0,0 @@
1
- import * as BufferLayout from '@solana/buffer-layout';
2
-
3
- import {Signer} from '../keypair';
4
- import assert from '../utils/assert';
5
- import {VersionedMessage} from '../message/versioned';
6
- import {SIGNATURE_LENGTH_IN_BYTES} from './constants';
7
- import * as shortvec from '../utils/shortvec-encoding';
8
- import * as Layout from '../layout';
9
- import {sign} from '../utils/ed25519';
10
- import {PublicKey} from '../publickey';
11
-
12
- export type TransactionVersion = 'legacy' | 0;
13
-
14
- /**
15
- * Versioned transaction class
16
- */
17
- export class VersionedTransaction {
18
- signatures: Array<Uint8Array>;
19
- message: VersionedMessage;
20
-
21
- get version(): TransactionVersion {
22
- return this.message.version;
23
- }
24
-
25
- constructor(message: VersionedMessage, signatures?: Array<Uint8Array>) {
26
- if (signatures !== undefined) {
27
- assert(
28
- signatures.length === message.header.numRequiredSignatures,
29
- 'Expected signatures length to be equal to the number of required signatures',
30
- );
31
- this.signatures = signatures;
32
- } else {
33
- const defaultSignatures = [];
34
- for (let i = 0; i < message.header.numRequiredSignatures; i++) {
35
- defaultSignatures.push(new Uint8Array(SIGNATURE_LENGTH_IN_BYTES));
36
- }
37
- this.signatures = defaultSignatures;
38
- }
39
- this.message = message;
40
- }
41
-
42
- serialize(): Uint8Array {
43
- const serializedMessage = this.message.serialize();
44
-
45
- const encodedSignaturesLength = Array<number>();
46
- shortvec.encodeLength(encodedSignaturesLength, this.signatures.length);
47
-
48
- const transactionLayout = BufferLayout.struct<{
49
- encodedSignaturesLength: Uint8Array;
50
- signatures: Array<Uint8Array>;
51
- serializedMessage: Uint8Array;
52
- }>([
53
- BufferLayout.blob(
54
- encodedSignaturesLength.length,
55
- 'encodedSignaturesLength',
56
- ),
57
- BufferLayout.seq(
58
- Layout.signature(),
59
- this.signatures.length,
60
- 'signatures',
61
- ),
62
- BufferLayout.blob(serializedMessage.length, 'serializedMessage'),
63
- ]);
64
-
65
- const serializedTransaction = new Uint8Array(2048);
66
- const serializedTransactionLength = transactionLayout.encode(
67
- {
68
- encodedSignaturesLength: new Uint8Array(encodedSignaturesLength),
69
- signatures: this.signatures,
70
- serializedMessage,
71
- },
72
- serializedTransaction,
73
- );
74
-
75
- return serializedTransaction.slice(0, serializedTransactionLength);
76
- }
77
-
78
- static deserialize(serializedTransaction: Uint8Array): VersionedTransaction {
79
- let byteArray = [...serializedTransaction];
80
-
81
- const signatures = [];
82
- const signaturesLength = shortvec.decodeLength(byteArray);
83
- for (let i = 0; i < signaturesLength; i++) {
84
- signatures.push(
85
- new Uint8Array(byteArray.splice(0, SIGNATURE_LENGTH_IN_BYTES)),
86
- );
87
- }
88
-
89
- const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
90
- return new VersionedTransaction(message, signatures);
91
- }
92
-
93
- sign(signers: Array<Signer>) {
94
- const messageData = this.message.serialize();
95
- const signerPubkeys = this.message.staticAccountKeys.slice(
96
- 0,
97
- this.message.header.numRequiredSignatures,
98
- );
99
- for (const signer of signers) {
100
- const signerIndex = signerPubkeys.findIndex(pubkey =>
101
- pubkey.equals(signer.publicKey),
102
- );
103
- assert(
104
- signerIndex >= 0,
105
- `Cannot sign with non signer key ${signer.publicKey.toBase58()}`,
106
- );
107
- this.signatures[signerIndex] = sign(messageData, signer.secretKey);
108
- }
109
- }
110
-
111
- addSignature(publicKey: PublicKey, signature: Uint8Array) {
112
- assert(signature.byteLength === 64, 'Signature must be 64 bytes long');
113
- const signerPubkeys = this.message.staticAccountKeys.slice(
114
- 0,
115
- this.message.header.numRequiredSignatures,
116
- );
117
- const signerIndex = signerPubkeys.findIndex(pubkey =>
118
- pubkey.equals(publicKey),
119
- );
120
- assert(
121
- signerIndex >= 0,
122
- `Can not add signature; \`${publicKey.toBase58()}\` is not required to sign this transaction`,
123
- );
124
- this.signatures[signerIndex] = signature;
125
- }
126
- }
@@ -1,8 +0,0 @@
1
- export default function (
2
- condition: unknown,
3
- message?: string,
4
- ): asserts condition {
5
- if (!condition) {
6
- throw new Error(message || 'Assertion failed');
7
- }
8
- }
@@ -1,43 +0,0 @@
1
- import {Buffer} from 'buffer';
2
- import {blob, Layout} from '@solana/buffer-layout';
3
- import {toBigIntLE, toBufferLE} from 'bigint-buffer';
4
-
5
- interface EncodeDecode<T> {
6
- decode(buffer: Buffer, offset?: number): T;
7
- encode(src: T, buffer: Buffer, offset?: number): number;
8
- }
9
-
10
- const encodeDecode = <T>(layout: Layout<T>): EncodeDecode<T> => {
11
- const decode = layout.decode.bind(layout);
12
- const encode = layout.encode.bind(layout);
13
- return {decode, encode};
14
- };
15
-
16
- const bigInt =
17
- (length: number) =>
18
- (property?: string): Layout<bigint> => {
19
- const layout = blob(length, property);
20
- const {encode, decode} = encodeDecode(layout);
21
-
22
- const bigIntLayout = layout as Layout<unknown> as Layout<bigint>;
23
-
24
- bigIntLayout.decode = (buffer: Buffer, offset: number) => {
25
- const src = decode(buffer, offset);
26
- return toBigIntLE(Buffer.from(src));
27
- };
28
-
29
- bigIntLayout.encode = (bigInt: bigint, buffer: Buffer, offset: number) => {
30
- const src = toBufferLE(bigInt, length);
31
- return encode(src, buffer, offset);
32
- };
33
-
34
- return bigIntLayout;
35
- };
36
-
37
- export const u64 = bigInt(8);
38
-
39
- export const u128 = bigInt(16);
40
-
41
- export const u192 = bigInt(24);
42
-
43
- export const u256 = bigInt(32);
@@ -1,38 +0,0 @@
1
- import {Buffer} from 'buffer';
2
- import {serialize, deserialize, deserializeUnchecked} from 'borsh';
3
-
4
- // Class wrapping a plain object
5
- export class Struct {
6
- constructor(properties: any) {
7
- Object.assign(this, properties);
8
- }
9
-
10
- encode(): Buffer {
11
- return Buffer.from(serialize(SOLANA_SCHEMA, this));
12
- }
13
-
14
- static decode(data: Buffer): any {
15
- return deserialize(SOLANA_SCHEMA, this, data);
16
- }
17
-
18
- static decodeUnchecked(data: Buffer): any {
19
- return deserializeUnchecked(SOLANA_SCHEMA, this, data);
20
- }
21
- }
22
-
23
- // Class representing a Rust-compatible enum, since enums are only strings or
24
- // numbers in pure JS
25
- export class Enum extends Struct {
26
- enum: string = '';
27
- constructor(properties: any) {
28
- super(properties);
29
- if (Object.keys(properties).length !== 1) {
30
- throw new Error('Enum can only take single value');
31
- }
32
- Object.keys(properties).map(key => {
33
- this.enum = key;
34
- });
35
- }
36
- }
37
-
38
- export const SOLANA_SCHEMA: Map<Function, any> = new Map();
@@ -1,35 +0,0 @@
1
- const endpoint = {
2
- http: {
3
- devnet: 'http://api.devnet.solana.com',
4
- testnet: 'http://api.testnet.solana.com',
5
- 'mainnet-beta': 'http://api.mainnet-beta.solana.com/',
6
- },
7
- https: {
8
- devnet: 'https://api.devnet.solana.com',
9
- testnet: 'https://api.testnet.solana.com',
10
- 'mainnet-beta': 'https://api.mainnet-beta.solana.com/',
11
- },
12
- };
13
-
14
- export type Cluster = 'devnet' | 'testnet' | 'mainnet-beta';
15
-
16
- /**
17
- * Retrieves the RPC API URL for the specified cluster
18
- * @param {Cluster} [cluster="devnet"] - The cluster name of the RPC API URL to use. Possible options: 'devnet' | 'testnet' | 'mainnet-beta'
19
- * @param {boolean} [tls="http"] - Use TLS when connecting to cluster.
20
- *
21
- * @returns {string} URL string of the RPC endpoint
22
- */
23
- export function clusterApiUrl(cluster?: Cluster, tls?: boolean): string {
24
- const key = tls === false ? 'http' : 'https';
25
-
26
- if (!cluster) {
27
- return endpoint[key]['devnet'];
28
- }
29
-
30
- const url = endpoint[key][cluster];
31
- if (!url) {
32
- throw new Error(`Unknown ${key} cluster: ${cluster}`);
33
- }
34
- return url;
35
- }
@@ -1,43 +0,0 @@
1
- import {ed25519} from '@noble/curves/ed25519';
2
-
3
- /**
4
- * A 64 byte secret key, the first 32 bytes of which is the
5
- * private scalar and the last 32 bytes is the public key.
6
- * Read more: https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/
7
- */
8
- type Ed25519SecretKey = Uint8Array;
9
-
10
- /**
11
- * Ed25519 Keypair
12
- */
13
- export interface Ed25519Keypair {
14
- publicKey: Uint8Array;
15
- secretKey: Ed25519SecretKey;
16
- }
17
-
18
- export const generatePrivateKey = ed25519.utils.randomPrivateKey;
19
- export const generateKeypair = (): Ed25519Keypair => {
20
- const privateScalar = ed25519.utils.randomPrivateKey();
21
- const publicKey = getPublicKey(privateScalar);
22
- const secretKey = new Uint8Array(64);
23
- secretKey.set(privateScalar);
24
- secretKey.set(publicKey, 32);
25
- return {
26
- publicKey,
27
- secretKey,
28
- };
29
- };
30
- export const getPublicKey = ed25519.getPublicKey;
31
- export function isOnCurve(publicKey: Uint8Array): boolean {
32
- try {
33
- ed25519.ExtendedPoint.fromHex(publicKey);
34
- return true;
35
- } catch {
36
- return false;
37
- }
38
- }
39
- export const sign = (
40
- message: Parameters<typeof ed25519.sign>[0],
41
- secretKey: Ed25519SecretKey,
42
- ) => ed25519.sign(message, secretKey.slice(0, 32));
43
- export const verify = ed25519.verify;
@@ -1,5 +0,0 @@
1
- export * from './borsh-schema';
2
- export * from './cluster';
3
- export type {Ed25519Keypair} from './ed25519';
4
- export * from './send-and-confirm-raw-transaction';
5
- export * from './send-and-confirm-transaction';
@@ -1,26 +0,0 @@
1
- const URL_RE = /^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;
2
-
3
- export function makeWebsocketUrl(endpoint: string) {
4
- const matches = endpoint.match(URL_RE);
5
- if (matches == null) {
6
- throw TypeError(`Failed to validate endpoint URL \`${endpoint}\``);
7
- }
8
- const [
9
- _, // eslint-disable-line @typescript-eslint/no-unused-vars
10
- hostish,
11
- portWithColon,
12
- rest,
13
- ] = matches;
14
- const protocol = endpoint.startsWith('https:') ? 'wss:' : 'ws:';
15
- const startPort =
16
- portWithColon == null ? null : parseInt(portWithColon.slice(1), 10);
17
- const websocketPort =
18
- // Only shift the port by +1 as a convention for ws(s) only if given endpoint
19
- // is explictly specifying the endpoint port (HTTP-based RPC), assuming
20
- // we're directly trying to connect to solana-validator's ws listening port.
21
- // When the endpoint omits the port, we're connecting to the protocol
22
- // default ports: http(80) or https(443) and it's assumed we're behind a reverse
23
- // proxy which manages WebSocket upgrade and backend port redirection.
24
- startPort == null ? '' : `:${startPort + 1}`;
25
- return `${protocol}//${hostish}${websocketPort}${rest}`;
26
- }
@@ -1,14 +0,0 @@
1
- export function promiseTimeout<T>(
2
- promise: Promise<T>,
3
- timeoutMs: number,
4
- ): Promise<T | null> {
5
- let timeoutId: ReturnType<typeof setTimeout>;
6
- const timeoutPromise: Promise<null> = new Promise(resolve => {
7
- timeoutId = setTimeout(() => resolve(null), timeoutMs);
8
- });
9
-
10
- return Promise.race([promise, timeoutPromise]).then((result: T | null) => {
11
- clearTimeout(timeoutId);
12
- return result;
13
- });
14
- }
@@ -1,11 +0,0 @@
1
- import {secp256k1} from '@noble/curves/secp256k1';
2
-
3
- export const ecdsaSign = (
4
- msgHash: Parameters<typeof secp256k1.sign>[0],
5
- privKey: Parameters<typeof secp256k1.sign>[1],
6
- ) => {
7
- const signature = secp256k1.sign(msgHash, privKey);
8
- return [signature.toCompactRawBytes(), signature.recovery!] as const;
9
- };
10
- export const isValidPrivateKey = secp256k1.utils.isValidPrivateKey;
11
- export const publicKeyCreate = secp256k1.getPublicKey;
@@ -1,102 +0,0 @@
1
- import type {Buffer} from 'buffer';
2
-
3
- import {
4
- BlockheightBasedTransactionConfirmationStrategy,
5
- Connection,
6
- DurableNonceTransactionConfirmationStrategy,
7
- TransactionConfirmationStrategy,
8
- } from '../connection';
9
- import type {TransactionSignature} from '../transaction';
10
- import type {ConfirmOptions} from '../connection';
11
-
12
- /**
13
- * Send and confirm a raw transaction
14
- *
15
- * If `commitment` option is not specified, defaults to 'max' commitment.
16
- *
17
- * @param {Connection} connection
18
- * @param {Buffer} rawTransaction
19
- * @param {TransactionConfirmationStrategy} confirmationStrategy
20
- * @param {ConfirmOptions} [options]
21
- * @returns {Promise<TransactionSignature>}
22
- */
23
- export async function sendAndConfirmRawTransaction(
24
- connection: Connection,
25
- rawTransaction: Buffer,
26
- confirmationStrategy: TransactionConfirmationStrategy,
27
- options?: ConfirmOptions,
28
- ): Promise<TransactionSignature>;
29
-
30
- /**
31
- * @deprecated Calling `sendAndConfirmRawTransaction()` without a `confirmationStrategy`
32
- * is no longer supported and will be removed in a future version.
33
- */
34
- // eslint-disable-next-line no-redeclare
35
- export async function sendAndConfirmRawTransaction(
36
- connection: Connection,
37
- rawTransaction: Buffer,
38
- options?: ConfirmOptions,
39
- ): Promise<TransactionSignature>;
40
-
41
- // eslint-disable-next-line no-redeclare
42
- export async function sendAndConfirmRawTransaction(
43
- connection: Connection,
44
- rawTransaction: Buffer,
45
- confirmationStrategyOrConfirmOptions:
46
- | TransactionConfirmationStrategy
47
- | ConfirmOptions
48
- | undefined,
49
- maybeConfirmOptions?: ConfirmOptions,
50
- ): Promise<TransactionSignature> {
51
- let confirmationStrategy: TransactionConfirmationStrategy | undefined;
52
- let options: ConfirmOptions | undefined;
53
- if (
54
- confirmationStrategyOrConfirmOptions &&
55
- Object.prototype.hasOwnProperty.call(
56
- confirmationStrategyOrConfirmOptions,
57
- 'lastValidBlockHeight',
58
- )
59
- ) {
60
- confirmationStrategy =
61
- confirmationStrategyOrConfirmOptions as BlockheightBasedTransactionConfirmationStrategy;
62
- options = maybeConfirmOptions;
63
- } else if (
64
- confirmationStrategyOrConfirmOptions &&
65
- Object.prototype.hasOwnProperty.call(
66
- confirmationStrategyOrConfirmOptions,
67
- 'nonceValue',
68
- )
69
- ) {
70
- confirmationStrategy =
71
- confirmationStrategyOrConfirmOptions as DurableNonceTransactionConfirmationStrategy;
72
- options = maybeConfirmOptions;
73
- } else {
74
- options = confirmationStrategyOrConfirmOptions as
75
- | ConfirmOptions
76
- | undefined;
77
- }
78
- const sendOptions = options && {
79
- skipPreflight: options.skipPreflight,
80
- preflightCommitment: options.preflightCommitment || options.commitment,
81
- minContextSlot: options.minContextSlot,
82
- };
83
-
84
- const signature = await connection.sendRawTransaction(
85
- rawTransaction,
86
- sendOptions,
87
- );
88
-
89
- const commitment = options && options.commitment;
90
- const confirmationPromise = confirmationStrategy
91
- ? connection.confirmTransaction(confirmationStrategy, commitment)
92
- : connection.confirmTransaction(signature, commitment);
93
- const status = (await confirmationPromise).value;
94
-
95
- if (status.err) {
96
- throw new Error(
97
- `Raw transaction ${signature} failed (${JSON.stringify(status)})`,
98
- );
99
- }
100
-
101
- return signature;
102
- }