Commit Graph

463 Commits

Author SHA1 Message Date
Yihau Chen 6489c20de5
test: fix rentEpoch value (#29999) 2023-01-31 13:14:28 +08:00
Kollan House a2db104edb
feat: add commission fields matching RPC spec to web3.js client (#29435)
* fix: adds commission field matching RPC spec

* fix: update optional to follow type pattern
2022-12-29 20:22:56 -08:00
TJDawson10 9679bc6d1f
chore: typecheck web3.js tests (#29422)
* fix: web3.js test typescript errors

Fixes the typescript errors throughout the
web3.js test suite

* fix: node14 test

AbortController is a default in node16 but needs
to be imported for node14

* fix: additional typescript errors

Adds the tests to the tsconfig to auto-include mocha
and fixes remaining typescript errors

* fix: graphql-tools to work with typescript

version of graphql-tools initially installed has incompatible
types preventing ./scripts/typegen.sh from passing when tests
are added to the include path of tsconfig.json

* Don't build typedefs for tests

Co-authored-by: steveluscher <me+github@steveluscher.com>
2022-12-29 15:02:21 -08:00
Yihau Chen 3cfd1b244d
test: fix get inflation rate test failed at test:live (#29413) 2022-12-25 02:24:49 +08:00
TJDawson10 c0e6065ac9
feat: add getInflationRate RPC call to web3.js (#29377)
* Add getInflationRate RPC call

* Fix code formatting

Co-authored-by: steveluscher <me+github@steveluscher.com>
2022-12-23 22:08:23 -08:00
Nico Schapeler 5f4752a29e
feat: Allow for verifying the sigs of partially signed txs in web3.js (#29249)
* feat: allow for verifying the sigs of partially signed txs

* fix: make comment ab verifying sigs more specific

Co-authored-by: Steven Luscher <steveluscher@users.noreply.github.com>

* feat: add tests for partial signed tx verification

* fix: revert lockfile changes

* fix: make tests more modular

* fix: run linter

Co-authored-by: Steven Luscher <steveluscher@users.noreply.github.com>
2022-12-23 21:50:53 -08:00
Steven Luscher 456a81982e
fix: reduce Connection keep-alive timeout to 1 second fewer than the Solana RPC's keep-alive timeout (#29130)
* Delete `AgentManager`

* Replace custom `http.Agent` implementation with `agentkeepalive` package

* Set the default free socket timeout to 1s less than the Solana RPC's default timeout

* Add link to particular issue comment

* Create the correct flavor of default agent for http/https
2022-12-19 10:22:25 -08:00
Steven Luscher ffcebbbd9b
fix: pretty print PublicKey objects in node and in the browser (#29062) 2022-12-09 11:27:14 -08:00
Steven Luscher f1427dd90c
feat: you can now supply your own HTTP agent to a web3.js Connection (#29125)
* You can now supply your own `https?.Agent` when creating a `Connection` object

* Don't use HTTP agents in test mode

* Tests that assert the behaviour of the `agentOverride` config of `Connection`

* s/agentOverride/httpAgent/ is less confusing when the value is `false`
2022-12-06 14:57:13 -08:00
Steven Luscher 35f3c18aa8
feat: you can now abort transaction confirmations in web3.js (#29057)
* Upgrade Typescript, `@types/node`, and `typedoc` to versions that play well together

In this instance it means they:

* understand `AbortSignal`
* don't cause build errors

* You can now abort transaction confirmation using an `AbortSignal`

* Pipe an `AbortSignal` down through `sendAndConfirmTransaction()`

* Add `AbortController` polyfill to test so that test works in Node 14
2022-12-02 16:36:09 -08:00
Steven Luscher b112d01a5d
feat: the web3.js getBlock APIs now accept `rewards` and `transactionDetails` config (#29000)
* Add `transactionDetails` and `rewards` params to `getBlock` API of web3.js

* Add the same content to the legacy call

…because it's such a PITA to share config between two methods and not have Typedoc throw a fit.

* Add tests to exercise block deserialization in the case that `transactionDetails` is `none` or `accounts`

* Extract the annotated account key parser into a separate struct

* Parse the `getBlock()` responses differently depending on the mode
2022-12-01 22:04:47 -08:00
Jon Cinque 337621d031
fix: support `VersionedMessage` in `getFeeForMessage` (#28996) 2022-11-30 10:06:43 -08:00
Steven Luscher 491d4f3331
fix: TransactionMessage.decompile() now counts the correct number of unsigned, writable accounts (#28990)
* Test that `TransactionMessage.decompile()` can decompile a legacy `Message`

* `TransactionMessage.decompile()` now correctly accounts for the number of writable unsigned accounts
2022-11-30 09:57:54 -08:00
Steven Luscher 7646521a6e
feat: a nonce-based transaction confirmation strategy for web3.js (#25839)
* feat: you can now construct a `Transaction` with durable nonce information

* chore: refactor confirmation logic so that each strategy gets its own method

* feat: `geNonce` now accepts a `minContextSlot` param

* feat: a nonce-based transaction confirmation strategy

* feat: add nonce confirmation strategy to send-and-confirm helpers

* fix: nits from July 8 review

* Use Typescript narrowing to determine which strategy to use

* Double check the signature confirmation against the slot in which the nonce was discovered to have advanced
2022-11-28 22:46:27 -08:00
Steven Luscher 04789cab81
fix: verify commitment level when confirming transactions with one-shot fetch (#28969)
* Rename `subscriptionCommitment` to `confirmationCommitment`

* Reorganize status checking code to return early if `value` is `null`

* Bail if the one-shot signature result does not meet the target commitment
2022-11-28 18:50:16 -08:00
Adrian Brzeziński d16810ec84
fix: web3.js transaction confirmation now double-checks for already-confirmed txs (#28290)
* chore: create internal method for subscribing to subscription state changes

* add status pool

* fix tests

* more tests

* syntax fix

* variable rename

* fix test

* comment fix

* remove getSignatureStatuses pooling

* rename variable

* IIFE

* wait for subscription

* fix interval clear

* test: you can now pause the establishment of subscriptions in tests

* feat: implementation of signature status check after setting up signature subscription

Co-authored-by: steveluscher <me+github@steveluscher.com>
2022-11-28 11:55:56 -08:00
Dmitri Makarov 34865d032c chore: update Solana docs and code comments that specify "BPF" to "SBF" 2022-10-31 14:14:25 -04:00
Steven Luscher 65f1614a42
test: repair tests, `space` having been added to the account response (#28518) 2022-10-20 13:37:55 -07:00
Justin Starry 831ed96730
feat: add getMultipleParsedAccounts method (#28414) 2022-10-16 07:26:08 +00:00
Justin Starry 36e5f33e67
feat: add dataSlice param to account fetching config (#28389) 2022-10-14 03:28:00 +00:00
Dmitri Makarov d6813b98d2 chore: move programs/bpf to programs/sbf 2022-10-13 11:40:40 -04:00
Justin Starry 33a328e589
feat: add getParsedBlock method to Connection (#28345)
* feat: add getParsedBlock method to Connection

* Update web3.js/src/connection.ts

Co-authored-by: Yihau Chen <a122092487@gmail.com>

Co-authored-by: Yihau Chen <a122092487@gmail.com>
2022-10-11 16:13:10 +08:00
Varga-Somogyi Ákos e15a5c010e
feat: implement addSignature in VersionedTransaction (#27945)
* Implement addSignature in VersionedTransaction

* Update asserts

* VersionedTransaction.addSignature test

* Update VersionedTransaction tests
2022-09-21 17:22:40 -07:00
Steven Luscher d466799871
fix: replace bigint literals with `BigInt` constructors (#27930)
This makes web3.js compatible with runtimes that don't understand bigint literals but _do_ understand `BigInt` constructors.
For whatever that's worth.
2022-09-19 18:31:16 -07:00
Justin Starry 07a83e0fbb
feat: add isAccountWritable and isAccountSigner to MessageV0 (#27808) 2022-09-15 18:31:43 +00:00
Justin Starry e6687b89e6
chore: fix flakey partialSign test (#27770) 2022-09-13 20:16:30 +00:00
Justin Starry afe1cfe94a
fix: replace computed max u64 constant with literal (#27765) 2022-09-13 19:37:40 +00:00
Justin Starry 8bb0acc4c6
chore: remove failing request units test (#27735) 2022-09-12 23:18:29 +00:00
Justin Starry e42a39024d
feat: add source field to parsed account key responses (#27702) 2022-09-09 21:06:54 +00:00
Justin Starry 080f085cb8
fix: ensure that Keypair.secretKey is a Uint8Array (#27700) 2022-09-09 16:31:18 -04:00
Justin Starry f8b5b517d2
fix: replace `TransactionMessage` `accountKeys` field with `payerKey` (#27653)
fix: replace TransactionMessage accountKeys field with payerKey
2022-09-07 18:11:24 -04:00
Steven Luscher 6bc04b5e3a
fix: replace js-sha3 with `@noble/hashes/sha3` (#27630) 2022-09-06 22:38:11 -07:00
Steven Luscher 466e9948bf
feat: added `authorizeWithSeed` to the vote program in web3.js (#27627)
* fix: recursively size variable size structs in your buffer layouts

* feat: added `authorizeWithSeed` to the vote program in web3.js
2022-09-06 22:37:43 -07:00
Justin Starry 204f272412
feat: support versioned txs in `sendTransaction` and `simulateTransaction` (#27528)
* feat: support versioned txs in sendTransaction and simulateTransaction

* chore: add docs for simulation config parameters
2022-09-06 23:53:42 -04:00
Justin Starry 9f81d27db8
feat: add `TransactionMessage` class (#27526)
feat: implement message v0 decompilation
2022-09-07 03:51:52 +00:00
Justin Starry 3374f41201
feat: implement message v0 compilation (#27524)
* feat: add PublicKey.unique method for tests

* feat: add MessageAccountKeys class

* feat: add CompiledKeys class for message compilation

* feat: implement message compilation using CompiledKeys
2022-09-06 23:43:22 -04:00
Justin Starry da7e88fc41
fix: add compute units to jsonrpc parser (#27554) 2022-09-01 18:18:43 +00:00
Justin Starry 292b2a1bfe
feat: update `Connection` to support versioned transactions (#27068)
feat: update Connection to support versioned transactions
2022-08-31 08:46:24 -04:00
Justin Starry ada493f607
feat: add VersionedMessage.deserializeMessageVersion utility function (#27415) 2022-08-29 21:20:16 +01:00
Steven Luscher 60f3dc5f72
fix: replace tweetnacl impl
* Install `@noble/ed25519` and create a shim

* Replace `tweetnacl` with `@noble/ed25519` in `Account` class

* Replace `tweetnacl` with `@noble/ed25519` in `Keypair` class

* Replace `tweetnacl` with `@noble/ed25519` in `PublicKey` class

* Replace `tweetnacl` with `@noble/ed25519` in `Ed25519Program` class

* Replace `tweetnacl` with `@noble/ed25519` in `Transaction` class

* Replace `tweetnacl` with `@noble/ed25519` in versioned `Transaction` class

* Remove `tweetnacl` from project

* Damnit, typedoc.
2022-08-28 12:11:34 -07:00
Steven Luscher 1a836ab4af
[web3.js] Replace sha256 and secp256k1 impls (#27390)
* fix: replace `@ethersproject/sha2` with `@noble/hashes/sha256`

* fix: replace `secp256k1` with `@noble/secp256k1`
2022-08-25 13:34:11 -07:00
Justin Starry 1ccfc65a52
feat: add support for creating version 0 transactions (#27142)
* feat: add support for version 0 transactions

* chore: feedback

* chore: update VersionedMessage type

* chore: use literals for version getter

* chore: fix lint error

* chore: switch to VersionedMessage.deserialize
2022-08-25 15:42:54 +02:00
Steven Luscher 5975176af7
[web3.js] Eliminate dependency on `URL` class (#27349)
* fix: `makeWebsocketUrl` no longer depends on the `URL` class
* fix: `Connection` no longer relies on the `URL` class
* fix: remove dependency on `react-native-url-polyfill`
2022-08-24 11:02:40 -07:00
Andrew Schonfeld 4b8ab4e65d
VoteProgram.safeWithdraw function to safeguard against accidental vote account closures (#26586)
feat: safe withdraw function

Co-authored-by: aschonfeld <andrew@proofofalpha.io>
2022-08-17 00:22:38 +02:00
Justin Starry dcef8ec100
feat: add getAddressLookupTable method to Connection (#27127) 2022-08-14 10:11:49 +00:00
Justin Starry 8e30dbbbf2 chore: restructure utils code 2022-08-12 17:11:51 +01:00
Justin Starry 52dc24abfb chore: restructure program files 2022-08-12 17:11:51 +01:00
Athar Mohammad ce337e009d
feat(web3.js): add support for get stake minimum delegation (#26682) 2022-07-22 01:02:49 -07:00
Antematter e3c9c58032
feat: added web3 bindings for Address Lookup Table Program instructions (#26469)
* feat: added web3 bindings for Address Lookup Table Program

* fix: refactoring + addresses PR comments

* fix: typos fixed and minor refactoring

* add lookup table instruction decoding support + fixes recent slot serialization bug

* export lookup table program

* linting

* fix: type annotations

* add tests cases for address lookup table program

* fix: alloc encoding buffer properly for seq layouts

* fix: typedoc issue

Co-authored-by: Antematter <hello@antematter.io>
Co-authored-by: Muhammad Saad <msaadahmed039@gmail.com>
Co-authored-by: Justin Starry <justin@solana.com>
2022-07-13 20:19:51 +01:00
Athar Mohammad d0d3ad7166
Support for returnData in simulate transaction (#26499)
feat(web3.js): add Support for returnData in simulate transaction
2022-07-12 14:07:17 +02:00