@solana/web3.js 2.0.0-development → 2.0.0-experimental.00fa195
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/LICENSE +1 -1
- package/README.md +1153 -43
- package/dist/index.browser.cjs +286 -126
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +219 -119
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +6257 -708
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +217 -119
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +286 -126
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +217 -119
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +286 -16
- package/dist/types/airdrop-internal.d.ts +16 -0
- package/dist/types/airdrop-internal.d.ts.map +1 -0
- package/dist/types/airdrop.d.ts +12 -0
- package/dist/types/airdrop.d.ts.map +1 -0
- package/dist/types/decode-transaction.d.ts +9 -0
- package/dist/types/decode-transaction.d.ts.map +1 -0
- package/dist/types/index.d.ts +14 -2
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/send-transaction-internal.d.ts +27 -0
- package/dist/types/send-transaction-internal.d.ts.map +1 -0
- package/dist/types/send-transaction.d.ts +23 -0
- package/dist/types/send-transaction.d.ts.map +1 -0
- package/package.json +27 -41
- package/dist/types/rpc-default-config.d.ts +0 -3
- package/dist/types/rpc-integer-overflow-error.d.ts +0 -8
- package/dist/types/rpc-request-coalescer.d.ts +0 -5
- package/dist/types/rpc-request-deduplication.d.ts +0 -2
- package/dist/types/rpc-transport.d.ts +0 -4
- package/dist/types/rpc.d.ts +0 -5
package/dist/index.native.js
CHANGED
|
@@ -1,139 +1,237 @@
|
|
|
1
|
+
import { fetchJsonParsedAccounts, assertAccountsDecoded, assertAccountsExist } from '@solana/accounts';
|
|
2
|
+
export * from '@solana/accounts';
|
|
3
|
+
export * from '@solana/addresses';
|
|
4
|
+
export * from '@solana/codecs';
|
|
5
|
+
export * from '@solana/functional';
|
|
1
6
|
export * from '@solana/instructions';
|
|
2
7
|
export * from '@solana/keys';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
8
|
+
export * from '@solana/programs';
|
|
9
|
+
export * from '@solana/rpc';
|
|
10
|
+
export * from '@solana/rpc-parsed-types';
|
|
11
|
+
export * from '@solana/rpc-subscriptions';
|
|
12
|
+
import { commitmentComparator } from '@solana/rpc-types';
|
|
13
|
+
export * from '@solana/rpc-types';
|
|
14
|
+
export * from '@solana/signers';
|
|
15
|
+
import { getCompiledTransactionDecoder, decompileTransaction, getBase64EncodedWireTransaction } from '@solana/transactions';
|
|
16
|
+
export * from '@solana/transactions';
|
|
17
|
+
import { createRecentSignatureConfirmationPromiseFactory, createNonceInvalidationPromiseFactory, createBlockHeightExceedencePromiseFactory, waitForRecentTransactionConfirmationUntilTimeout, getTimeoutPromise, waitForDurableNonceTransactionConfirmation, waitForRecentTransactionConfirmation } from '@solana/transaction-confirmation';
|
|
6
18
|
|
|
7
19
|
// src/index.ts
|
|
8
20
|
|
|
9
|
-
// src/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
ordinal = argPosition + "th";
|
|
24
|
-
}
|
|
25
|
-
const path = keyPath.length > 1 ? keyPath.slice(1).map((pathPart) => typeof pathPart === "number" ? `[${pathPart}]` : pathPart).join(".") : null;
|
|
26
|
-
super(
|
|
27
|
-
`The ${ordinal} argument to the \`${methodName}\` RPC method${path ? ` at path \`${path}\`` : ""} was \`${value}\`. This number is unsafe for use with the Solana JSON-RPC because it exceeds \`Number.MAX_SAFE_INTEGER\`.`
|
|
28
|
-
);
|
|
29
|
-
this.keyPath = keyPath;
|
|
30
|
-
this.methodName = methodName;
|
|
31
|
-
this.value = value;
|
|
32
|
-
}
|
|
33
|
-
get name() {
|
|
34
|
-
return "SolanaJsonRpcIntegerOverflowError";
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// src/rpc-default-config.ts
|
|
39
|
-
var DEFAULT_RPC_CONFIG = {
|
|
40
|
-
onIntegerOverflow(methodName, keyPath, value) {
|
|
41
|
-
throw new SolanaJsonRpcIntegerOverflowError(methodName, keyPath, value);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// src/rpc.ts
|
|
46
|
-
function createSolanaRpc(config) {
|
|
47
|
-
return createJsonRpc({
|
|
48
|
-
...config,
|
|
49
|
-
api: createSolanaRpcApi(DEFAULT_RPC_CONFIG)
|
|
21
|
+
// src/airdrop-internal.ts
|
|
22
|
+
async function requestAndConfirmAirdrop_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
23
|
+
abortSignal,
|
|
24
|
+
commitment,
|
|
25
|
+
confirmSignatureOnlyTransaction,
|
|
26
|
+
lamports,
|
|
27
|
+
recipientAddress,
|
|
28
|
+
rpc
|
|
29
|
+
}) {
|
|
30
|
+
const airdropTransactionSignature = await rpc.requestAirdrop(recipientAddress, lamports, { commitment }).send({ abortSignal });
|
|
31
|
+
await confirmSignatureOnlyTransaction({
|
|
32
|
+
abortSignal,
|
|
33
|
+
commitment,
|
|
34
|
+
signature: airdropTransactionSignature
|
|
50
35
|
});
|
|
36
|
+
return airdropTransactionSignature;
|
|
51
37
|
}
|
|
52
38
|
|
|
53
|
-
// src/
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
numConsumers: 0,
|
|
73
|
-
responsePromise: transport({
|
|
74
|
-
...config,
|
|
75
|
-
signal: abortController.signal
|
|
76
|
-
})
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
const coalescedRequest = coalescedRequestsByDeduplicationKey[deduplicationKey];
|
|
80
|
-
coalescedRequest.numConsumers++;
|
|
81
|
-
if (signal) {
|
|
82
|
-
const responsePromise = coalescedRequest.responsePromise;
|
|
83
|
-
return await new Promise((resolve, reject) => {
|
|
84
|
-
const handleAbort = (e) => {
|
|
85
|
-
signal.removeEventListener("abort", handleAbort);
|
|
86
|
-
coalescedRequest.numConsumers -= 1;
|
|
87
|
-
if (coalescedRequest.numConsumers === 0) {
|
|
88
|
-
const abortController = coalescedRequest.abortController;
|
|
89
|
-
abortController.abort();
|
|
90
|
-
}
|
|
91
|
-
const abortError = new DOMException(e.target.reason, "AbortError");
|
|
92
|
-
reject(abortError);
|
|
93
|
-
};
|
|
94
|
-
signal.addEventListener("abort", handleAbort);
|
|
95
|
-
responsePromise.then(resolve).finally(() => {
|
|
96
|
-
signal.removeEventListener("abort", handleAbort);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
} else {
|
|
100
|
-
return await coalescedRequest.responsePromise;
|
|
101
|
-
}
|
|
39
|
+
// src/airdrop.ts
|
|
40
|
+
function airdropFactory({ rpc, rpcSubscriptions }) {
|
|
41
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
42
|
+
rpc,
|
|
43
|
+
rpcSubscriptions
|
|
44
|
+
);
|
|
45
|
+
async function confirmSignatureOnlyTransaction(config) {
|
|
46
|
+
await waitForRecentTransactionConfirmationUntilTimeout({
|
|
47
|
+
...config,
|
|
48
|
+
getRecentSignatureConfirmationPromise,
|
|
49
|
+
getTimeoutPromise
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return async function airdrop(config) {
|
|
53
|
+
return await requestAndConfirmAirdrop_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
54
|
+
...config,
|
|
55
|
+
confirmSignatureOnlyTransaction,
|
|
56
|
+
rpc
|
|
57
|
+
});
|
|
102
58
|
};
|
|
103
59
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
60
|
+
var compiledTransactionDecoder = void 0;
|
|
61
|
+
async function fetchLookupTables(lookupTableAddresses, rpc, config) {
|
|
62
|
+
const fetchedLookupTables = await fetchJsonParsedAccounts(
|
|
63
|
+
rpc,
|
|
64
|
+
lookupTableAddresses,
|
|
65
|
+
config
|
|
66
|
+
);
|
|
67
|
+
assertAccountsDecoded(fetchedLookupTables);
|
|
68
|
+
assertAccountsExist(fetchedLookupTables);
|
|
69
|
+
return fetchedLookupTables.reduce((acc, lookup) => {
|
|
70
|
+
return {
|
|
71
|
+
...acc,
|
|
72
|
+
[lookup.address]: lookup.data.addresses
|
|
73
|
+
};
|
|
74
|
+
}, {});
|
|
75
|
+
}
|
|
76
|
+
async function decodeTransaction(encodedTransaction, rpc, config) {
|
|
77
|
+
const { lastValidBlockHeight, ...fetchAccountsConfig } = config ?? {};
|
|
78
|
+
if (!compiledTransactionDecoder)
|
|
79
|
+
compiledTransactionDecoder = getCompiledTransactionDecoder();
|
|
80
|
+
const compiledTransaction = compiledTransactionDecoder.decode(encodedTransaction);
|
|
81
|
+
const { compiledMessage } = compiledTransaction;
|
|
82
|
+
const lookupTables = "addressTableLookups" in compiledMessage && compiledMessage.addressTableLookups !== void 0 && compiledMessage.addressTableLookups.length > 0 ? compiledMessage.addressTableLookups : [];
|
|
83
|
+
const lookupTableAddresses = lookupTables.map((l) => l.lookupTableAddress);
|
|
84
|
+
const fetchedLookupTables = lookupTableAddresses.length > 0 ? await fetchLookupTables(lookupTableAddresses, rpc, fetchAccountsConfig) : {};
|
|
85
|
+
return decompileTransaction(compiledTransaction, {
|
|
86
|
+
addressesByLookupTableAddress: fetchedLookupTables,
|
|
87
|
+
lastValidBlockHeight
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, config) {
|
|
91
|
+
if (
|
|
92
|
+
// The developer has supplied no value for `preflightCommitment`.
|
|
93
|
+
!config?.preflightCommitment && // The value of `commitment` is lower than the server default of `preflightCommitment`.
|
|
94
|
+
commitmentComparator(
|
|
95
|
+
commitment,
|
|
96
|
+
"finalized"
|
|
97
|
+
/* default value of `preflightCommitment` */
|
|
98
|
+
) < 0
|
|
99
|
+
) {
|
|
100
|
+
return {
|
|
101
|
+
...config,
|
|
102
|
+
// In the common case, it is unlikely that you want to simulate a transaction at
|
|
103
|
+
// `finalized` commitment when your standard of commitment for confirming the
|
|
104
|
+
// transaction is lower. Cap the simulation commitment level to the level of the
|
|
105
|
+
// confirmation commitment.
|
|
106
|
+
preflightCommitment: commitment
|
|
107
|
+
};
|
|
110
108
|
}
|
|
109
|
+
return config;
|
|
110
|
+
}
|
|
111
|
+
async function sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
112
|
+
abortSignal,
|
|
113
|
+
commitment,
|
|
114
|
+
rpc,
|
|
115
|
+
transaction,
|
|
116
|
+
...sendTransactionConfig
|
|
117
|
+
}) {
|
|
118
|
+
const base64EncodedWireTransaction = getBase64EncodedWireTransaction(transaction);
|
|
119
|
+
return await rpc.sendTransaction(base64EncodedWireTransaction, {
|
|
120
|
+
...getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, sendTransactionConfig),
|
|
121
|
+
encoding: "base64"
|
|
122
|
+
}).send({ abortSignal });
|
|
123
|
+
}
|
|
124
|
+
async function sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
125
|
+
abortSignal,
|
|
126
|
+
commitment,
|
|
127
|
+
confirmDurableNonceTransaction,
|
|
128
|
+
rpc,
|
|
129
|
+
transaction,
|
|
130
|
+
...sendTransactionConfig
|
|
131
|
+
}) {
|
|
132
|
+
const transactionSignature = await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
133
|
+
...sendTransactionConfig,
|
|
134
|
+
abortSignal,
|
|
135
|
+
commitment,
|
|
136
|
+
rpc,
|
|
137
|
+
transaction
|
|
138
|
+
});
|
|
139
|
+
await confirmDurableNonceTransaction({
|
|
140
|
+
abortSignal,
|
|
141
|
+
commitment,
|
|
142
|
+
transaction
|
|
143
|
+
});
|
|
144
|
+
return transactionSignature;
|
|
145
|
+
}
|
|
146
|
+
async function sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
147
|
+
abortSignal,
|
|
148
|
+
commitment,
|
|
149
|
+
confirmRecentTransaction,
|
|
150
|
+
rpc,
|
|
151
|
+
transaction,
|
|
152
|
+
...sendTransactionConfig
|
|
153
|
+
}) {
|
|
154
|
+
const transactionSignature = await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
155
|
+
...sendTransactionConfig,
|
|
156
|
+
abortSignal,
|
|
157
|
+
commitment,
|
|
158
|
+
rpc,
|
|
159
|
+
transaction
|
|
160
|
+
});
|
|
161
|
+
await confirmRecentTransaction({
|
|
162
|
+
abortSignal,
|
|
163
|
+
commitment,
|
|
164
|
+
transaction
|
|
165
|
+
});
|
|
166
|
+
return transactionSignature;
|
|
111
167
|
}
|
|
112
168
|
|
|
113
|
-
// src/
|
|
114
|
-
function
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
169
|
+
// src/send-transaction.ts
|
|
170
|
+
function sendTransactionWithoutConfirmingFactory({
|
|
171
|
+
rpc
|
|
172
|
+
}) {
|
|
173
|
+
return async function sendTransactionWithoutConfirming(transaction, config) {
|
|
174
|
+
await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
175
|
+
...config,
|
|
176
|
+
rpc,
|
|
177
|
+
transaction
|
|
178
|
+
});
|
|
179
|
+
};
|
|
120
180
|
}
|
|
121
|
-
function
|
|
122
|
-
|
|
123
|
-
|
|
181
|
+
function sendAndConfirmDurableNonceTransactionFactory({
|
|
182
|
+
rpc,
|
|
183
|
+
rpcSubscriptions
|
|
184
|
+
}) {
|
|
185
|
+
const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions);
|
|
186
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
187
|
+
rpc,
|
|
188
|
+
rpcSubscriptions
|
|
189
|
+
);
|
|
190
|
+
async function confirmDurableNonceTransaction(config) {
|
|
191
|
+
await waitForDurableNonceTransactionConfirmation({
|
|
124
192
|
...config,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
193
|
+
getNonceInvalidationPromise,
|
|
194
|
+
getRecentSignatureConfirmationPromise
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
return async function sendAndConfirmDurableNonceTransaction(transaction, config) {
|
|
198
|
+
await sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
199
|
+
...config,
|
|
200
|
+
confirmDurableNonceTransaction,
|
|
201
|
+
rpc,
|
|
202
|
+
transaction
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function sendAndConfirmTransactionFactory({
|
|
207
|
+
rpc,
|
|
208
|
+
rpcSubscriptions
|
|
209
|
+
}) {
|
|
210
|
+
const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory({
|
|
211
|
+
rpc,
|
|
212
|
+
rpcSubscriptions
|
|
213
|
+
});
|
|
214
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
215
|
+
rpc,
|
|
216
|
+
rpcSubscriptions
|
|
134
217
|
);
|
|
218
|
+
async function confirmRecentTransaction(config) {
|
|
219
|
+
await waitForRecentTransactionConfirmation({
|
|
220
|
+
...config,
|
|
221
|
+
getBlockHeightExceedencePromise,
|
|
222
|
+
getRecentSignatureConfirmationPromise
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
return async function sendAndConfirmTransaction(transaction, config) {
|
|
226
|
+
await sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
227
|
+
...config,
|
|
228
|
+
confirmRecentTransaction,
|
|
229
|
+
rpc,
|
|
230
|
+
transaction
|
|
231
|
+
});
|
|
232
|
+
};
|
|
135
233
|
}
|
|
136
234
|
|
|
137
|
-
export {
|
|
235
|
+
export { airdropFactory, decodeTransaction, sendAndConfirmDurableNonceTransactionFactory, sendAndConfirmTransactionFactory, sendTransactionWithoutConfirmingFactory };
|
|
138
236
|
//# sourceMappingURL=out.js.map
|
|
139
237
|
//# sourceMappingURL=index.native.js.map
|
package/dist/index.native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/rpc.ts","../src/rpc-integer-overflow-error.ts","../src/rpc-default-config.ts","../src/rpc-transport.ts","../src/rpc-request-coalescer.ts","../src/rpc-request-deduplication.ts"],"names":[],"mappings":";AAAA,cAAc;AACd,cAAc;;;ACDd,SAAS,0BAA4C;AACrD,SAAS,qBAAqB;;;ACDvB,IAAM,oCAAN,cAAgD,MAAM;AAAA,EAIzD,YAAY,YAAoB,SAA8B,OAAe;AACzE,UAAM,eAAe,OAAO,QAAQ,CAAC,MAAM,WAAW,QAAQ,CAAC,IAAI,SAAS,QAAQ,CAAC,GAAG,EAAE,KAAK;AAC/F,QAAI,UAAU;AACd,UAAM,YAAY,cAAc;AAChC,UAAM,gBAAgB,cAAc;AACpC,QAAI,aAAa,KAAK,iBAAiB,IAAI;AACvC,gBAAU,cAAc;AAAA,IAC5B,WAAW,aAAa,KAAK,iBAAiB,IAAI;AAC9C,gBAAU,cAAc;AAAA,IAC5B,WAAW,aAAa,KAAK,iBAAiB,IAAI;AAC9C,gBAAU,cAAc;AAAA,IAC5B,OAAO;AACH,gBAAU,cAAc;AAAA,IAC5B;AACA,UAAM,O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AiB;AAAA,QAC5C;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,IACD;AAAA,EACJ;AACJ","sourcesContent":["export * from '@solana/instructions';\nexport * from '@solana/keys';\nexport * from './rpc';\nexport * from './rpc-transport';\n","import { createSolanaRpcApi, SolanaRpcMethods } from '@solana/rpc-core';\nimport { createJsonRpc } from '@solana/rpc-transport';\nimport type { Rpc } from '@solana/rpc-transport/dist/types/json-rpc-types';\n\nimport { DEFAULT_RPC_CONFIG } from './rpc-default-config';\n\nexport function createSolanaRpc(config: Omit<Parameters<typeof createJsonRpc>[0], 'api'>): Rpc<SolanaRpcMethods> {\n return createJsonRpc<SolanaRpcMethods>({\n ...config,\n api: createSolanaRpcApi(DEFAULT_RPC_CONFIG),\n });\n}\n","export class SolanaJsonRpcIntegerOverflowError extends Error {\n readonly methodName: string;\n readonly keyPath: (number | string)[];\n readonly value: bigint;\n constructor(methodName: string, keyPath: (number | string)[], value: bigint) {\n const argPosition = (typeof keyPath[0] === 'number' ? keyPath[0] : parseInt(keyPath[0], 10)) + 1;\n let ordinal = '';\n const lastDigit = argPosition % 10;\n const lastTwoDigits = argPosition % 100;\n if (lastDigit == 1 && lastTwoDigits != 11) {\n ordinal = argPosition + 'st';\n } else if (lastDigit == 2 && lastTwoDigits != 12) {\n ordinal = argPosition + 'nd';\n } else if (lastDigit == 3 && lastTwoDigits != 13) {\n ordinal = argPosition + 'rd';\n } else {\n ordinal = argPosition + 'th';\n }\n const path =\n keyPath.length > 1\n ? keyPath\n .slice(1)\n .map(pathPart => (typeof pathPart === 'number' ? `[${pathPart}]` : pathPart))\n .join('.')\n : null;\n super(\n `The ${ordinal} argument to the \\`${methodName}\\` RPC method` +\n `${path ? ` at path \\`${path}\\`` : ''} was \\`${value}\\`. This number is ` +\n 'unsafe for use with the Solana JSON-RPC because it exceeds ' +\n '`Number.MAX_SAFE_INTEGER`.'\n );\n this.keyPath = keyPath;\n this.methodName = methodName;\n this.value = value;\n }\n get name() {\n return 'SolanaJsonRpcIntegerOverflowError';\n }\n}\n","import { createSolanaRpcApi } from '@solana/rpc-core';\n\nimport { SolanaJsonRpcIntegerOverflowError } from './rpc-integer-overflow-error';\n\nexport const DEFAULT_RPC_CONFIG: Partial<Parameters<typeof createSolanaRpcApi>[0]> = {\n onIntegerOverflow(methodName, keyPath, value) {\n throw new SolanaJsonRpcIntegerOverflowError(methodName, keyPath, value);\n },\n};\n","import { createHttpTransport } from '@solana/rpc-transport';\nimport { IRpcTransport } from '@solana/rpc-transport/dist/types/transports/transport-types';\n\nimport { getRpcTransportWithRequestCoalescing } from './rpc-request-coalescer';\nimport { getSolanaRpcPayloadDeduplicationKey } from './rpc-request-deduplication';\n\n/**\n * Lowercasing header names makes it easier to override user-supplied headers.\n */\nfunction normalizeHeaders<T extends Record<string, string>>(\n headers: T\n): { [K in keyof T & string as Lowercase<K>]: T[K] } {\n const out: Record<string, string> = {};\n for (const headerName in headers) {\n out[headerName.toLowerCase()] = headers[headerName];\n }\n return out as { [K in keyof T & string as Lowercase<K>]: T[K] };\n}\n\nexport function createDefaultRpcTransport(config: Parameters<typeof createHttpTransport>[0]): IRpcTransport {\n return getRpcTransportWithRequestCoalescing(\n createHttpTransport({\n ...config,\n headers: {\n ...(config.headers ? normalizeHeaders(config.headers) : undefined),\n ...({\n // Keep these headers lowercase so they will override any user-supplied headers above.\n 'solana-client': `js/${__VERSION__}` ?? 'UNKNOWN',\n } as { [overrideHeader: string]: string }),\n },\n }),\n getSolanaRpcPayloadDeduplicationKey\n );\n}\n","import { IRpcTransport } from '@solana/rpc-transport/dist/types/transports/transport-types';\n\ntype CoalescedRequest = {\n readonly abortController: AbortController;\n numConsumers: number;\n readonly responsePromise: Promise<unknown>;\n};\n\ntype GetDeduplicationKeyFn = (payload: unknown) => string | undefined;\n\nexport function getRpcTransportWithRequestCoalescing(\n transport: IRpcTransport,\n getDeduplicationKey: GetDeduplicationKeyFn\n): IRpcTransport {\n let coalescedRequestsByDeduplicationKey: Record<string, CoalescedRequest> | undefined;\n return async function makeCoalescedHttpRequest<TResponse>(\n config: Parameters<IRpcTransport>[0]\n ): Promise<TResponse> {\n const { payload, signal } = config;\n const deduplicationKey = getDeduplicationKey(payload);\n if (deduplicationKey === undefined) {\n return await transport(config);\n }\n if (!coalescedRequestsByDeduplicationKey) {\n Promise.resolve().then(() => {\n coalescedRequestsByDeduplicationKey = undefined;\n });\n coalescedRequestsByDeduplicationKey = {};\n }\n if (coalescedRequestsByDeduplicationKey[deduplicationKey] == null) {\n const abortController = new AbortController();\n coalescedRequestsByDeduplicationKey[deduplicationKey] = {\n abortController,\n numConsumers: 0,\n responsePromise: transport<TResponse>({\n ...config,\n signal: abortController.signal,\n }),\n };\n }\n const coalescedRequest = coalescedRequestsByDeduplicationKey[deduplicationKey];\n coalescedRequest.numConsumers++;\n if (signal) {\n const responsePromise = coalescedRequest.responsePromise as Promise<TResponse>;\n return await new Promise<TResponse>((resolve, reject) => {\n const handleAbort = (e: AbortSignalEventMap['abort']) => {\n signal.removeEventListener('abort', handleAbort);\n coalescedRequest.numConsumers -= 1;\n if (coalescedRequest.numConsumers === 0) {\n const abortController = coalescedRequest.abortController;\n abortController.abort();\n }\n const abortError = new DOMException((e.target as AbortSignal).reason, 'AbortError');\n reject(abortError);\n };\n signal.addEventListener('abort', handleAbort);\n responsePromise.then(resolve).finally(() => {\n signal.removeEventListener('abort', handleAbort);\n });\n });\n } else {\n return (await coalescedRequest.responsePromise) as TResponse;\n }\n };\n}\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport fastStableStringify from 'fast-stable-stringify';\n\nexport function getSolanaRpcPayloadDeduplicationKey(payload: unknown): string | undefined {\n if (payload == null || typeof payload !== 'object' || Array.isArray(payload)) {\n return;\n }\n if ('jsonrpc' in payload && payload.jsonrpc === '2.0' && 'method' in payload && 'params' in payload) {\n return fastStableStringify([payload.method, payload.params]);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/airdrop.ts","../src/airdrop-internal.ts","../src/decode-transaction.ts","../src/send-transaction.ts","../src/send-transaction-internal.ts"],"names":["createRecentSignatureConfirmationPromiseFactory"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;;;ACTd;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,OACG;;;ACaP,eAAsB,qDAAqD;AAAA,EACvE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,GAAuD;AACnD,QAAM,8BAA8B,MAAM,IACrC,eAAe,kBAAkB,UAAU,EAAE,WAAW,CAAC,EACzD,KAAK,EAAE,YAAY,CAAC;AACzB,QAAM,gCAAgC;AAAA,IAClC;AAAA,IACA;AAAA,IACA,WAAW;AAAA,EACf,CAAC;AACD,SAAO;AACX;;;ADdO,SAAS,eAAe,EAAE,KAAK,iBAAiB,GAA0C;AAC7F,QAAM,wCAAwC;AAAA,IAC1C;AAAA,IACA;AAAA,EACJ;AACA,iBAAe,gCACX,QAIF;AACE,UAAM,iDAAiD;AAAA,MACnD,GAAG;AAAA,MACH;AAAA,MACA;AAAA,IACJ,CAAC;AAAA,EACL;AACA,SAAO,eAAe,QAAQ,QAAQ;AAClC,WAAO,MAAM,qDAAqD;AAAA,MAC9D,GAAG;AAAA,MACH;AAAA,MACA;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;;;AE/CA;AAAA,EACI;AAAA,EACA;AAAA,EAEA;AAAA,OACG;AAGP;AAAA,EAGI;AAAA,EACA;AAAA,OAEG;AAEP,IAAI,6BAA2F;AAM/F,eAAe,kBACX,sBACA,KACA,QACsC;AACtC,QAAM,sBAAsB,MAAM;AAAA,IAC9B;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AACA,wBAAsB,mBAAmB;AACzC,sBAAoB,mBAAmB;AAEvC,SAAO,oB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AACA,SAAO,eAAe,sCAAsC,aAAa,QAAQ;AAC7E,UAAM,kEAAkE;AAAA,MACpE,GAAG;AAAA,MACH;AAAA,MACA;AAAA,MACA;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;AAEO,SAAS,iCAAiC;AAAA,EAC7C;AAAA,EACA;AACJ,GAAwH;AACpH,QAAM,kCAAkC,0CAA0C;AAAA,IAC9E;AAAA,IACA;AAAA,EACJ,CAAC;AACD,QAAM,wCAAwCA;AAAA,IAC1C;AAAA,IACA;AAAA,EACJ;AACA,iBAAe,yBACX,QAIF;AACE,UAAM,qCAAqC;AAAA,MACvC,GAAG;AAAA,MACH;AAAA,MACA;AAAA,IACJ,CAAC;AAAA,EACL;AACA,SAAO,eAAe,0BAA0B,aAAa,QAAQ;AACjE,UAAM,2EAA2E;AAAA,MAC7E,GAAG;AAAA,MACH;AAAA,MACA;AAAA,MACA;AAAA,IACJ,CAAC;AAAA,EACL;AACJ","sourcesContent":["export * from '@solana/accounts';\nexport * from '@solana/addresses';\nexport * from '@solana/codecs';\nexport * from '@solana/functional';\nexport * from '@solana/instructions';\nexport * from '@solana/keys';\nexport * from '@solana/programs';\nexport * from '@solana/rpc';\nexport * from '@solana/rpc-parsed-types';\nexport * from '@solana/rpc-subscriptions';\nexport * from '@solana/rpc-types';\nexport * from '@solana/signers';\nexport * from '@solana/transactions';\nexport * from './airdrop';\nexport * from './decode-transaction';\nexport * from './send-transaction';\n","import type { Signature } from '@solana/keys';\nimport type { GetSignatureStatusesApi, RequestAirdropApi, Rpc } from '@solana/rpc';\nimport type { RpcSubscriptions, SignatureNotificationsApi } from '@solana/rpc-subscriptions';\nimport {\n createRecentSignatureConfirmationPromiseFactory,\n getTimeoutPromise,\n waitForRecentTransactionConfirmationUntilTimeout,\n} from '@solana/transaction-confirmation';\n\nimport { requestAndConfirmAirdrop_INTERNAL_ONLY_DO_NOT_EXPORT } from './airdrop-internal';\n\ntype AirdropFunction = (\n config: Omit<\n Parameters<typeof requestAndConfirmAirdrop_INTERNAL_ONLY_DO_NOT_EXPORT>[0],\n 'confirmSignatureOnlyTransaction' | 'rpc'\n >,\n) => Promise<Signature>;\n\ntype AirdropFactoryConfig = Readonly<{\n rpc: Rpc<GetSignatureStatusesApi & RequestAirdropApi>;\n rpcSubscriptions: RpcSubscriptions<SignatureNotificationsApi>;\n}>;\n\nexport function airdropFactory({ rpc, rpcSubscriptions }: AirdropFactoryConfig): AirdropFunction {\n const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(\n rpc,\n rpcSubscriptions,\n );\n async function confirmSignatureOnlyTransaction(\n config: Omit<\n Parameters<typeof waitForRecentTransactionConfirmationUntilTimeout>[0],\n 'getRecentSignatureConfirmationPromise' | 'getTimeoutPromise'\n >,\n ) {\n await waitForRecentTransactionConfirmationUntilTimeout({\n ...config,\n getRecentSignatureConfirmationPromise,\n getTimeoutPromise,\n });\n }\n return async function airdrop(config) {\n return await requestAndConfirmAirdrop_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n confirmSignatureOnlyTransaction,\n rpc,\n });\n };\n}\n","import type { Address } from '@solana/addresses';\nimport type { Signature } from '@solana/keys';\nimport type { RequestAirdropApi, Rpc } from '@solana/rpc';\nimport type { Commitment, LamportsUnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types';\nimport { waitForRecentTransactionConfirmationUntilTimeout } from '@solana/transaction-confirmation';\n\ntype RequestAndConfirmAirdropConfig = Readonly<{\n abortSignal?: AbortSignal;\n commitment: Commitment;\n confirmSignatureOnlyTransaction: (\n config: Omit<\n Parameters<typeof waitForRecentTransactionConfirmationUntilTimeout>[0],\n 'getRecentSignatureConfirmationPromise' | 'getTimeoutPromise'\n >,\n ) => Promise<void>;\n lamports: LamportsUnsafeBeyond2Pow53Minus1;\n recipientAddress: Address;\n rpc: Rpc<RequestAirdropApi>;\n}>;\n\nexport async function requestAndConfirmAirdrop_INTERNAL_ONLY_DO_NOT_EXPORT({\n abortSignal,\n commitment,\n confirmSignatureOnlyTransaction,\n lamports,\n recipientAddress,\n rpc,\n}: RequestAndConfirmAirdropConfig): Promise<Signature> {\n const airdropTransactionSignature = await rpc\n .requestAirdrop(recipientAddress, lamports, { commitment })\n .send({ abortSignal });\n await confirmSignatureOnlyTransaction({\n abortSignal,\n commitment,\n signature: airdropTransactionSignature,\n });\n return airdropTransactionSignature;\n}\n","import {\n assertAccountsDecoded,\n assertAccountsExist,\n type FetchAccountsConfig,\n fetchJsonParsedAccounts,\n} from '@solana/accounts';\nimport type { Address } from '@solana/addresses';\nimport type { GetMultipleAccountsApi, Rpc } from '@solana/rpc';\nimport {\n type AddressesByLookupTableAddress,\n type CompilableTransaction,\n decompileTransaction,\n getCompiledTransactionDecoder,\n type ITransactionWithSignatures,\n} from '@solana/transactions';\n\nlet compiledTransactionDecoder: ReturnType<typeof getCompiledTransactionDecoder> | undefined = undefined;\n\ntype FetchedAddressLookup = {\n addresses: Address[];\n};\n\nasync function fetchLookupTables(\n lookupTableAddresses: Address[],\n rpc: Rpc<GetMultipleAccountsApi>,\n config?: FetchAccountsConfig,\n): Promise<AddressesByLookupTableAddress> {\n const fetchedLookupTables = await fetchJsonParsedAccounts<FetchedAddressLookup[]>(\n rpc,\n lookupTableAddresses,\n config,\n );\n assertAccountsDecoded(fetchedLookupTables);\n assertAccountsExist(fetchedLookupTables);\n\n return fetchedLookupTables.reduce<AddressesByLookupTableAddress>((acc, lookup) => {\n return {\n ...acc,\n [lookup.address]: lookup.data.addresses,\n };\n }, {});\n}\n\ntype DecodeTransactionConfig = FetchAccountsConfig & {\n lastValidBlockHeight?: bigint;\n};\n\nexport async function decodeTransaction(\n encodedTransaction: Uint8Array,\n rpc: Rpc<GetMultipleAccountsApi>,\n config?: DecodeTransactionConfig,\n): Promise<CompilableTransaction | (CompilableTransaction & ITransactionWithSignatures)> {\n const { lastValidBlockHeight, ...fetchAccountsConfig } = config ?? {};\n\n if (!compiledTransactionDecoder) compiledTransactionDecoder = getCompiledTransactionDecoder();\n const compiledTransaction = compiledTransactionDecoder.decode(encodedTransaction);\n const { compiledMessage } = compiledTransaction;\n\n const lookupTables =\n 'addressTableLookups' in compiledMessage &&\n compiledMessage.addressTableLookups !== undefined &&\n compiledMessage.addressTableLookups.length > 0\n ? compiledMessage.addressTableLookups\n : [];\n const lookupTableAddresses = lookupTables.map(l => l.lookupTableAddress);\n\n const fetchedLookupTables =\n lookupTableAddresses.length > 0 ? await fetchLookupTables(lookupTableAddresses, rpc, fetchAccountsConfig) : {};\n\n return decompileTransaction(compiledTransaction, {\n addressesByLookupTableAddress: fetchedLookupTables,\n lastValidBlockHeight,\n });\n}\n","import type { GetAccountInfoApi, GetEpochInfoApi, GetSignatureStatusesApi, Rpc, SendTransactionApi } from '@solana/rpc';\nimport type {\n AccountNotificationsApi,\n RpcSubscriptions,\n SignatureNotificationsApi,\n SlotNotificationsApi,\n} from '@solana/rpc-subscriptions';\nimport {\n createBlockHeightExceedencePromiseFactory,\n createNonceInvalidationPromiseFactory,\n createRecentSignatureConfirmationPromiseFactory,\n waitForDurableNonceTransactionConfirmation,\n waitForRecentTransactionConfirmation,\n} from '@solana/transaction-confirmation';\nimport {\n BaseTransaction,\n IDurableNonceTransaction,\n IFullySignedTransaction,\n ITransactionWithBlockhashLifetime,\n ITransactionWithFeePayer,\n} from '@solana/transactions';\n\nimport {\n SendableTransaction,\n sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT,\n sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT,\n sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT,\n} from './send-transaction-internal';\n\ninterface SendAndConfirmDurableNonceTransactionFactoryConfig {\n rpc: Rpc<GetAccountInfoApi & GetSignatureStatusesApi & SendTransactionApi>;\n rpcSubscriptions: RpcSubscriptions<AccountNotificationsApi & SignatureNotificationsApi>;\n}\n\ninterface SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig {\n rpc: Rpc<GetEpochInfoApi & GetSignatureStatusesApi & SendTransactionApi>;\n rpcSubscriptions: RpcSubscriptions<SignatureNotificationsApi & SlotNotificationsApi>;\n}\n\ninterface SendTransactionWithoutConfirmingFactoryConfig {\n rpc: Rpc<SendTransactionApi>;\n}\n\ntype SendAndConfirmTransactionWithBlockhashLifetimeFunction = (\n transaction: ITransactionWithBlockhashLifetime & SendableTransaction,\n config: Omit<\n Parameters<typeof sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT>[0],\n 'confirmRecentTransaction' | 'rpc' | 'transaction'\n >,\n) => Promise<void>;\n\ntype SendAndConfirmDurableNonceTransactionFunction = (\n transaction: BaseTransaction & IDurableNonceTransaction & IFullySignedTransaction & ITransactionWithFeePayer,\n config: Omit<\n Parameters<typeof sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT>[0],\n 'confirmDurableNonceTransaction' | 'rpc' | 'transaction'\n >,\n) => Promise<void>;\n\ntype SendTransactionWithoutConfirmingFunction = (\n transaction: SendableTransaction,\n config: Omit<Parameters<typeof sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT>[0], 'rpc' | 'transaction'>,\n) => Promise<void>;\n\nexport function sendTransactionWithoutConfirmingFactory({\n rpc,\n}: SendTransactionWithoutConfirmingFactoryConfig): SendTransactionWithoutConfirmingFunction {\n return async function sendTransactionWithoutConfirming(transaction, config) {\n await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n rpc,\n transaction,\n });\n };\n}\n\nexport function sendAndConfirmDurableNonceTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmDurableNonceTransactionFactoryConfig): SendAndConfirmDurableNonceTransactionFunction {\n const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions);\n const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(\n rpc,\n rpcSubscriptions,\n );\n async function confirmDurableNonceTransaction(\n config: Omit<\n Parameters<typeof waitForDurableNonceTransactionConfirmation>[0],\n 'getNonceInvalidationPromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) {\n await waitForDurableNonceTransactionConfirmation({\n ...config,\n getNonceInvalidationPromise,\n getRecentSignatureConfirmationPromise,\n });\n }\n return async function sendAndConfirmDurableNonceTransaction(transaction, config) {\n await sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n confirmDurableNonceTransaction,\n rpc,\n transaction,\n });\n };\n}\n\nexport function sendAndConfirmTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig): SendAndConfirmTransactionWithBlockhashLifetimeFunction {\n const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory({\n rpc,\n rpcSubscriptions,\n });\n const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(\n rpc,\n rpcSubscriptions,\n );\n async function confirmRecentTransaction(\n config: Omit<\n Parameters<typeof waitForRecentTransactionConfirmation>[0],\n 'getBlockHeightExceedencePromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) {\n await waitForRecentTransactionConfirmation({\n ...config,\n getBlockHeightExceedencePromise,\n getRecentSignatureConfirmationPromise,\n });\n }\n return async function sendAndConfirmTransaction(transaction, config) {\n await sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n confirmRecentTransaction,\n rpc,\n transaction,\n });\n };\n}\n","import type { Signature } from '@solana/keys';\nimport type { Rpc, SendTransactionApi } from '@solana/rpc';\nimport { Commitment, commitmentComparator } from '@solana/rpc-types';\nimport {\n waitForDurableNonceTransactionConfirmation,\n waitForRecentTransactionConfirmation,\n} from '@solana/transaction-confirmation';\nimport {\n BaseTransaction,\n getBase64EncodedWireTransaction,\n IDurableNonceTransaction,\n IFullySignedTransaction,\n ITransactionWithBlockhashLifetime,\n ITransactionWithFeePayer,\n} from '@solana/transactions';\n\ninterface SendAndConfirmDurableNonceTransactionConfig\n extends SendTransactionBaseConfig,\n SendTransactionConfigWithoutEncoding {\n confirmDurableNonceTransaction: (\n config: Omit<\n Parameters<typeof waitForDurableNonceTransactionConfirmation>[0],\n 'getNonceInvalidationPromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) => Promise<void>;\n transaction: IDurableNonceTransaction & SendableTransaction;\n}\n\ninterface SendAndConfirmTransactionWithBlockhashLifetimeConfig\n extends SendTransactionBaseConfig,\n SendTransactionConfigWithoutEncoding {\n confirmRecentTransaction: (\n config: Omit<\n Parameters<typeof waitForRecentTransactionConfirmation>[0],\n 'getBlockHeightExceedencePromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) => Promise<void>;\n transaction: ITransactionWithBlockhashLifetime & SendableTransaction;\n}\n\ninterface SendTransactionBaseConfig extends SendTransactionConfigWithoutEncoding {\n abortSignal?: AbortSignal;\n commitment: Commitment;\n rpc: Rpc<SendTransactionApi>;\n transaction: SendableTransaction;\n}\n\ninterface SendTransactionConfigWithoutEncoding\n extends Omit<NonNullable<Parameters<SendTransactionApi['sendTransaction']>[1]>, 'encoding'> {}\n\nexport type SendableTransaction = BaseTransaction &\n IFullySignedTransaction &\n ITransactionWithFeePayer &\n (IDurableNonceTransaction | ITransactionWithBlockhashLifetime);\n\nfunction getSendTransactionConfigWithAdjustedPreflightCommitment(\n commitment: Commitment,\n config?: SendTransactionConfigWithoutEncoding,\n): SendTransactionConfigWithoutEncoding | void {\n if (\n // The developer has supplied no value for `preflightCommitment`.\n !config?.preflightCommitment &&\n // The value of `commitment` is lower than the server default of `preflightCommitment`.\n commitmentComparator(commitment, 'finalized' /* default value of `preflightCommitment` */) < 0\n ) {\n return {\n ...config,\n // In the common case, it is unlikely that you want to simulate a transaction at\n // `finalized` commitment when your standard of commitment for confirming the\n // transaction is lower. Cap the simulation commitment level to the level of the\n // confirmation commitment.\n preflightCommitment: commitment,\n };\n }\n // The commitment at which the developer wishes to confirm the transaction is at least as\n // high as the commitment at which they want to simulate it. Honour the config as-is.\n return config;\n}\n\nexport async function sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n abortSignal,\n commitment,\n rpc,\n transaction,\n ...sendTransactionConfig\n}: SendTransactionBaseConfig): Promise<Signature> {\n const base64EncodedWireTransaction = getBase64EncodedWireTransaction(transaction);\n return await rpc\n .sendTransaction(base64EncodedWireTransaction, {\n ...getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, sendTransactionConfig),\n encoding: 'base64',\n })\n .send({ abortSignal });\n}\n\nexport async function sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n abortSignal,\n commitment,\n confirmDurableNonceTransaction,\n rpc,\n transaction,\n ...sendTransactionConfig\n}: SendAndConfirmDurableNonceTransactionConfig): Promise<Signature> {\n const transactionSignature = await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...sendTransactionConfig,\n abortSignal,\n commitment,\n rpc,\n transaction,\n });\n await confirmDurableNonceTransaction({\n abortSignal,\n commitment,\n transaction,\n });\n return transactionSignature;\n}\n\nexport async function sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT({\n abortSignal,\n commitment,\n confirmRecentTransaction,\n rpc,\n transaction,\n ...sendTransactionConfig\n}: SendAndConfirmTransactionWithBlockhashLifetimeConfig): Promise<Signature> {\n const transactionSignature = await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...sendTransactionConfig,\n abortSignal,\n commitment,\n rpc,\n transaction,\n });\n await confirmRecentTransaction({\n abortSignal,\n commitment,\n transaction,\n });\n return transactionSignature;\n}\n"]}
|