@solana/web3.js 1.44.1 → 1.45.0
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/lib/index.browser.cjs.js +34 -19
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +34 -19
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +34 -19
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.esm.js +34 -19
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +34 -19
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +2 -2
- package/lib/index.iife.min.js.map +1 -1
- package/package.json +3 -3
- package/src/connection.ts +24 -4
- package/src/transaction.ts +19 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/web3.js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.45.0",
|
|
4
4
|
"description": "Solana Javascript API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"pretty": "prettier --check '{,{src,test}/**/}*.{j,t}s'",
|
|
51
51
|
"pretty:fix": "prettier --write '{,{src,test}/**/}*.{j,t}s'",
|
|
52
52
|
"re": "semantic-release --repository-url git@github.com:solana-labs/solana-web3.js.git",
|
|
53
|
-
"test": "cross-env TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\" }' ts-mocha --require esm './test/**/*.test.ts'",
|
|
53
|
+
"test": "cross-env TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\", \"target\": \"es2019\" }' ts-mocha --require esm './test/**/*.test.ts'",
|
|
54
54
|
"test:cover": "nyc --reporter=lcov npm run test",
|
|
55
55
|
"test:live": "TEST_LIVE=1 npm run test",
|
|
56
56
|
"test:live-with-test-validator": "start-server-and-test 'solana-test-validator --reset --quiet' http://localhost:8899/health test:live"
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"jayson": "^3.4.4",
|
|
69
69
|
"js-sha3": "^0.8.0",
|
|
70
70
|
"node-fetch": "2",
|
|
71
|
-
"rpc-websockets": "^7.
|
|
71
|
+
"rpc-websockets": "^7.5.0",
|
|
72
72
|
"secp256k1": "^4.0.2",
|
|
73
73
|
"superstruct": "^0.14.2",
|
|
74
74
|
"tweetnacl": "^1.0.0"
|
package/src/connection.ts
CHANGED
|
@@ -191,9 +191,9 @@ type Subscription = BaseSubscription &
|
|
|
191
191
|
StatefulSubscription &
|
|
192
192
|
DistributiveOmit<SubscriptionConfig, 'callback'>;
|
|
193
193
|
|
|
194
|
-
type RpcRequest = (methodName: string, args: Array<any>) => any
|
|
194
|
+
type RpcRequest = (methodName: string, args: Array<any>) => Promise<any>;
|
|
195
195
|
|
|
196
|
-
type RpcBatchRequest = (requests: RpcParams[]) => any
|
|
196
|
+
type RpcBatchRequest = (requests: RpcParams[]) => Promise<any[]>;
|
|
197
197
|
|
|
198
198
|
/**
|
|
199
199
|
* @internal
|
|
@@ -995,6 +995,7 @@ function createRpcClient(
|
|
|
995
995
|
'Content-Type': 'application/json',
|
|
996
996
|
},
|
|
997
997
|
httpHeaders || {},
|
|
998
|
+
COMMON_HTTP_HEADERS,
|
|
998
999
|
),
|
|
999
1000
|
};
|
|
1000
1001
|
|
|
@@ -2158,7 +2159,12 @@ export type ConfirmedSignatureInfo = {
|
|
|
2158
2159
|
/**
|
|
2159
2160
|
* An object defining headers to be passed to the RPC server
|
|
2160
2161
|
*/
|
|
2161
|
-
export type HttpHeaders = {
|
|
2162
|
+
export type HttpHeaders = {
|
|
2163
|
+
[header: string]: string;
|
|
2164
|
+
} & {
|
|
2165
|
+
// Prohibited headers; for internal use only.
|
|
2166
|
+
'solana-client'?: never;
|
|
2167
|
+
};
|
|
2162
2168
|
|
|
2163
2169
|
/**
|
|
2164
2170
|
* The type of the JavaScript `fetch()` API
|
|
@@ -2194,6 +2200,11 @@ export type ConnectionConfig = {
|
|
|
2194
2200
|
confirmTransactionInitialTimeout?: number;
|
|
2195
2201
|
};
|
|
2196
2202
|
|
|
2203
|
+
/** @internal */
|
|
2204
|
+
const COMMON_HTTP_HEADERS = {
|
|
2205
|
+
'solana-client': `js/${process.env.npm_package_version ?? 'UNKNOWN'}`,
|
|
2206
|
+
};
|
|
2207
|
+
|
|
2197
2208
|
/**
|
|
2198
2209
|
* A connection to a fullnode JSON RPC endpoint
|
|
2199
2210
|
*/
|
|
@@ -3566,7 +3577,16 @@ export class Connection {
|
|
|
3566
3577
|
if ('error' in res) {
|
|
3567
3578
|
throw new Error('failed to get transactions: ' + res.error.message);
|
|
3568
3579
|
}
|
|
3569
|
-
|
|
3580
|
+
const result = res.result;
|
|
3581
|
+
if (!result) return result;
|
|
3582
|
+
|
|
3583
|
+
return {
|
|
3584
|
+
...result,
|
|
3585
|
+
transaction: {
|
|
3586
|
+
...result.transaction,
|
|
3587
|
+
message: new Message(result.transaction.message),
|
|
3588
|
+
},
|
|
3589
|
+
};
|
|
3570
3590
|
});
|
|
3571
3591
|
|
|
3572
3592
|
return res;
|
package/src/transaction.ts
CHANGED
|
@@ -327,17 +327,24 @@ export class Transaction {
|
|
|
327
327
|
return this._message;
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
this.
|
|
330
|
+
let recentBlockhash;
|
|
331
|
+
let instructions: TransactionInstruction[];
|
|
332
|
+
if (this.nonceInfo) {
|
|
333
|
+
recentBlockhash = this.nonceInfo.nonce;
|
|
334
|
+
if (this.instructions[0] != this.nonceInfo.nonceInstruction) {
|
|
335
|
+
instructions = [this.nonceInfo.nonceInstruction, ...this.instructions];
|
|
336
|
+
} else {
|
|
337
|
+
instructions = this.instructions;
|
|
338
|
+
}
|
|
339
|
+
} else {
|
|
340
|
+
recentBlockhash = this.recentBlockhash;
|
|
341
|
+
instructions = this.instructions;
|
|
334
342
|
}
|
|
335
|
-
const {recentBlockhash} = this;
|
|
336
343
|
if (!recentBlockhash) {
|
|
337
344
|
throw new Error('Transaction recentBlockhash required');
|
|
338
345
|
}
|
|
339
346
|
|
|
340
|
-
if (
|
|
347
|
+
if (instructions.length < 1) {
|
|
341
348
|
console.warn('No instructions provided');
|
|
342
349
|
}
|
|
343
350
|
|
|
@@ -351,8 +358,8 @@ export class Transaction {
|
|
|
351
358
|
throw new Error('Transaction fee payer required');
|
|
352
359
|
}
|
|
353
360
|
|
|
354
|
-
for (let i = 0; i <
|
|
355
|
-
if (
|
|
361
|
+
for (let i = 0; i < instructions.length; i++) {
|
|
362
|
+
if (instructions[i].programId === undefined) {
|
|
356
363
|
throw new Error(
|
|
357
364
|
`Transaction instruction index ${i} has undefined program id`,
|
|
358
365
|
);
|
|
@@ -361,7 +368,7 @@ export class Transaction {
|
|
|
361
368
|
|
|
362
369
|
const programIds: string[] = [];
|
|
363
370
|
const accountMetas: AccountMeta[] = [];
|
|
364
|
-
|
|
371
|
+
instructions.forEach(instruction => {
|
|
365
372
|
instruction.keys.forEach(accountMeta => {
|
|
366
373
|
accountMetas.push({...accountMeta});
|
|
367
374
|
});
|
|
@@ -471,7 +478,7 @@ export class Transaction {
|
|
|
471
478
|
});
|
|
472
479
|
|
|
473
480
|
const accountKeys = signedKeys.concat(unsignedKeys);
|
|
474
|
-
const
|
|
481
|
+
const compiledInstructions: CompiledInstruction[] = instructions.map(
|
|
475
482
|
instruction => {
|
|
476
483
|
const {data, programId} = instruction;
|
|
477
484
|
return {
|
|
@@ -484,7 +491,7 @@ export class Transaction {
|
|
|
484
491
|
},
|
|
485
492
|
);
|
|
486
493
|
|
|
487
|
-
|
|
494
|
+
compiledInstructions.forEach(instruction => {
|
|
488
495
|
invariant(instruction.programIdIndex >= 0);
|
|
489
496
|
instruction.accounts.forEach(keyIndex => invariant(keyIndex >= 0));
|
|
490
497
|
});
|
|
@@ -497,7 +504,7 @@ export class Transaction {
|
|
|
497
504
|
},
|
|
498
505
|
accountKeys,
|
|
499
506
|
recentBlockhash,
|
|
500
|
-
instructions,
|
|
507
|
+
instructions: compiledInstructions,
|
|
501
508
|
});
|
|
502
509
|
}
|
|
503
510
|
|