ox 0.9.16 → 0.10.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/CHANGELOG.md +27 -0
- package/README.md +4 -4
- package/TxEnvelope/package.json +6 -0
- package/TxEnvelopeEip1559/package.json +6 -0
- package/TxEnvelopeEip2930/package.json +6 -0
- package/TxEnvelopeEip4844/package.json +6 -0
- package/TxEnvelopeEip7702/package.json +6 -0
- package/TxEnvelopeLegacy/package.json +6 -0
- package/_cjs/core/{TransactionEnvelope.js → TxEnvelope.js} +1 -1
- package/_cjs/core/TxEnvelope.js.map +1 -0
- package/_cjs/core/{TransactionEnvelopeEip1559.js → TxEnvelopeEip1559.js} +2 -2
- package/_cjs/core/TxEnvelopeEip1559.js.map +1 -0
- package/_cjs/core/{TransactionEnvelopeEip2930.js → TxEnvelopeEip2930.js} +2 -2
- package/_cjs/core/TxEnvelopeEip2930.js.map +1 -0
- package/_cjs/core/{TransactionEnvelopeEip4844.js → TxEnvelopeEip4844.js} +4 -4
- package/_cjs/core/TxEnvelopeEip4844.js.map +1 -0
- package/_cjs/core/{TransactionEnvelopeEip7702.js → TxEnvelopeEip7702.js} +4 -4
- package/_cjs/core/TxEnvelopeEip7702.js.map +1 -0
- package/_cjs/core/{TransactionEnvelopeLegacy.js → TxEnvelopeLegacy.js} +2 -2
- package/_cjs/core/TxEnvelopeLegacy.js.map +1 -0
- package/_cjs/core/WebAuthnP256.js +1 -1
- package/_cjs/core/WebAuthnP256.js.map +1 -1
- package/_cjs/erc8021/Attribution.js +36 -6
- package/_cjs/erc8021/Attribution.js.map +1 -1
- package/_cjs/index.docs.js +1 -0
- package/_cjs/index.docs.js.map +1 -1
- package/_cjs/index.js +7 -7
- package/_cjs/index.js.map +1 -1
- package/_cjs/tempo/AuthorizationTempo.js +101 -0
- package/_cjs/tempo/AuthorizationTempo.js.map +1 -0
- package/_cjs/tempo/KeyAuthorization.js +123 -0
- package/_cjs/tempo/KeyAuthorization.js.map +1 -0
- package/_cjs/tempo/PoolId.js +10 -0
- package/_cjs/tempo/PoolId.js.map +1 -0
- package/_cjs/tempo/SignatureEnvelope.js +394 -0
- package/_cjs/tempo/SignatureEnvelope.js.map +1 -0
- package/_cjs/tempo/Tick.js +77 -0
- package/_cjs/tempo/Tick.js.map +1 -0
- package/_cjs/tempo/TokenId.js +28 -0
- package/_cjs/tempo/TokenId.js.map +1 -0
- package/_cjs/tempo/TokenRole.js +26 -0
- package/_cjs/tempo/TokenRole.js.map +1 -0
- package/_cjs/tempo/Transaction.js +80 -0
- package/_cjs/tempo/Transaction.js.map +1 -0
- package/_cjs/tempo/TransactionReceipt.js +26 -0
- package/_cjs/tempo/TransactionReceipt.js.map +1 -0
- package/_cjs/tempo/TransactionRequest.js +53 -0
- package/_cjs/tempo/TransactionRequest.js.map +1 -0
- package/_cjs/tempo/TxEnvelopeTempo.js +267 -0
- package/_cjs/tempo/TxEnvelopeTempo.js.map +1 -0
- package/_cjs/tempo/index.js +15 -0
- package/_cjs/tempo/index.js.map +1 -0
- package/_cjs/version.js +1 -1
- package/_esm/core/Blobs.js +8 -8
- package/_esm/core/{TransactionEnvelope.js → TxEnvelope.js} +11 -11
- package/_esm/core/TxEnvelope.js.map +1 -0
- package/_esm/core/{TransactionEnvelopeEip1559.js → TxEnvelopeEip1559.js} +42 -42
- package/_esm/core/TxEnvelopeEip1559.js.map +1 -0
- package/_esm/core/{TransactionEnvelopeEip2930.js → TxEnvelopeEip2930.js} +43 -43
- package/_esm/core/TxEnvelopeEip2930.js.map +1 -0
- package/_esm/core/{TransactionEnvelopeEip4844.js → TxEnvelopeEip4844.js} +42 -42
- package/_esm/core/TxEnvelopeEip4844.js.map +1 -0
- package/_esm/core/{TransactionEnvelopeEip7702.js → TxEnvelopeEip7702.js} +40 -40
- package/_esm/core/TxEnvelopeEip7702.js.map +1 -0
- package/_esm/core/{TransactionEnvelopeLegacy.js → TxEnvelopeLegacy.js} +42 -42
- package/_esm/core/TxEnvelopeLegacy.js.map +1 -0
- package/_esm/core/WebAuthnP256.js +1 -1
- package/_esm/core/WebAuthnP256.js.map +1 -1
- package/_esm/erc8021/Attribution.js +58 -13
- package/_esm/erc8021/Attribution.js.map +1 -1
- package/_esm/index.docs.js +1 -0
- package/_esm/index.docs.js.map +1 -1
- package/_esm/index.js +192 -192
- package/_esm/index.js.map +1 -1
- package/_esm/tempo/AuthorizationTempo.js +664 -0
- package/_esm/tempo/AuthorizationTempo.js.map +1 -0
- package/_esm/tempo/KeyAuthorization.js +426 -0
- package/_esm/tempo/KeyAuthorization.js.map +1 -0
- package/_esm/tempo/PoolId.js +28 -0
- package/_esm/tempo/PoolId.js.map +1 -0
- package/_esm/tempo/SignatureEnvelope.js +660 -0
- package/_esm/tempo/SignatureEnvelope.js.map +1 -0
- package/_esm/tempo/Tick.js +147 -0
- package/_esm/tempo/Tick.js.map +1 -0
- package/_esm/tempo/TokenId.js +71 -0
- package/_esm/tempo/TokenId.js.map +1 -0
- package/_esm/tempo/TokenRole.js +40 -0
- package/_esm/tempo/TokenRole.js.map +1 -0
- package/_esm/tempo/Transaction.js +167 -0
- package/_esm/tempo/Transaction.js.map +1 -0
- package/_esm/tempo/TransactionReceipt.js +138 -0
- package/_esm/tempo/TransactionReceipt.js.map +1 -0
- package/_esm/tempo/TransactionRequest.js +99 -0
- package/_esm/tempo/TransactionRequest.js.map +1 -0
- package/_esm/tempo/TxEnvelopeTempo.js +607 -0
- package/_esm/tempo/TxEnvelopeTempo.js.map +1 -0
- package/_esm/tempo/index.js +298 -0
- package/_esm/tempo/index.js.map +1 -0
- package/_esm/version.js +1 -1
- package/_types/core/Blobs.d.ts +8 -8
- package/_types/core/{TransactionEnvelope.d.ts → TxEnvelope.d.ts} +11 -11
- package/_types/core/TxEnvelope.d.ts.map +1 -0
- package/_types/core/{TransactionEnvelopeEip1559.d.ts → TxEnvelopeEip1559.d.ts} +54 -54
- package/_types/core/TxEnvelopeEip1559.d.ts.map +1 -0
- package/_types/core/{TransactionEnvelopeEip2930.d.ts → TxEnvelopeEip2930.d.ts} +55 -55
- package/_types/core/TxEnvelopeEip2930.d.ts.map +1 -0
- package/_types/core/{TransactionEnvelopeEip4844.d.ts → TxEnvelopeEip4844.d.ts} +54 -54
- package/_types/core/TxEnvelopeEip4844.d.ts.map +1 -0
- package/_types/core/{TransactionEnvelopeEip7702.d.ts → TxEnvelopeEip7702.d.ts} +49 -49
- package/_types/core/TxEnvelopeEip7702.d.ts.map +1 -0
- package/_types/core/{TransactionEnvelopeLegacy.d.ts → TxEnvelopeLegacy.d.ts} +54 -54
- package/_types/core/TxEnvelopeLegacy.d.ts.map +1 -0
- package/_types/core/WebAuthnP256.d.ts +1 -1
- package/_types/core/WebAuthnP256.d.ts.map +1 -1
- package/_types/erc8021/Attribution.d.ts +20 -6
- package/_types/erc8021/Attribution.d.ts.map +1 -1
- package/_types/index.d.ts +192 -192
- 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/tempo/AuthorizationTempo.d.ts +688 -0
- package/_types/tempo/AuthorizationTempo.d.ts.map +1 -0
- package/_types/tempo/KeyAuthorization.d.ts +437 -0
- package/_types/tempo/KeyAuthorization.d.ts.map +1 -0
- package/_types/tempo/PoolId.d.ts +33 -0
- package/_types/tempo/PoolId.d.ts.map +1 -0
- package/_types/tempo/SignatureEnvelope.d.ts +438 -0
- package/_types/tempo/SignatureEnvelope.d.ts.map +1 -0
- package/_types/tempo/Tick.d.ts +120 -0
- package/_types/tempo/Tick.d.ts.map +1 -0
- package/_types/tempo/TokenId.d.ts +55 -0
- package/_types/tempo/TokenId.d.ts.map +1 -0
- package/_types/tempo/TokenRole.d.ts +29 -0
- package/_types/tempo/TokenRole.d.ts.map +1 -0
- package/_types/tempo/Transaction.d.ts +208 -0
- package/_types/tempo/Transaction.d.ts.map +1 -0
- package/_types/tempo/TransactionReceipt.d.ts +165 -0
- package/_types/tempo/TransactionReceipt.d.ts.map +1 -0
- package/_types/tempo/TransactionRequest.d.ts +89 -0
- package/_types/tempo/TransactionRequest.d.ts.map +1 -0
- package/_types/tempo/TxEnvelopeTempo.d.ts +551 -0
- package/_types/tempo/TxEnvelopeTempo.d.ts.map +1 -0
- package/_types/tempo/index.d.ts +300 -0
- package/_types/tempo/index.d.ts.map +1 -0
- package/_types/version.d.ts +1 -1
- package/core/Blobs.ts +8 -8
- package/core/{TransactionEnvelope.ts → TxEnvelope.ts} +10 -10
- package/core/{TransactionEnvelopeEip1559.ts → TxEnvelopeEip1559.ts} +60 -69
- package/core/{TransactionEnvelopeEip2930.ts → TxEnvelopeEip2930.ts} +61 -72
- package/core/{TransactionEnvelopeEip4844.ts → TxEnvelopeEip4844.ts} +62 -71
- package/core/{TransactionEnvelopeEip7702.ts → TxEnvelopeEip7702.ts} +58 -67
- package/core/{TransactionEnvelopeLegacy.ts → TxEnvelopeLegacy.ts} +59 -68
- package/core/WebAuthnP256.ts +3 -1
- package/erc8021/Attribution.ts +77 -15
- package/index.docs.ts +1 -0
- package/index.ts +192 -195
- package/package.json +91 -31
- package/tempo/AuthorizationTempo/package.json +6 -0
- package/tempo/AuthorizationTempo.test.ts +1293 -0
- package/tempo/AuthorizationTempo.ts +884 -0
- package/tempo/KeyAuthorization/package.json +6 -0
- package/tempo/KeyAuthorization.test.ts +1373 -0
- package/tempo/KeyAuthorization.ts +622 -0
- package/tempo/PoolId/package.json +6 -0
- package/tempo/PoolId.test.ts +33 -0
- package/tempo/PoolId.ts +42 -0
- package/tempo/SignatureEnvelope/package.json +6 -0
- package/tempo/SignatureEnvelope.test.ts +1877 -0
- package/tempo/SignatureEnvelope.ts +973 -0
- package/tempo/Tick/package.json +6 -0
- package/tempo/Tick.test.ts +281 -0
- package/tempo/Tick.ts +186 -0
- package/tempo/TokenId/package.json +6 -0
- package/tempo/TokenId.test.ts +40 -0
- package/tempo/TokenId.ts +80 -0
- package/tempo/TokenRole/package.json +6 -0
- package/tempo/TokenRole.test.ts +16 -0
- package/tempo/TokenRole.ts +45 -0
- package/tempo/Transaction/package.json +6 -0
- package/tempo/Transaction.test.ts +523 -0
- package/tempo/Transaction.ts +339 -0
- package/tempo/TransactionReceipt/package.json +6 -0
- package/tempo/TransactionReceipt.ts +200 -0
- package/tempo/TransactionRequest/package.json +6 -0
- package/tempo/TransactionRequest.ts +160 -0
- package/tempo/TxEnvelopeTempo/package.json +6 -0
- package/tempo/TxEnvelopeTempo.test.ts +1371 -0
- package/tempo/TxEnvelopeTempo.ts +972 -0
- package/tempo/e2e.test.ts +1387 -0
- package/tempo/index.ts +308 -0
- package/tempo/package.json +6 -0
- package/version.ts +1 -1
- package/TransactionEnvelope/package.json +0 -6
- package/TransactionEnvelopeEip1559/package.json +0 -6
- package/TransactionEnvelopeEip2930/package.json +0 -6
- package/TransactionEnvelopeEip4844/package.json +0 -6
- package/TransactionEnvelopeEip7702/package.json +0 -6
- package/TransactionEnvelopeLegacy/package.json +0 -6
- package/_cjs/core/TransactionEnvelope.js.map +0 -1
- package/_cjs/core/TransactionEnvelopeEip1559.js.map +0 -1
- package/_cjs/core/TransactionEnvelopeEip2930.js.map +0 -1
- package/_cjs/core/TransactionEnvelopeEip4844.js.map +0 -1
- package/_cjs/core/TransactionEnvelopeEip7702.js.map +0 -1
- package/_cjs/core/TransactionEnvelopeLegacy.js.map +0 -1
- package/_esm/core/TransactionEnvelope.js.map +0 -1
- package/_esm/core/TransactionEnvelopeEip1559.js.map +0 -1
- package/_esm/core/TransactionEnvelopeEip2930.js.map +0 -1
- package/_esm/core/TransactionEnvelopeEip4844.js.map +0 -1
- package/_esm/core/TransactionEnvelopeEip7702.js.map +0 -1
- package/_esm/core/TransactionEnvelopeLegacy.js.map +0 -1
- package/_types/core/TransactionEnvelope.d.ts.map +0 -1
- package/_types/core/TransactionEnvelopeEip1559.d.ts.map +0 -1
- package/_types/core/TransactionEnvelopeEip2930.d.ts.map +0 -1
- package/_types/core/TransactionEnvelopeEip4844.d.ts.map +0 -1
- package/_types/core/TransactionEnvelopeEip7702.d.ts.map +0 -1
- package/_types/core/TransactionEnvelopeLegacy.d.ts.map +0 -1
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type * as Errors from '../core/Errors.js'
|
|
2
|
+
import * as Hex from '../core/Hex.js'
|
|
3
|
+
import type { Compute } from '../core/internal/types.js'
|
|
4
|
+
import * as ox_TransactionRequest from '../core/TransactionRequest.js'
|
|
5
|
+
import * as AuthorizationTempo from './AuthorizationTempo.js'
|
|
6
|
+
import * as KeyAuthorization from './KeyAuthorization.js'
|
|
7
|
+
import * as TokenId from './TokenId.js'
|
|
8
|
+
import * as Transaction from './Transaction.js'
|
|
9
|
+
import type { Call } from './TxEnvelopeTempo.js'
|
|
10
|
+
|
|
11
|
+
type KeyType = 'secp256k1' | 'p256' | 'webAuthn'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A Transaction Request that is generic to all transaction types.
|
|
15
|
+
*
|
|
16
|
+
* Extends the [Execution API specification](https://github.com/ethereum/execution-apis/blob/4aca1d7a3e5aab24c8f6437131289ad386944eaa/src/schemas/transaction.yaml#L358-L423)
|
|
17
|
+
* with Tempo-specific fields for batched calls, fee tokens, access keys, and scheduled execution.
|
|
18
|
+
*
|
|
19
|
+
* @see {@link https://docs.tempo.xyz/protocol/transactions Tempo Transactions}
|
|
20
|
+
*/
|
|
21
|
+
export type TransactionRequest<
|
|
22
|
+
bigintType = bigint,
|
|
23
|
+
numberType = number,
|
|
24
|
+
type extends string = string,
|
|
25
|
+
> = Compute<
|
|
26
|
+
Omit<
|
|
27
|
+
ox_TransactionRequest.TransactionRequest<bigintType, numberType, type>,
|
|
28
|
+
'authorizationList'
|
|
29
|
+
> & {
|
|
30
|
+
authorizationList?:
|
|
31
|
+
| AuthorizationTempo.ListSigned<bigintType, numberType>
|
|
32
|
+
| undefined
|
|
33
|
+
calls?: readonly Call<bigintType>[] | undefined
|
|
34
|
+
keyAuthorization?: KeyAuthorization.KeyAuthorization<true> | undefined
|
|
35
|
+
keyData?: Hex.Hex | undefined
|
|
36
|
+
keyType?: KeyType | undefined
|
|
37
|
+
feeToken?: TokenId.TokenIdOrAddress | undefined
|
|
38
|
+
nonceKey?: 'random' | bigintType | undefined
|
|
39
|
+
validBefore?: numberType | undefined
|
|
40
|
+
validAfter?: numberType | undefined
|
|
41
|
+
}
|
|
42
|
+
>
|
|
43
|
+
|
|
44
|
+
/** RPC representation of a {@link ox#TransactionRequest.TransactionRequest}. */
|
|
45
|
+
export type Rpc = Omit<
|
|
46
|
+
TransactionRequest<Hex.Hex, Hex.Hex, string>,
|
|
47
|
+
'authorizationList' | 'keyAuthorization'
|
|
48
|
+
> & {
|
|
49
|
+
authorizationList?: AuthorizationTempo.ListRpc | undefined
|
|
50
|
+
keyAuthorization?: KeyAuthorization.Rpc | undefined
|
|
51
|
+
nonceKey?: Hex.Hex | undefined
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Converts a {@link ox#TransactionRequest.TransactionRequest} to a {@link ox#TransactionRequest.Rpc}.
|
|
56
|
+
*
|
|
57
|
+
* @see {@link https://docs.tempo.xyz/protocol/transactions Tempo Transactions}
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts twoslash
|
|
61
|
+
* import { Value } from 'ox'
|
|
62
|
+
* import { TransactionRequest } from 'ox/tempo'
|
|
63
|
+
*
|
|
64
|
+
* const request = TransactionRequest.toRpc({
|
|
65
|
+
* calls: [{
|
|
66
|
+
* data: '0xdeadbeef',
|
|
67
|
+
* to: '0xcafebabecafebabecafebabecafebabecafebabe',
|
|
68
|
+
* }],
|
|
69
|
+
* feeToken: '0x20c0000000000000000000000000000000000000',
|
|
70
|
+
* })
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ### Using with a Provider
|
|
75
|
+
*
|
|
76
|
+
* You can use {@link ox#Provider.(from:function)} to instantiate an EIP-1193 Provider and
|
|
77
|
+
* send a transaction to the Wallet using the `eth_sendTransaction` method.
|
|
78
|
+
*
|
|
79
|
+
* ```ts twoslash
|
|
80
|
+
* import 'ox/window'
|
|
81
|
+
* import { Provider, Value } from 'ox'
|
|
82
|
+
* import { TransactionRequest } from 'ox/tempo'
|
|
83
|
+
*
|
|
84
|
+
* const provider = Provider.from(window.ethereum!)
|
|
85
|
+
*
|
|
86
|
+
* const request = TransactionRequest.toRpc({
|
|
87
|
+
* calls: [{
|
|
88
|
+
* data: '0xdeadbeef',
|
|
89
|
+
* to: '0xcafebabecafebabecafebabecafebabecafebabe',
|
|
90
|
+
* }],
|
|
91
|
+
* feeToken: '0x20c0000000000000000000000000000000000000',
|
|
92
|
+
* })
|
|
93
|
+
*
|
|
94
|
+
* const hash = await provider.request({ // [!code focus]
|
|
95
|
+
* method: 'eth_sendTransaction', // [!code focus]
|
|
96
|
+
* params: [request], // [!code focus]
|
|
97
|
+
* }) // [!code focus]
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @param request - The request to convert.
|
|
101
|
+
* @returns An RPC request.
|
|
102
|
+
*/
|
|
103
|
+
export function toRpc(request: TransactionRequest): Rpc {
|
|
104
|
+
const request_rpc = ox_TransactionRequest.toRpc({
|
|
105
|
+
...request,
|
|
106
|
+
authorizationList: undefined,
|
|
107
|
+
}) as Rpc
|
|
108
|
+
|
|
109
|
+
if (request.authorizationList)
|
|
110
|
+
request_rpc.authorizationList = AuthorizationTempo.toRpcList(
|
|
111
|
+
request.authorizationList,
|
|
112
|
+
)
|
|
113
|
+
if (request.calls)
|
|
114
|
+
request_rpc.calls = request.calls.map((call) => ({
|
|
115
|
+
to: call.to ?? '0x',
|
|
116
|
+
value: call.value ? Hex.fromNumber(call.value) : '0x',
|
|
117
|
+
data: call.data ?? '0x',
|
|
118
|
+
}))
|
|
119
|
+
if (typeof request.feeToken !== 'undefined')
|
|
120
|
+
request_rpc.feeToken = TokenId.toAddress(request.feeToken)
|
|
121
|
+
if (request.keyAuthorization)
|
|
122
|
+
request_rpc.keyAuthorization = KeyAuthorization.toRpc(
|
|
123
|
+
request.keyAuthorization,
|
|
124
|
+
)
|
|
125
|
+
if (typeof request.validBefore !== 'undefined')
|
|
126
|
+
request_rpc.validBefore = Hex.fromNumber(request.validBefore)
|
|
127
|
+
if (typeof request.validAfter !== 'undefined')
|
|
128
|
+
request_rpc.validAfter = Hex.fromNumber(request.validAfter)
|
|
129
|
+
|
|
130
|
+
const nonceKey = (() => {
|
|
131
|
+
if (request.nonceKey === 'random') return Hex.random(6)
|
|
132
|
+
if (typeof request.nonceKey === 'bigint')
|
|
133
|
+
return Hex.fromNumber(request.nonceKey)
|
|
134
|
+
return undefined
|
|
135
|
+
})()
|
|
136
|
+
if (nonceKey) request_rpc.nonceKey = nonceKey
|
|
137
|
+
|
|
138
|
+
if (
|
|
139
|
+
request.calls ||
|
|
140
|
+
typeof request.feeToken !== 'undefined' ||
|
|
141
|
+
typeof request.validBefore !== 'undefined' ||
|
|
142
|
+
typeof request.validAfter !== 'undefined' ||
|
|
143
|
+
request.type === 'tempo'
|
|
144
|
+
) {
|
|
145
|
+
request_rpc.type = Transaction.toRpcType.tempo
|
|
146
|
+
delete request_rpc.data
|
|
147
|
+
delete request_rpc.input
|
|
148
|
+
delete request_rpc.to
|
|
149
|
+
delete request_rpc.value
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return request_rpc
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export declare namespace toRpc {
|
|
156
|
+
export type ErrorType =
|
|
157
|
+
| AuthorizationTempo.toRpcList.ErrorType
|
|
158
|
+
| Hex.fromNumber.ErrorType
|
|
159
|
+
| Errors.GlobalErrorType
|
|
160
|
+
}
|