ox 0.8.9 → 0.9.1
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/CHANGELOG.md +19 -0
- package/_cjs/core/AbiEvent.js +1 -1
- package/_cjs/core/AbiEvent.js.map +1 -1
- package/_cjs/core/AbiItem.js +1 -1
- package/_cjs/core/AbiItem.js.map +1 -1
- package/_cjs/core/AbiParameters.js +4 -4
- package/_cjs/core/AbiParameters.js.map +1 -1
- package/_cjs/core/Authorization.js.map +1 -1
- package/_cjs/core/Blobs.js +1 -1
- package/_cjs/core/Blobs.js.map +1 -1
- package/_cjs/core/Block.js.map +1 -1
- package/_cjs/core/Bytes.js +1 -1
- package/_cjs/core/Bytes.js.map +1 -1
- package/_cjs/core/ContractAddress.js.map +1 -1
- package/_cjs/core/HdKey.js.map +1 -1
- package/_cjs/core/Hex.js +1 -1
- package/_cjs/core/Hex.js.map +1 -1
- package/_cjs/core/Keystore.js.map +1 -1
- package/_cjs/core/Mnemonic.js +2 -2
- package/_cjs/core/Mnemonic.js.map +1 -1
- package/_cjs/core/P256.js +1 -1
- package/_cjs/core/P256.js.map +1 -1
- package/_cjs/core/Provider.js.map +1 -1
- package/_cjs/core/PublicKey.js +1 -1
- package/_cjs/core/PublicKey.js.map +1 -1
- package/_cjs/core/RpcTransport.js +1 -1
- package/_cjs/core/RpcTransport.js.map +1 -1
- package/_cjs/core/Secp256k1.js +1 -1
- package/_cjs/core/Secp256k1.js.map +1 -1
- package/_cjs/core/Signature.js.map +1 -1
- package/_cjs/core/Siwe.js +4 -4
- package/_cjs/core/Siwe.js.map +1 -1
- package/_cjs/core/Transaction.js.map +1 -1
- package/_cjs/core/TransactionEnvelope.js.map +1 -1
- package/_cjs/core/TransactionEnvelopeEip1559.js.map +1 -1
- package/_cjs/core/TransactionEnvelopeEip2930.js.map +1 -1
- package/_cjs/core/TransactionEnvelopeEip4844.js.map +1 -1
- package/_cjs/core/TransactionEnvelopeEip7702.js.map +1 -1
- package/_cjs/core/TransactionEnvelopeLegacy.js.map +1 -1
- package/_cjs/core/TransactionReceipt.js.map +1 -1
- package/_cjs/core/TypedData.js +3 -3
- package/_cjs/core/TypedData.js.map +1 -1
- package/_cjs/core/WebAuthnP256.js +1 -1
- package/_cjs/core/WebAuthnP256.js.map +1 -1
- package/_cjs/core/WebCryptoP256.js.map +1 -1
- package/_cjs/core/internal/abiParameters.js +4 -4
- package/_cjs/core/internal/abiParameters.js.map +1 -1
- package/_cjs/core/internal/promise.js.map +1 -1
- package/_cjs/erc4337/UserOperation.js.map +1 -1
- package/_cjs/erc6492/{WrappedSignature.js → SignatureErc6492.js} +9 -11
- package/_cjs/erc6492/SignatureErc6492.js.map +1 -0
- package/_cjs/erc6492/index.js +2 -2
- package/_cjs/erc8010/SignatureErc8010.js +93 -0
- package/_cjs/erc8010/SignatureErc8010.js.map +1 -0
- package/_cjs/erc8010/index.js +5 -0
- package/_cjs/erc8010/index.js.map +1 -0
- package/_cjs/index.docs.js +1 -0
- package/_cjs/index.docs.js.map +1 -1
- package/_cjs/index.js +6 -6
- package/_cjs/index.js.map +1 -1
- package/_cjs/trusted-setups/internal/paths.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/core/AbiEvent.js +1 -1
- package/_esm/core/AbiEvent.js.map +1 -1
- package/_esm/core/AbiItem.js +1 -1
- package/_esm/core/AbiItem.js.map +1 -1
- package/_esm/core/AbiParameters.js +4 -4
- package/_esm/core/AbiParameters.js.map +1 -1
- package/_esm/core/Authorization.js.map +1 -1
- package/_esm/core/Blobs.js +1 -1
- package/_esm/core/Blobs.js.map +1 -1
- package/_esm/core/Block.js.map +1 -1
- package/_esm/core/Bytes.js +1 -1
- package/_esm/core/Bytes.js.map +1 -1
- package/_esm/core/ContractAddress.js.map +1 -1
- package/_esm/core/HdKey.js.map +1 -1
- package/_esm/core/Hex.js +1 -1
- package/_esm/core/Hex.js.map +1 -1
- package/_esm/core/Keystore.js +3 -2
- package/_esm/core/Keystore.js.map +1 -1
- package/_esm/core/Mnemonic.js +1 -1
- package/_esm/core/Mnemonic.js.map +1 -1
- package/_esm/core/P256.js +1 -1
- package/_esm/core/P256.js.map +1 -1
- package/_esm/core/Provider.js.map +1 -1
- package/_esm/core/PublicKey.js +1 -1
- package/_esm/core/PublicKey.js.map +1 -1
- package/_esm/core/RpcTransport.js +1 -1
- package/_esm/core/RpcTransport.js.map +1 -1
- package/_esm/core/Secp256k1.js +1 -1
- package/_esm/core/Secp256k1.js.map +1 -1
- package/_esm/core/Signature.js.map +1 -1
- package/_esm/core/Siwe.js +4 -4
- package/_esm/core/Siwe.js.map +1 -1
- package/_esm/core/Transaction.js.map +1 -1
- package/_esm/core/TransactionEnvelope.js.map +1 -1
- package/_esm/core/TransactionEnvelopeEip1559.js.map +1 -1
- package/_esm/core/TransactionEnvelopeEip2930.js.map +1 -1
- package/_esm/core/TransactionEnvelopeEip4844.js.map +1 -1
- package/_esm/core/TransactionEnvelopeEip7702.js.map +1 -1
- package/_esm/core/TransactionEnvelopeLegacy.js.map +1 -1
- package/_esm/core/TransactionReceipt.js.map +1 -1
- package/_esm/core/TypedData.js +3 -3
- package/_esm/core/TypedData.js.map +1 -1
- package/_esm/core/WebAuthnP256.js +1 -1
- package/_esm/core/WebAuthnP256.js.map +1 -1
- package/_esm/core/WebCryptoP256.js.map +1 -1
- package/_esm/core/internal/abiParameters.js +4 -4
- package/_esm/core/internal/abiParameters.js.map +1 -1
- package/_esm/core/internal/promise.js.map +1 -1
- package/_esm/erc4337/UserOperation.js.map +1 -1
- package/_esm/erc6492/{WrappedSignature.js → SignatureErc6492.js} +18 -20
- package/_esm/erc6492/SignatureErc6492.js.map +1 -0
- package/_esm/erc6492/index.js +3 -3
- package/_esm/erc8010/SignatureErc8010.js +182 -0
- package/_esm/erc8010/SignatureErc8010.js.map +1 -0
- package/_esm/erc8010/index.js +40 -0
- package/_esm/erc8010/index.js.map +1 -0
- package/_esm/index.docs.js +2 -0
- package/_esm/index.docs.js.map +1 -1
- package/_esm/index.js +236 -236
- package/_esm/index.js.map +1 -1
- package/_esm/trusted-setups/internal/paths.js +1 -0
- package/_esm/trusted-setups/internal/paths.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/core/AbiEvent.d.ts +1 -2
- package/_types/core/AbiEvent.d.ts.map +1 -1
- package/_types/core/AbiParameters.d.ts.map +1 -1
- package/_types/core/Authorization.d.ts +1 -1
- package/_types/core/Authorization.d.ts.map +1 -1
- package/_types/core/Blobs.d.ts +1 -1
- package/_types/core/Blobs.d.ts.map +1 -1
- package/_types/core/Block.d.ts +1 -1
- package/_types/core/Block.d.ts.map +1 -1
- package/_types/core/Bytes.d.ts.map +1 -1
- package/_types/core/ContractAddress.d.ts +1 -1
- package/_types/core/ContractAddress.d.ts.map +1 -1
- package/_types/core/HdKey.d.ts +1 -1
- package/_types/core/HdKey.d.ts.map +1 -1
- package/_types/core/Hex.d.ts.map +1 -1
- package/_types/core/Keystore.d.ts.map +1 -1
- package/_types/core/Mnemonic.d.ts +1 -1
- package/_types/core/Mnemonic.d.ts.map +1 -1
- package/_types/core/P256.d.ts.map +1 -1
- package/_types/core/Provider.d.ts +2 -2
- package/_types/core/Provider.d.ts.map +1 -1
- package/_types/core/PublicKey.d.ts.map +1 -1
- package/_types/core/RpcRequest.d.ts +1 -1
- package/_types/core/RpcRequest.d.ts.map +1 -1
- package/_types/core/RpcTransport.d.ts +2 -2
- package/_types/core/RpcTransport.d.ts.map +1 -1
- package/_types/core/Secp256k1.d.ts +1 -1
- package/_types/core/Secp256k1.d.ts.map +1 -1
- package/_types/core/Signature.d.ts.map +1 -1
- package/_types/core/Siwe.d.ts.map +1 -1
- package/_types/core/Transaction.d.ts +1 -2
- package/_types/core/Transaction.d.ts.map +1 -1
- package/_types/core/TransactionEnvelope.d.ts.map +1 -1
- package/_types/core/TransactionEnvelopeEip1559.d.ts +1 -1
- package/_types/core/TransactionEnvelopeEip1559.d.ts.map +1 -1
- package/_types/core/TransactionEnvelopeEip2930.d.ts +1 -1
- package/_types/core/TransactionEnvelopeEip2930.d.ts.map +1 -1
- package/_types/core/TransactionEnvelopeEip4844.d.ts +1 -1
- package/_types/core/TransactionEnvelopeEip4844.d.ts.map +1 -1
- package/_types/core/TransactionEnvelopeEip7702.d.ts +1 -3
- package/_types/core/TransactionEnvelopeEip7702.d.ts.map +1 -1
- package/_types/core/TransactionEnvelopeLegacy.d.ts +1 -1
- package/_types/core/TransactionEnvelopeLegacy.d.ts.map +1 -1
- package/_types/core/TransactionReceipt.d.ts +1 -1
- package/_types/core/TransactionReceipt.d.ts.map +1 -1
- package/_types/core/TypedData.d.ts +1 -1
- package/_types/core/TypedData.d.ts.map +1 -1
- package/_types/core/WebAuthnP256.d.ts +2 -2
- package/_types/core/WebAuthnP256.d.ts.map +1 -1
- package/_types/core/WebCryptoP256.d.ts +1 -1
- package/_types/core/WebCryptoP256.d.ts.map +1 -1
- package/_types/core/internal/abiParameters.d.ts +1 -1
- package/_types/core/internal/abiParameters.d.ts.map +1 -1
- package/_types/core/internal/promise.d.ts.map +1 -1
- package/_types/core/internal/register.d.ts +1 -2
- package/_types/core/internal/register.d.ts.map +1 -1
- package/_types/erc4337/UserOperation.d.ts +1 -1
- package/_types/erc4337/UserOperation.d.ts.map +1 -1
- package/_types/erc6492/{WrappedSignature.d.ts → SignatureErc6492.d.ts} +28 -26
- package/_types/erc6492/SignatureErc6492.d.ts.map +1 -0
- package/_types/erc6492/index.d.ts +3 -3
- package/_types/erc8010/SignatureErc8010.d.ts +138 -0
- package/_types/erc8010/SignatureErc8010.d.ts.map +1 -0
- package/_types/erc8010/index.d.ts +42 -0
- package/_types/erc8010/index.d.ts.map +1 -0
- package/_types/index.d.ts +237 -237
- package/_types/index.d.ts.map +1 -1
- package/_types/index.docs.d.ts +1 -0
- package/_types/index.docs.d.ts.map +1 -1
- package/_types/trusted-setups/internal/paths.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/core/AbiEvent.ts +3 -4
- package/core/AbiItem.ts +1 -1
- package/core/AbiParameters.ts +4 -4
- package/core/Authorization.ts +1 -1
- package/core/Blobs.ts +1 -1
- package/core/Block.ts +1 -1
- package/core/Bytes.ts +1 -1
- package/core/ContractAddress.ts +1 -1
- package/core/HdKey.ts +1 -1
- package/core/Hex.ts +1 -1
- package/core/Keystore.ts +3 -2
- package/core/Mnemonic.ts +1 -1
- package/core/P256.ts +1 -1
- package/core/Provider.ts +2 -2
- package/core/PublicKey.ts +2 -2
- package/core/RpcRequest.ts +1 -1
- package/core/RpcTransport.ts +3 -3
- package/core/Secp256k1.ts +2 -2
- package/core/Signature.ts +1 -1
- package/core/Siwe.ts +4 -5
- package/core/Transaction.ts +1 -2
- package/core/TransactionEnvelope.ts +1 -1
- package/core/TransactionEnvelopeEip1559.ts +3 -3
- package/core/TransactionEnvelopeEip2930.ts +3 -3
- package/core/TransactionEnvelopeEip4844.ts +5 -5
- package/core/TransactionEnvelopeEip7702.ts +6 -5
- package/core/TransactionEnvelopeLegacy.ts +3 -3
- package/core/TransactionReceipt.ts +1 -1
- package/core/TypedData.ts +4 -4
- package/core/WebAuthnP256.ts +2 -2
- package/core/WebCryptoP256.ts +1 -1
- package/core/internal/abiParameters.ts +5 -5
- package/core/internal/promise.ts +3 -1
- package/core/internal/register.ts +1 -2
- package/erc4337/UserOperation.ts +1 -1
- package/erc6492/SignatureErc6492/package.json +6 -0
- package/erc6492/{WrappedSignature.ts → SignatureErc6492.ts} +31 -30
- package/erc6492/index.ts +3 -3
- package/erc8010/SignatureErc8010/package.json +6 -0
- package/erc8010/SignatureErc8010.ts +227 -0
- package/erc8010/index.ts +43 -0
- package/erc8010/package.json +6 -0
- package/index.docs.ts +2 -0
- package/index.ts +237 -261
- package/package.json +15 -5
- package/trusted-setups/internal/paths.ts +1 -0
- package/version.ts +1 -1
- package/_cjs/erc6492/WrappedSignature.js.map +0 -1
- package/_esm/erc6492/WrappedSignature.js.map +0 -1
- package/_types/erc6492/WrappedSignature.d.ts.map +0 -1
- package/erc6492/WrappedSignature/package.json +0 -6
package/index.ts
CHANGED
|
@@ -1400,14 +1400,16 @@ export * as Ed25519 from './core/Ed25519.js'
|
|
|
1400
1400
|
export * as Ens from './core/Ens.js'
|
|
1401
1401
|
|
|
1402
1402
|
export * as Errors from './core/Errors.js'
|
|
1403
|
-
|
|
1403
|
+
/**
|
|
1404
|
+
* @category Execution Spec
|
|
1405
|
+
*/
|
|
1406
|
+
export * as Fee from './core/Fee.js'
|
|
1404
1407
|
/**
|
|
1405
1408
|
* Utilities & types for working with Filters as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/filter.yaml)
|
|
1406
1409
|
*
|
|
1407
1410
|
* @category Execution Spec
|
|
1408
1411
|
*/
|
|
1409
1412
|
export * as Filter from './core/Filter.js'
|
|
1410
|
-
|
|
1411
1413
|
/**
|
|
1412
1414
|
* Utility functions for hashing (keccak256, sha256, etc).
|
|
1413
1415
|
*
|
|
@@ -1422,7 +1424,6 @@ export * as Filter from './core/Filter.js'
|
|
|
1422
1424
|
* @category Crypto
|
|
1423
1425
|
*/
|
|
1424
1426
|
export * as Hash from './core/Hash.js'
|
|
1425
|
-
|
|
1426
1427
|
/**
|
|
1427
1428
|
* Utility functions for generating and working with [BIP-32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) HD Wallets.
|
|
1428
1429
|
*
|
|
@@ -1436,7 +1437,6 @@ export * as Hash from './core/Hash.js'
|
|
|
1436
1437
|
* @category Crypto
|
|
1437
1438
|
*/
|
|
1438
1439
|
export * as HdKey from './core/HdKey.js'
|
|
1439
|
-
|
|
1440
1440
|
/**
|
|
1441
1441
|
* A set of Ethereum-related utility functions for working with hexadecimal string values (e.g. `"0xdeadbeef"`).
|
|
1442
1442
|
*
|
|
@@ -1551,12 +1551,7 @@ export * as HdKey from './core/HdKey.js'
|
|
|
1551
1551
|
* @category Data
|
|
1552
1552
|
*/
|
|
1553
1553
|
export * as Hex from './core/Hex.js'
|
|
1554
|
-
|
|
1555
|
-
/**
|
|
1556
|
-
* @category Execution Spec
|
|
1557
|
-
*/
|
|
1558
|
-
export * as Fee from './core/Fee.js'
|
|
1559
|
-
|
|
1554
|
+
export type { Register } from './core/internal/register.js'
|
|
1560
1555
|
/**
|
|
1561
1556
|
* Utility functions for working with JSON (with support for `bigint`).
|
|
1562
1557
|
*
|
|
@@ -1590,7 +1585,6 @@ export * as Fee from './core/Fee.js'
|
|
|
1590
1585
|
* @category JSON
|
|
1591
1586
|
*/
|
|
1592
1587
|
export * as Json from './core/Json.js'
|
|
1593
|
-
|
|
1594
1588
|
/**
|
|
1595
1589
|
* Utilities & types for working with [Keystores](https://ethereum.org/en/developers/docs/data-structures-and-encoding/web3-secret-storage).
|
|
1596
1590
|
*
|
|
@@ -1654,7 +1648,6 @@ export * as Json from './core/Json.js'
|
|
|
1654
1648
|
* @category Crypto
|
|
1655
1649
|
*/
|
|
1656
1650
|
export * as Keystore from './core/Keystore.js'
|
|
1657
|
-
|
|
1658
1651
|
/**
|
|
1659
1652
|
* Utility functions for working with KZG Commitments.
|
|
1660
1653
|
*
|
|
@@ -1663,7 +1656,6 @@ export * as Keystore from './core/Keystore.js'
|
|
|
1663
1656
|
* @category Blobs (EIP-4844)
|
|
1664
1657
|
*/
|
|
1665
1658
|
export * as Kzg from './core/Kzg.js'
|
|
1666
|
-
|
|
1667
1659
|
/**
|
|
1668
1660
|
* Utilities & types for working with Logs as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/receipt.yaml)
|
|
1669
1661
|
*
|
|
@@ -1722,7 +1714,6 @@ export * as Kzg from './core/Kzg.js'
|
|
|
1722
1714
|
* @category Execution Spec
|
|
1723
1715
|
*/
|
|
1724
1716
|
export * as Log from './core/Log.js'
|
|
1725
|
-
|
|
1726
1717
|
/**
|
|
1727
1718
|
* Utility functions for generating and working with [BIP-39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) mnemonics.
|
|
1728
1719
|
*
|
|
@@ -1783,7 +1774,78 @@ export * as Log from './core/Log.js'
|
|
|
1783
1774
|
* @category Crypto
|
|
1784
1775
|
*/
|
|
1785
1776
|
export * as Mnemonic from './core/Mnemonic.js'
|
|
1786
|
-
|
|
1777
|
+
/**
|
|
1778
|
+
* Utility functions for [NIST P256](https://csrc.nist.gov/csrc/media/events/workshop-on-elliptic-curve-cryptography-standards/documents/papers/session6-adalier-mehmet.pdf) ECDSA cryptography.
|
|
1779
|
+
*
|
|
1780
|
+
* :::info
|
|
1781
|
+
*
|
|
1782
|
+
* The `P256` module is a friendly wrapper over [`@noble/curves/p256`](https://github.com/paulmillr/noble-curves), an **audited** implementation of [P256](https://www.secg.org/sec2-v2.pdf)
|
|
1783
|
+
*
|
|
1784
|
+
* :::
|
|
1785
|
+
*
|
|
1786
|
+
* @example
|
|
1787
|
+
* ### Computing a Random Private Key
|
|
1788
|
+
*
|
|
1789
|
+
* A random private key can be computed using {@link ox#P256.(randomPrivateKey:function)}:
|
|
1790
|
+
*
|
|
1791
|
+
* ```ts twoslash
|
|
1792
|
+
* import { P256 } from 'ox'
|
|
1793
|
+
*
|
|
1794
|
+
* const privateKey = P256.randomPrivateKey()
|
|
1795
|
+
* // @log: '0x...'
|
|
1796
|
+
* ```
|
|
1797
|
+
*
|
|
1798
|
+
* @example
|
|
1799
|
+
* ### Getting a Public Key
|
|
1800
|
+
*
|
|
1801
|
+
* A public key can be derived from a private key using {@link ox#P256.(getPublicKey:function)}:
|
|
1802
|
+
*
|
|
1803
|
+
* ```ts twoslash
|
|
1804
|
+
* import { P256 } from 'ox'
|
|
1805
|
+
*
|
|
1806
|
+
* const privateKey = P256.randomPrivateKey()
|
|
1807
|
+
*
|
|
1808
|
+
* const publicKey = P256.getPublicKey({ privateKey }) // [!code focus]
|
|
1809
|
+
* // @log: { x: 3251...5152n, y: 1251...5152n }
|
|
1810
|
+
* ```
|
|
1811
|
+
*
|
|
1812
|
+
* @example
|
|
1813
|
+
* ### Signing a Payload
|
|
1814
|
+
*
|
|
1815
|
+
* A payload can be signed using {@link ox#P256.(sign:function)}:
|
|
1816
|
+
*
|
|
1817
|
+
* ```ts twoslash
|
|
1818
|
+
* import { P256 } from 'ox'
|
|
1819
|
+
*
|
|
1820
|
+
* const privateKey = P256.randomPrivateKey()
|
|
1821
|
+
*
|
|
1822
|
+
* const signature = P256.sign({ payload: '0xdeadbeef', privateKey }) // [!code focus]
|
|
1823
|
+
* // @log: { r: 1251...5152n, s: 1251...5152n, yParity: 1 }
|
|
1824
|
+
* ```
|
|
1825
|
+
*
|
|
1826
|
+
* @example
|
|
1827
|
+
* ### Verifying a Signature
|
|
1828
|
+
*
|
|
1829
|
+
* A signature can be verified using {@link ox#P256.(verify:function)}:
|
|
1830
|
+
*
|
|
1831
|
+
* ```ts twoslash
|
|
1832
|
+
* import { P256 } from 'ox'
|
|
1833
|
+
*
|
|
1834
|
+
* const privateKey = P256.randomPrivateKey()
|
|
1835
|
+
* const publicKey = P256.getPublicKey({ privateKey })
|
|
1836
|
+
* const signature = P256.sign({ payload: '0xdeadbeef', privateKey })
|
|
1837
|
+
*
|
|
1838
|
+
* const isValid = P256.verify({ // [!code focus]
|
|
1839
|
+
* payload: '0xdeadbeef', // [!code focus]
|
|
1840
|
+
* publicKey, // [!code focus]
|
|
1841
|
+
* signature, // [!code focus]
|
|
1842
|
+
* }) // [!code focus]
|
|
1843
|
+
* // @log: true
|
|
1844
|
+
* ```
|
|
1845
|
+
*
|
|
1846
|
+
* @category Crypto
|
|
1847
|
+
*/
|
|
1848
|
+
export * as P256 from './core/P256.js'
|
|
1787
1849
|
/**
|
|
1788
1850
|
* Utilities & types for working with [EIP-191 Personal Messages](https://eips.ethereum.org/EIPS/eip-191#version-0x45-e)
|
|
1789
1851
|
*
|
|
@@ -1803,7 +1865,6 @@ export * as Mnemonic from './core/Mnemonic.js'
|
|
|
1803
1865
|
* @category Signed & Typed Data
|
|
1804
1866
|
*/
|
|
1805
1867
|
export * as PersonalMessage from './core/PersonalMessage.js'
|
|
1806
|
-
|
|
1807
1868
|
/**
|
|
1808
1869
|
* Utilities & types for working with [EIP-1193 Providers](https://eips.ethereum.org/EIPS/eip-1193)
|
|
1809
1870
|
*
|
|
@@ -1888,7 +1949,6 @@ export * as PersonalMessage from './core/PersonalMessage.js'
|
|
|
1888
1949
|
* @category Providers (EIP-1193)
|
|
1889
1950
|
*/
|
|
1890
1951
|
export * as Provider from './core/Provider.js'
|
|
1891
|
-
|
|
1892
1952
|
/**
|
|
1893
1953
|
* Utility functions for working with ECDSA public keys.
|
|
1894
1954
|
*
|
|
@@ -1929,9 +1989,6 @@ export * as Provider from './core/Provider.js'
|
|
|
1929
1989
|
* @category Crypto
|
|
1930
1990
|
*/
|
|
1931
1991
|
export * as PublicKey from './core/PublicKey.js'
|
|
1932
|
-
|
|
1933
|
-
export type { Register } from './core/internal/register.js'
|
|
1934
|
-
|
|
1935
1992
|
/**
|
|
1936
1993
|
* Utility functions for encoding and decoding [Recursive Length Prefix](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/) structures.
|
|
1937
1994
|
*
|
|
@@ -1950,13 +2007,6 @@ export type { Register } from './core/internal/register.js'
|
|
|
1950
2007
|
*/
|
|
1951
2008
|
export * as Rlp from './core/Rlp.js'
|
|
1952
2009
|
|
|
1953
|
-
/**
|
|
1954
|
-
* Utility types for working with Ethereum JSON-RPC namespaces & schemas.
|
|
1955
|
-
*
|
|
1956
|
-
* @category JSON-RPC
|
|
1957
|
-
*/
|
|
1958
|
-
export * as RpcSchema from './core/RpcSchema.js'
|
|
1959
|
-
|
|
1960
2010
|
/**
|
|
1961
2011
|
* Utility types & functions for working with [JSON-RPC 2.0 Requests](https://www.jsonrpc.org/specification#request_object) and Ethereum JSON-RPC methods as
|
|
1962
2012
|
* defined on the [Ethereum API specification](https://github.com/ethereum/execution-apis)
|
|
@@ -2074,7 +2124,12 @@ export * as RpcRequest from './core/RpcRequest.js'
|
|
|
2074
2124
|
* @category JSON-RPC
|
|
2075
2125
|
*/
|
|
2076
2126
|
export * as RpcResponse from './core/RpcResponse.js'
|
|
2077
|
-
|
|
2127
|
+
/**
|
|
2128
|
+
* Utility types for working with Ethereum JSON-RPC namespaces & schemas.
|
|
2129
|
+
*
|
|
2130
|
+
* @category JSON-RPC
|
|
2131
|
+
*/
|
|
2132
|
+
export * as RpcSchema from './core/RpcSchema.js'
|
|
2078
2133
|
/**
|
|
2079
2134
|
* Utility functions for working with JSON-RPC Transports.
|
|
2080
2135
|
*
|
|
@@ -2100,7 +2155,6 @@ export * as RpcResponse from './core/RpcResponse.js'
|
|
|
2100
2155
|
* @category JSON-RPC
|
|
2101
2156
|
*/
|
|
2102
2157
|
export * as RpcTransport from './core/RpcTransport.js'
|
|
2103
|
-
|
|
2104
2158
|
/**
|
|
2105
2159
|
* Utility functions for [secp256k1](https://www.secg.org/sec2-v2.pdf) ECDSA cryptography.
|
|
2106
2160
|
*
|
|
@@ -2174,79 +2228,6 @@ export * as RpcTransport from './core/RpcTransport.js'
|
|
|
2174
2228
|
*/
|
|
2175
2229
|
export * as Secp256k1 from './core/Secp256k1.js'
|
|
2176
2230
|
|
|
2177
|
-
/**
|
|
2178
|
-
* Utility functions for [NIST P256](https://csrc.nist.gov/csrc/media/events/workshop-on-elliptic-curve-cryptography-standards/documents/papers/session6-adalier-mehmet.pdf) ECDSA cryptography.
|
|
2179
|
-
*
|
|
2180
|
-
* :::info
|
|
2181
|
-
*
|
|
2182
|
-
* The `P256` module is a friendly wrapper over [`@noble/curves/p256`](https://github.com/paulmillr/noble-curves), an **audited** implementation of [P256](https://www.secg.org/sec2-v2.pdf)
|
|
2183
|
-
*
|
|
2184
|
-
* :::
|
|
2185
|
-
*
|
|
2186
|
-
* @example
|
|
2187
|
-
* ### Computing a Random Private Key
|
|
2188
|
-
*
|
|
2189
|
-
* A random private key can be computed using {@link ox#P256.(randomPrivateKey:function)}:
|
|
2190
|
-
*
|
|
2191
|
-
* ```ts twoslash
|
|
2192
|
-
* import { P256 } from 'ox'
|
|
2193
|
-
*
|
|
2194
|
-
* const privateKey = P256.randomPrivateKey()
|
|
2195
|
-
* // @log: '0x...'
|
|
2196
|
-
* ```
|
|
2197
|
-
*
|
|
2198
|
-
* @example
|
|
2199
|
-
* ### Getting a Public Key
|
|
2200
|
-
*
|
|
2201
|
-
* A public key can be derived from a private key using {@link ox#P256.(getPublicKey:function)}:
|
|
2202
|
-
*
|
|
2203
|
-
* ```ts twoslash
|
|
2204
|
-
* import { P256 } from 'ox'
|
|
2205
|
-
*
|
|
2206
|
-
* const privateKey = P256.randomPrivateKey()
|
|
2207
|
-
*
|
|
2208
|
-
* const publicKey = P256.getPublicKey({ privateKey }) // [!code focus]
|
|
2209
|
-
* // @log: { x: 3251...5152n, y: 1251...5152n }
|
|
2210
|
-
* ```
|
|
2211
|
-
*
|
|
2212
|
-
* @example
|
|
2213
|
-
* ### Signing a Payload
|
|
2214
|
-
*
|
|
2215
|
-
* A payload can be signed using {@link ox#P256.(sign:function)}:
|
|
2216
|
-
*
|
|
2217
|
-
* ```ts twoslash
|
|
2218
|
-
* import { P256 } from 'ox'
|
|
2219
|
-
*
|
|
2220
|
-
* const privateKey = P256.randomPrivateKey()
|
|
2221
|
-
*
|
|
2222
|
-
* const signature = P256.sign({ payload: '0xdeadbeef', privateKey }) // [!code focus]
|
|
2223
|
-
* // @log: { r: 1251...5152n, s: 1251...5152n, yParity: 1 }
|
|
2224
|
-
* ```
|
|
2225
|
-
*
|
|
2226
|
-
* @example
|
|
2227
|
-
* ### Verifying a Signature
|
|
2228
|
-
*
|
|
2229
|
-
* A signature can be verified using {@link ox#P256.(verify:function)}:
|
|
2230
|
-
*
|
|
2231
|
-
* ```ts twoslash
|
|
2232
|
-
* import { P256 } from 'ox'
|
|
2233
|
-
*
|
|
2234
|
-
* const privateKey = P256.randomPrivateKey()
|
|
2235
|
-
* const publicKey = P256.getPublicKey({ privateKey })
|
|
2236
|
-
* const signature = P256.sign({ payload: '0xdeadbeef', privateKey })
|
|
2237
|
-
*
|
|
2238
|
-
* const isValid = P256.verify({ // [!code focus]
|
|
2239
|
-
* payload: '0xdeadbeef', // [!code focus]
|
|
2240
|
-
* publicKey, // [!code focus]
|
|
2241
|
-
* signature, // [!code focus]
|
|
2242
|
-
* }) // [!code focus]
|
|
2243
|
-
* // @log: true
|
|
2244
|
-
* ```
|
|
2245
|
-
*
|
|
2246
|
-
* @category Crypto
|
|
2247
|
-
*/
|
|
2248
|
-
export * as P256 from './core/P256.js'
|
|
2249
|
-
|
|
2250
2231
|
/**
|
|
2251
2232
|
* Utility functions for working with ECDSA signatures.
|
|
2252
2233
|
*
|
|
@@ -2446,162 +2427,6 @@ export * as Transaction from './core/Transaction.js'
|
|
|
2446
2427
|
* @category Transaction Envelopes
|
|
2447
2428
|
*/
|
|
2448
2429
|
export * as TransactionEnvelope from './core/TransactionEnvelope.js'
|
|
2449
|
-
|
|
2450
|
-
/**
|
|
2451
|
-
* Utility functions for working
|
|
2452
|
-
* with **Legacy Transaction Envelopes**.
|
|
2453
|
-
*
|
|
2454
|
-
* @example
|
|
2455
|
-
* ### Instantiating
|
|
2456
|
-
*
|
|
2457
|
-
* Transaction Envelopes can be instantiated using {@link ox#TransactionEnvelopeLegacy.(from:function)}:
|
|
2458
|
-
*
|
|
2459
|
-
* ```ts twoslash
|
|
2460
|
-
* import { TransactionEnvelopeLegacy, Value } from 'ox'
|
|
2461
|
-
*
|
|
2462
|
-
* const envelope = TransactionEnvelopeLegacy.from({
|
|
2463
|
-
* gasPrice: Value.fromGwei('10'),
|
|
2464
|
-
* to: '0x0000000000000000000000000000000000000000',
|
|
2465
|
-
* value: Value.fromEther('1'),
|
|
2466
|
-
* })
|
|
2467
|
-
* ```
|
|
2468
|
-
*
|
|
2469
|
-
* * @example
|
|
2470
|
-
* ### Signing
|
|
2471
|
-
*
|
|
2472
|
-
* Transaction Envelopes can be signed using {@link ox#TransactionEnvelopeLegacy.(getSignPayload:function)} and a signing function such as {@link ox#Secp256k1.(sign:function)} or {@link ox#P256.(sign:function)}:
|
|
2473
|
-
*
|
|
2474
|
-
* ```ts twoslash
|
|
2475
|
-
* // @noErrors
|
|
2476
|
-
* import { Secp256k1, TransactionEnvelopeLegacy } from 'ox'
|
|
2477
|
-
*
|
|
2478
|
-
* const envelope = TransactionEnvelopeLegacy.from({
|
|
2479
|
-
* nonce: 0n,
|
|
2480
|
-
* gasPrice: 1000000000n,
|
|
2481
|
-
* gas: 21000n,
|
|
2482
|
-
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
2483
|
-
* value: 1000000000000000000n,
|
|
2484
|
-
* })
|
|
2485
|
-
*
|
|
2486
|
-
* const signature = Secp256k1.sign({ // [!code focus]
|
|
2487
|
-
* payload: TransactionEnvelopeLegacy.getSignPayload(envelope), // [!code focus]
|
|
2488
|
-
* privateKey: '0x...' // [!code focus]
|
|
2489
|
-
* }) // [!code focus]
|
|
2490
|
-
*
|
|
2491
|
-
* const envelope_signed = TransactionEnvelopeLegacy.from(envelope, { signature })
|
|
2492
|
-
* ```
|
|
2493
|
-
*
|
|
2494
|
-
* @example
|
|
2495
|
-
* ### Serializing
|
|
2496
|
-
*
|
|
2497
|
-
* Transaction Envelopes can be serialized using {@link ox#TransactionEnvelopeLegacy.(serialize:function)}:
|
|
2498
|
-
*
|
|
2499
|
-
* ```ts twoslash
|
|
2500
|
-
* import { TransactionEnvelopeLegacy, Value } from 'ox'
|
|
2501
|
-
*
|
|
2502
|
-
* const envelope = TransactionEnvelopeLegacy.from({
|
|
2503
|
-
* chainId: 1,
|
|
2504
|
-
* gasPrice: Value.fromGwei('10'),
|
|
2505
|
-
* to: '0x0000000000000000000000000000000000000000',
|
|
2506
|
-
* value: Value.fromEther('1'),
|
|
2507
|
-
* })
|
|
2508
|
-
*
|
|
2509
|
-
* const serialized = TransactionEnvelopeLegacy.serialize(envelope) // [!code focus]
|
|
2510
|
-
* ```
|
|
2511
|
-
*
|
|
2512
|
-
* @example
|
|
2513
|
-
* ### Sending
|
|
2514
|
-
*
|
|
2515
|
-
* We can send a Transaction Envelope to the network by serializing the signed envelope with `.serialize`, and then broadcasting it over JSON-RPC with `eth_sendRawTransaction`.
|
|
2516
|
-
*
|
|
2517
|
-
* In this example, we will use {@link ox#RpcTransport.(fromHttp:function)} to broadcast a `eth_sendRawTransaction` request over HTTP JSON-RPC.
|
|
2518
|
-
*
|
|
2519
|
-
* ```ts twoslash
|
|
2520
|
-
* import { RpcTransport, TransactionEnvelopeLegacy, Secp256k1, Value } from 'ox'
|
|
2521
|
-
*
|
|
2522
|
-
* // Construct the Envelope.
|
|
2523
|
-
* const envelope = TransactionEnvelopeLegacy.from({
|
|
2524
|
-
* chainId: 1,
|
|
2525
|
-
* gasPrice: Value.fromGwei('10'),
|
|
2526
|
-
* nonce: 69n,
|
|
2527
|
-
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
2528
|
-
* value: Value.fromEther('1.5'),
|
|
2529
|
-
* })
|
|
2530
|
-
*
|
|
2531
|
-
* // Sign over the Envelope.
|
|
2532
|
-
* const signature = Secp256k1.sign({
|
|
2533
|
-
* payload: TransactionEnvelopeLegacy.getSignPayload(envelope),
|
|
2534
|
-
* privateKey: '0x...',
|
|
2535
|
-
* })
|
|
2536
|
-
*
|
|
2537
|
-
* // Serialize the Envelope with the Signature. // [!code focus]
|
|
2538
|
-
* const serialized = TransactionEnvelopeLegacy.serialize(envelope, { // [!code focus]
|
|
2539
|
-
* signature // [!code focus]
|
|
2540
|
-
* }) // [!code focus]
|
|
2541
|
-
*
|
|
2542
|
-
* // Broadcast the Envelope with `eth_sendRawTransaction`. // [!code focus]
|
|
2543
|
-
* const transport = RpcTransport.fromHttp('https://1.rpc.thirdweb.com') // [!code focus]
|
|
2544
|
-
* const hash = await transport.request({ // [!code focus]
|
|
2545
|
-
* method: 'eth_sendRawTransaction', // [!code focus]
|
|
2546
|
-
* params: [serialized], // [!code focus]
|
|
2547
|
-
* }) // [!code focus]
|
|
2548
|
-
* ```
|
|
2549
|
-
*
|
|
2550
|
-
* If you are interfacing with an RPC that supports `eth_sendTransaction`, you can also use
|
|
2551
|
-
* {@link ox#TransactionEnvelopeLegacy.(toRpc:function)} to convert an Envelope to an RPC-compatible format.
|
|
2552
|
-
* This means you can skip the ceremony of manually filling & signing the Transaction.
|
|
2553
|
-
*
|
|
2554
|
-
* ```ts twoslash
|
|
2555
|
-
* import 'ox/window'
|
|
2556
|
-
* import { Provider, TransactionEnvelopeLegacy, Value } from 'ox'
|
|
2557
|
-
*
|
|
2558
|
-
* const envelope = TransactionEnvelopeLegacy.from({
|
|
2559
|
-
* chainId: 1,
|
|
2560
|
-
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
2561
|
-
* value: Value.fromEther('1.5'),
|
|
2562
|
-
* })
|
|
2563
|
-
*
|
|
2564
|
-
* const envelope_rpc = TransactionEnvelopeLegacy.toRpc(envelope)
|
|
2565
|
-
*
|
|
2566
|
-
* const provider = Provider.from(window.ethereum)
|
|
2567
|
-
* const hash = await provider.request({
|
|
2568
|
-
* method: 'eth_sendTransaction',
|
|
2569
|
-
* params: [envelope_rpc],
|
|
2570
|
-
* })
|
|
2571
|
-
* ```
|
|
2572
|
-
*
|
|
2573
|
-
* @example
|
|
2574
|
-
* ### Computing Hashes
|
|
2575
|
-
*
|
|
2576
|
-
* Transaction Hashes can be computed using {@link ox#TransactionEnvelopeLegacy.(hash:function)}:
|
|
2577
|
-
*
|
|
2578
|
-
* ```ts twoslash
|
|
2579
|
-
* import { Secp256k1, TransactionEnvelopeLegacy } from 'ox'
|
|
2580
|
-
*
|
|
2581
|
-
* const envelope = TransactionEnvelopeLegacy.from({
|
|
2582
|
-
* chainId: 1,
|
|
2583
|
-
* nonce: 0n,
|
|
2584
|
-
* gasPrice: 1000000000n,
|
|
2585
|
-
* gas: 21000n,
|
|
2586
|
-
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
2587
|
-
* value: 1000000000000000000n,
|
|
2588
|
-
* data: '0x',
|
|
2589
|
-
* })
|
|
2590
|
-
*
|
|
2591
|
-
* const signature = Secp256k1.sign({
|
|
2592
|
-
* payload: TransactionEnvelopeLegacy.getSignPayload(envelope),
|
|
2593
|
-
* privateKey: '0x...'
|
|
2594
|
-
* })
|
|
2595
|
-
*
|
|
2596
|
-
* const envelope_signed = TransactionEnvelopeLegacy.from(envelope, { signature })
|
|
2597
|
-
*
|
|
2598
|
-
* const hash = TransactionEnvelopeLegacy.hash(envelope_signed) // [!code focus]
|
|
2599
|
-
* ```
|
|
2600
|
-
*
|
|
2601
|
-
* @category Transaction Envelopes
|
|
2602
|
-
*/
|
|
2603
|
-
export * as TransactionEnvelopeLegacy from './core/TransactionEnvelopeLegacy.js'
|
|
2604
|
-
|
|
2605
2430
|
/**
|
|
2606
2431
|
* Utility functions for working with [EIP-1559 Typed Transaction Envelopes](https://eips.ethereum.org/EIPS/eip-1559)
|
|
2607
2432
|
*
|
|
@@ -2768,7 +2593,6 @@ export * as TransactionEnvelopeLegacy from './core/TransactionEnvelopeLegacy.js'
|
|
|
2768
2593
|
* @category Transaction Envelopes
|
|
2769
2594
|
*/
|
|
2770
2595
|
export * as TransactionEnvelopeEip1559 from './core/TransactionEnvelopeEip1559.js'
|
|
2771
|
-
|
|
2772
2596
|
/**
|
|
2773
2597
|
* Utility functions for working with [EIP-2930 Typed Transaction Envelopes](https://eips.ethereum.org/EIPS/eip-2930)
|
|
2774
2598
|
*
|
|
@@ -2927,7 +2751,6 @@ export * as TransactionEnvelopeEip1559 from './core/TransactionEnvelopeEip1559.j
|
|
|
2927
2751
|
* @category Transaction Envelopes
|
|
2928
2752
|
*/
|
|
2929
2753
|
export * as TransactionEnvelopeEip2930 from './core/TransactionEnvelopeEip2930.js'
|
|
2930
|
-
|
|
2931
2754
|
/**
|
|
2932
2755
|
* Utility functions for working with [EIP-4844 Typed Transaction Envelopes](https://eips.ethereum.org/EIPS/eip-4844)
|
|
2933
2756
|
*
|
|
@@ -3111,7 +2934,6 @@ export * as TransactionEnvelopeEip2930 from './core/TransactionEnvelopeEip2930.j
|
|
|
3111
2934
|
* @category Transaction Envelopes
|
|
3112
2935
|
*/
|
|
3113
2936
|
export * as TransactionEnvelopeEip4844 from './core/TransactionEnvelopeEip4844.js'
|
|
3114
|
-
|
|
3115
2937
|
/**
|
|
3116
2938
|
* Utility functions for working with [EIP-7702 Typed Transaction Envelopes](https://eips.ethereum.org/EIPS/eip-7702)
|
|
3117
2939
|
*
|
|
@@ -3244,6 +3066,160 @@ export * as TransactionEnvelopeEip4844 from './core/TransactionEnvelopeEip4844.j
|
|
|
3244
3066
|
* @category Transaction Envelopes
|
|
3245
3067
|
*/
|
|
3246
3068
|
export * as TransactionEnvelopeEip7702 from './core/TransactionEnvelopeEip7702.js'
|
|
3069
|
+
/**
|
|
3070
|
+
* Utility functions for working
|
|
3071
|
+
* with **Legacy Transaction Envelopes**.
|
|
3072
|
+
*
|
|
3073
|
+
* @example
|
|
3074
|
+
* ### Instantiating
|
|
3075
|
+
*
|
|
3076
|
+
* Transaction Envelopes can be instantiated using {@link ox#TransactionEnvelopeLegacy.(from:function)}:
|
|
3077
|
+
*
|
|
3078
|
+
* ```ts twoslash
|
|
3079
|
+
* import { TransactionEnvelopeLegacy, Value } from 'ox'
|
|
3080
|
+
*
|
|
3081
|
+
* const envelope = TransactionEnvelopeLegacy.from({
|
|
3082
|
+
* gasPrice: Value.fromGwei('10'),
|
|
3083
|
+
* to: '0x0000000000000000000000000000000000000000',
|
|
3084
|
+
* value: Value.fromEther('1'),
|
|
3085
|
+
* })
|
|
3086
|
+
* ```
|
|
3087
|
+
*
|
|
3088
|
+
* * @example
|
|
3089
|
+
* ### Signing
|
|
3090
|
+
*
|
|
3091
|
+
* Transaction Envelopes can be signed using {@link ox#TransactionEnvelopeLegacy.(getSignPayload:function)} and a signing function such as {@link ox#Secp256k1.(sign:function)} or {@link ox#P256.(sign:function)}:
|
|
3092
|
+
*
|
|
3093
|
+
* ```ts twoslash
|
|
3094
|
+
* // @noErrors
|
|
3095
|
+
* import { Secp256k1, TransactionEnvelopeLegacy } from 'ox'
|
|
3096
|
+
*
|
|
3097
|
+
* const envelope = TransactionEnvelopeLegacy.from({
|
|
3098
|
+
* nonce: 0n,
|
|
3099
|
+
* gasPrice: 1000000000n,
|
|
3100
|
+
* gas: 21000n,
|
|
3101
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
3102
|
+
* value: 1000000000000000000n,
|
|
3103
|
+
* })
|
|
3104
|
+
*
|
|
3105
|
+
* const signature = Secp256k1.sign({ // [!code focus]
|
|
3106
|
+
* payload: TransactionEnvelopeLegacy.getSignPayload(envelope), // [!code focus]
|
|
3107
|
+
* privateKey: '0x...' // [!code focus]
|
|
3108
|
+
* }) // [!code focus]
|
|
3109
|
+
*
|
|
3110
|
+
* const envelope_signed = TransactionEnvelopeLegacy.from(envelope, { signature })
|
|
3111
|
+
* ```
|
|
3112
|
+
*
|
|
3113
|
+
* @example
|
|
3114
|
+
* ### Serializing
|
|
3115
|
+
*
|
|
3116
|
+
* Transaction Envelopes can be serialized using {@link ox#TransactionEnvelopeLegacy.(serialize:function)}:
|
|
3117
|
+
*
|
|
3118
|
+
* ```ts twoslash
|
|
3119
|
+
* import { TransactionEnvelopeLegacy, Value } from 'ox'
|
|
3120
|
+
*
|
|
3121
|
+
* const envelope = TransactionEnvelopeLegacy.from({
|
|
3122
|
+
* chainId: 1,
|
|
3123
|
+
* gasPrice: Value.fromGwei('10'),
|
|
3124
|
+
* to: '0x0000000000000000000000000000000000000000',
|
|
3125
|
+
* value: Value.fromEther('1'),
|
|
3126
|
+
* })
|
|
3127
|
+
*
|
|
3128
|
+
* const serialized = TransactionEnvelopeLegacy.serialize(envelope) // [!code focus]
|
|
3129
|
+
* ```
|
|
3130
|
+
*
|
|
3131
|
+
* @example
|
|
3132
|
+
* ### Sending
|
|
3133
|
+
*
|
|
3134
|
+
* We can send a Transaction Envelope to the network by serializing the signed envelope with `.serialize`, and then broadcasting it over JSON-RPC with `eth_sendRawTransaction`.
|
|
3135
|
+
*
|
|
3136
|
+
* In this example, we will use {@link ox#RpcTransport.(fromHttp:function)} to broadcast a `eth_sendRawTransaction` request over HTTP JSON-RPC.
|
|
3137
|
+
*
|
|
3138
|
+
* ```ts twoslash
|
|
3139
|
+
* import { RpcTransport, TransactionEnvelopeLegacy, Secp256k1, Value } from 'ox'
|
|
3140
|
+
*
|
|
3141
|
+
* // Construct the Envelope.
|
|
3142
|
+
* const envelope = TransactionEnvelopeLegacy.from({
|
|
3143
|
+
* chainId: 1,
|
|
3144
|
+
* gasPrice: Value.fromGwei('10'),
|
|
3145
|
+
* nonce: 69n,
|
|
3146
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
3147
|
+
* value: Value.fromEther('1.5'),
|
|
3148
|
+
* })
|
|
3149
|
+
*
|
|
3150
|
+
* // Sign over the Envelope.
|
|
3151
|
+
* const signature = Secp256k1.sign({
|
|
3152
|
+
* payload: TransactionEnvelopeLegacy.getSignPayload(envelope),
|
|
3153
|
+
* privateKey: '0x...',
|
|
3154
|
+
* })
|
|
3155
|
+
*
|
|
3156
|
+
* // Serialize the Envelope with the Signature. // [!code focus]
|
|
3157
|
+
* const serialized = TransactionEnvelopeLegacy.serialize(envelope, { // [!code focus]
|
|
3158
|
+
* signature // [!code focus]
|
|
3159
|
+
* }) // [!code focus]
|
|
3160
|
+
*
|
|
3161
|
+
* // Broadcast the Envelope with `eth_sendRawTransaction`. // [!code focus]
|
|
3162
|
+
* const transport = RpcTransport.fromHttp('https://1.rpc.thirdweb.com') // [!code focus]
|
|
3163
|
+
* const hash = await transport.request({ // [!code focus]
|
|
3164
|
+
* method: 'eth_sendRawTransaction', // [!code focus]
|
|
3165
|
+
* params: [serialized], // [!code focus]
|
|
3166
|
+
* }) // [!code focus]
|
|
3167
|
+
* ```
|
|
3168
|
+
*
|
|
3169
|
+
* If you are interfacing with an RPC that supports `eth_sendTransaction`, you can also use
|
|
3170
|
+
* {@link ox#TransactionEnvelopeLegacy.(toRpc:function)} to convert an Envelope to an RPC-compatible format.
|
|
3171
|
+
* This means you can skip the ceremony of manually filling & signing the Transaction.
|
|
3172
|
+
*
|
|
3173
|
+
* ```ts twoslash
|
|
3174
|
+
* import 'ox/window'
|
|
3175
|
+
* import { Provider, TransactionEnvelopeLegacy, Value } from 'ox'
|
|
3176
|
+
*
|
|
3177
|
+
* const envelope = TransactionEnvelopeLegacy.from({
|
|
3178
|
+
* chainId: 1,
|
|
3179
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
3180
|
+
* value: Value.fromEther('1.5'),
|
|
3181
|
+
* })
|
|
3182
|
+
*
|
|
3183
|
+
* const envelope_rpc = TransactionEnvelopeLegacy.toRpc(envelope)
|
|
3184
|
+
*
|
|
3185
|
+
* const provider = Provider.from(window.ethereum)
|
|
3186
|
+
* const hash = await provider.request({
|
|
3187
|
+
* method: 'eth_sendTransaction',
|
|
3188
|
+
* params: [envelope_rpc],
|
|
3189
|
+
* })
|
|
3190
|
+
* ```
|
|
3191
|
+
*
|
|
3192
|
+
* @example
|
|
3193
|
+
* ### Computing Hashes
|
|
3194
|
+
*
|
|
3195
|
+
* Transaction Hashes can be computed using {@link ox#TransactionEnvelopeLegacy.(hash:function)}:
|
|
3196
|
+
*
|
|
3197
|
+
* ```ts twoslash
|
|
3198
|
+
* import { Secp256k1, TransactionEnvelopeLegacy } from 'ox'
|
|
3199
|
+
*
|
|
3200
|
+
* const envelope = TransactionEnvelopeLegacy.from({
|
|
3201
|
+
* chainId: 1,
|
|
3202
|
+
* nonce: 0n,
|
|
3203
|
+
* gasPrice: 1000000000n,
|
|
3204
|
+
* gas: 21000n,
|
|
3205
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
3206
|
+
* value: 1000000000000000000n,
|
|
3207
|
+
* data: '0x',
|
|
3208
|
+
* })
|
|
3209
|
+
*
|
|
3210
|
+
* const signature = Secp256k1.sign({
|
|
3211
|
+
* payload: TransactionEnvelopeLegacy.getSignPayload(envelope),
|
|
3212
|
+
* privateKey: '0x...'
|
|
3213
|
+
* })
|
|
3214
|
+
*
|
|
3215
|
+
* const envelope_signed = TransactionEnvelopeLegacy.from(envelope, { signature })
|
|
3216
|
+
*
|
|
3217
|
+
* const hash = TransactionEnvelopeLegacy.hash(envelope_signed) // [!code focus]
|
|
3218
|
+
* ```
|
|
3219
|
+
*
|
|
3220
|
+
* @category Transaction Envelopes
|
|
3221
|
+
*/
|
|
3222
|
+
export * as TransactionEnvelopeLegacy from './core/TransactionEnvelopeLegacy.js'
|
|
3247
3223
|
|
|
3248
3224
|
/**
|
|
3249
3225
|
* Utilities & types for working with **Transaction Receipts** as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/receipt.yaml)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ox",
|
|
3
3
|
"description": "Ethereum Standard Library",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.9.1",
|
|
5
5
|
"main": "./_cjs/index.js",
|
|
6
6
|
"module": "./_esm/index.js",
|
|
7
7
|
"types": "./_types/index.d.ts",
|
|
@@ -418,16 +418,26 @@
|
|
|
418
418
|
"import": "./_esm/erc4337/index.js",
|
|
419
419
|
"default": "./_cjs/erc4337/index.js"
|
|
420
420
|
},
|
|
421
|
-
"./erc6492/
|
|
422
|
-
"types": "./_types/erc6492/
|
|
423
|
-
"import": "./_esm/erc6492/
|
|
424
|
-
"default": "./_cjs/erc6492/
|
|
421
|
+
"./erc6492/SignatureErc6492": {
|
|
422
|
+
"types": "./_types/erc6492/SignatureErc6492.d.ts",
|
|
423
|
+
"import": "./_esm/erc6492/SignatureErc6492.js",
|
|
424
|
+
"default": "./_cjs/erc6492/SignatureErc6492.js"
|
|
425
425
|
},
|
|
426
426
|
"./erc6492": {
|
|
427
427
|
"types": "./_types/erc6492/index.d.ts",
|
|
428
428
|
"import": "./_esm/erc6492/index.js",
|
|
429
429
|
"default": "./_cjs/erc6492/index.js"
|
|
430
430
|
},
|
|
431
|
+
"./erc8010/SignatureErc8010": {
|
|
432
|
+
"types": "./_types/erc8010/SignatureErc8010.d.ts",
|
|
433
|
+
"import": "./_esm/erc8010/SignatureErc8010.js",
|
|
434
|
+
"default": "./_cjs/erc8010/SignatureErc8010.js"
|
|
435
|
+
},
|
|
436
|
+
"./erc8010": {
|
|
437
|
+
"types": "./_types/erc8010/index.d.ts",
|
|
438
|
+
"import": "./_esm/erc8010/index.js",
|
|
439
|
+
"default": "./_cjs/erc8010/index.js"
|
|
440
|
+
},
|
|
431
441
|
"./index.docs": {
|
|
432
442
|
"types": "./_types/index.docs.d.ts",
|
|
433
443
|
"import": "./_esm/index.docs.js",
|
|
@@ -5,6 +5,7 @@ import { fileURLToPath } from 'node:url'
|
|
|
5
5
|
export function path(name: string) {
|
|
6
6
|
const __filename = fileURLToPath(
|
|
7
7
|
// import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'
|
|
8
|
+
// biome-ignore lint/suspicious/noTsIgnore: _
|
|
8
9
|
// @ts-ignore
|
|
9
10
|
import.meta.url,
|
|
10
11
|
)
|
package/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
export const version = '0.
|
|
2
|
+
export const version = '0.9.1'
|