tempo.ts 0.0.5 → 0.1.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/dist/chains.d.ts +244 -541
- package/dist/chains.d.ts.map +1 -1
- package/dist/chains.js +10 -23
- package/dist/chains.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/ox/SignatureEnvelope.d.ts +245 -0
- package/dist/ox/SignatureEnvelope.d.ts.map +1 -0
- package/dist/ox/SignatureEnvelope.js +437 -0
- package/dist/ox/SignatureEnvelope.js.map +1 -0
- package/dist/ox/Transaction.d.ts +61 -24
- package/dist/ox/Transaction.d.ts.map +1 -1
- package/dist/ox/Transaction.js +63 -18
- package/dist/ox/Transaction.js.map +1 -1
- package/dist/ox/TransactionEnvelopeAA.d.ts +461 -0
- package/dist/ox/TransactionEnvelopeAA.d.ts.map +1 -0
- package/dist/ox/TransactionEnvelopeAA.js +528 -0
- package/dist/ox/TransactionEnvelopeAA.js.map +1 -0
- package/dist/ox/TransactionRequest.d.ts +7 -5
- package/dist/ox/TransactionRequest.d.ts.map +1 -1
- package/dist/ox/TransactionRequest.js +21 -12
- package/dist/ox/TransactionRequest.js.map +1 -1
- package/dist/ox/index.d.ts +5 -4
- package/dist/ox/index.d.ts.map +1 -1
- package/dist/ox/index.js +5 -4
- package/dist/ox/index.js.map +1 -1
- package/dist/prool/Instance.d.ts +0 -4
- package/dist/prool/Instance.d.ts.map +1 -1
- package/dist/prool/Instance.js +7 -7
- package/dist/prool/Instance.js.map +1 -1
- package/dist/prool/index.d.ts +1 -1
- package/dist/prool/index.d.ts.map +1 -1
- package/dist/prool/index.js +1 -1
- package/dist/prool/index.js.map +1 -1
- package/dist/viem/{abis.d.ts → Abis.d.ts} +523 -9
- package/dist/viem/Abis.d.ts.map +1 -0
- package/dist/viem/{abis.js → Abis.js} +321 -9
- package/dist/viem/Abis.js.map +1 -0
- package/dist/viem/{actions → Actions}/amm.d.ts +21 -21
- package/dist/viem/Actions/amm.d.ts.map +1 -0
- package/dist/viem/{actions → Actions}/amm.js +55 -43
- package/dist/viem/Actions/amm.js.map +1 -0
- package/dist/viem/Actions/dex.d.ts +3263 -0
- package/dist/viem/Actions/dex.d.ts.map +1 -0
- package/dist/viem/Actions/dex.js +1357 -0
- package/dist/viem/Actions/dex.js.map +1 -0
- package/dist/viem/{actions → Actions}/fee.d.ts +8 -8
- package/dist/viem/Actions/fee.d.ts.map +1 -0
- package/dist/viem/{actions → Actions}/fee.js +14 -13
- package/dist/viem/Actions/fee.js.map +1 -0
- package/dist/viem/Actions/index.d.ts +6 -0
- package/dist/viem/Actions/index.d.ts.map +1 -0
- package/dist/viem/Actions/index.js +6 -0
- package/dist/viem/Actions/index.js.map +1 -0
- package/dist/viem/{actions → Actions}/policy.d.ts +19 -19
- package/dist/viem/Actions/policy.d.ts.map +1 -0
- package/dist/viem/{actions → Actions}/policy.js +59 -46
- package/dist/viem/Actions/policy.js.map +1 -0
- package/dist/viem/{actions → Actions}/token.d.ts +3251 -707
- package/dist/viem/Actions/token.d.ts.map +1 -0
- package/dist/viem/{actions → Actions}/token.js +420 -88
- package/dist/viem/Actions/token.js.map +1 -0
- package/dist/viem/Addresses.d.ts +9 -0
- package/dist/viem/Addresses.d.ts.map +1 -0
- package/dist/viem/Addresses.js +9 -0
- package/dist/viem/Addresses.js.map +1 -0
- package/dist/viem/{chain.d.ts → Chain.d.ts} +81 -57
- package/dist/viem/Chain.d.ts.map +1 -0
- package/dist/viem/{chain.js → Chain.js} +7 -7
- package/dist/viem/Chain.js.map +1 -0
- package/dist/viem/{client.d.ts → Client.d.ts} +4 -4
- package/dist/viem/Client.d.ts.map +1 -0
- package/dist/viem/{client.js → Client.js} +3 -3
- package/dist/viem/Client.js.map +1 -0
- package/dist/viem/{decorator.d.ts → Decorator.d.ts} +507 -5
- package/dist/viem/Decorator.d.ts.map +1 -0
- package/dist/viem/{decorator.js → Decorator.js} +31 -5
- package/dist/viem/Decorator.js.map +1 -0
- package/dist/viem/{formatters.d.ts → Formatters.d.ts} +2 -2
- package/dist/viem/Formatters.d.ts.map +1 -0
- package/dist/viem/{formatters.js → Formatters.js} +24 -17
- package/dist/viem/Formatters.js.map +1 -0
- package/dist/viem/Tick.d.ts +111 -0
- package/dist/viem/Tick.d.ts.map +1 -0
- package/dist/viem/Tick.js +127 -0
- package/dist/viem/Tick.js.map +1 -0
- package/dist/viem/TokenIds.d.ts +3 -0
- package/dist/viem/TokenIds.d.ts.map +1 -0
- package/dist/viem/TokenIds.js +3 -0
- package/dist/viem/TokenIds.js.map +1 -0
- package/dist/viem/Transaction.d.ts +57 -0
- package/dist/viem/Transaction.d.ts.map +1 -0
- package/dist/viem/Transaction.js +137 -0
- package/dist/viem/Transaction.js.map +1 -0
- package/dist/viem/{transport.d.ts → Transport.d.ts} +3 -3
- package/dist/viem/Transport.d.ts.map +1 -0
- package/dist/viem/{transport.js → Transport.js} +3 -3
- package/dist/viem/Transport.js.map +1 -0
- package/dist/viem/index.d.ts +13 -9
- package/dist/viem/index.d.ts.map +1 -1
- package/dist/viem/index.js +13 -9
- package/dist/viem/index.js.map +1 -1
- package/dist/viem/{types.d.ts → internal/types.d.ts} +3 -3
- package/dist/viem/internal/types.d.ts.map +1 -0
- package/dist/viem/{types.js.map → internal/types.js.map} +1 -1
- package/dist/viem/internal/utils.d.ts.map +1 -0
- package/dist/viem/internal/utils.js.map +1 -0
- package/package.json +87 -101
- package/src/chains.ts +10 -24
- package/src/ox/SignatureEnvelope.test.ts +1252 -0
- package/src/ox/SignatureEnvelope.ts +709 -0
- package/src/ox/Transaction.test.ts +144 -89
- package/src/ox/Transaction.ts +104 -29
- package/src/ox/TransactionEnvelopeAA.test.ts +1533 -0
- package/src/ox/TransactionEnvelopeAA.ts +858 -0
- package/src/ox/TransactionRequest.ts +25 -17
- package/src/ox/index.ts +2 -1
- package/src/prool/Instance.ts +6 -14
- package/src/prool/internal/chain.json +101 -27
- package/src/viem/{abis.ts → Abis.ts} +322 -8
- package/src/viem/{actions → Actions}/amm.test.ts +65 -68
- package/src/viem/{actions → Actions}/amm.ts +72 -60
- package/src/viem/Actions/dex.test.ts +1608 -0
- package/src/viem/Actions/dex.ts +2026 -0
- package/src/viem/{actions → Actions}/fee.test.ts +34 -36
- package/src/viem/{actions → Actions}/fee.ts +18 -17
- package/src/viem/{actions → Actions}/index.ts +1 -0
- package/src/viem/{actions → Actions}/policy.test.ts +2 -2
- package/src/viem/{actions → Actions}/policy.ts +77 -64
- package/src/viem/{actions → Actions}/token.test.ts +406 -67
- package/src/viem/{actions → Actions}/token.ts +675 -144
- package/src/viem/Addresses.ts +9 -0
- package/src/viem/{chain.ts → Chain.ts} +6 -6
- package/src/viem/{client.bench-d.ts → Client.bench-d.ts} +2 -2
- package/src/viem/{client.test.ts → Client.test.ts} +31 -6
- package/src/viem/{client.ts → Client.ts} +1 -1
- package/src/viem/{decorator.bench-d.ts → Decorator.bench-d.ts} +2 -2
- package/src/viem/{decorator.test.ts → Decorator.test.ts} +1 -0
- package/src/viem/{decorator.ts → Decorator.ts} +586 -4
- package/src/viem/{formatters.ts → Formatters.ts} +31 -20
- package/src/viem/Tick.test.ts +281 -0
- package/src/viem/Tick.ts +176 -0
- package/src/viem/TokenIds.ts +2 -0
- package/src/viem/Transaction.ts +303 -0
- package/src/viem/{transport.ts → Transport.ts} +5 -5
- package/src/viem/e2e.test.ts +153 -78
- package/src/viem/index.ts +13 -9
- package/src/viem/{types.ts → internal/types.ts} +3 -3
- package/dist/ox/TransactionEnvelopeFeeToken.d.ts +0 -393
- package/dist/ox/TransactionEnvelopeFeeToken.d.ts.map +0 -1
- package/dist/ox/TransactionEnvelopeFeeToken.js +0 -452
- package/dist/ox/TransactionEnvelopeFeeToken.js.map +0 -1
- package/dist/viem/abis.d.ts.map +0 -1
- package/dist/viem/abis.js.map +0 -1
- package/dist/viem/actions/amm.d.ts.map +0 -1
- package/dist/viem/actions/amm.js.map +0 -1
- package/dist/viem/actions/fee.d.ts.map +0 -1
- package/dist/viem/actions/fee.js.map +0 -1
- package/dist/viem/actions/index.d.ts +0 -5
- package/dist/viem/actions/index.d.ts.map +0 -1
- package/dist/viem/actions/index.js +0 -5
- package/dist/viem/actions/index.js.map +0 -1
- package/dist/viem/actions/policy.d.ts.map +0 -1
- package/dist/viem/actions/policy.js.map +0 -1
- package/dist/viem/actions/token.d.ts.map +0 -1
- package/dist/viem/actions/token.js.map +0 -1
- package/dist/viem/addresses.d.ts +0 -8
- package/dist/viem/addresses.d.ts.map +0 -1
- package/dist/viem/addresses.js +0 -8
- package/dist/viem/addresses.js.map +0 -1
- package/dist/viem/chain.d.ts.map +0 -1
- package/dist/viem/chain.js.map +0 -1
- package/dist/viem/client.d.ts.map +0 -1
- package/dist/viem/client.js.map +0 -1
- package/dist/viem/decorator.d.ts.map +0 -1
- package/dist/viem/decorator.js.map +0 -1
- package/dist/viem/formatters.d.ts.map +0 -1
- package/dist/viem/formatters.js.map +0 -1
- package/dist/viem/transaction.d.ts +0 -54
- package/dist/viem/transaction.d.ts.map +0 -1
- package/dist/viem/transaction.js +0 -108
- package/dist/viem/transaction.js.map +0 -1
- package/dist/viem/transport.d.ts.map +0 -1
- package/dist/viem/transport.js.map +0 -1
- package/dist/viem/types.d.ts.map +0 -1
- package/dist/viem/utils.d.ts.map +0 -1
- package/dist/viem/utils.js.map +0 -1
- package/src/ox/TransactionEnvelopeFeeToken.test.ts +0 -1119
- package/src/ox/TransactionEnvelopeFeeToken.ts +0 -717
- package/src/prool/internal/consensus.toml +0 -32
- package/src/viem/addresses.ts +0 -10
- package/src/viem/transaction.ts +0 -253
- /package/dist/viem/{types.js → internal/types.js} +0 -0
- /package/dist/viem/{utils.d.ts → internal/utils.d.ts} +0 -0
- /package/dist/viem/{utils.js → internal/utils.js} +0 -0
- /package/src/viem/{utils.ts → internal/utils.ts} +0 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import * as Hex from 'ox/Hex'
|
|
2
|
+
import * as Secp256k1 from 'ox/Secp256k1'
|
|
3
|
+
import * as Signature from 'ox/Signature'
|
|
4
|
+
import {
|
|
5
|
+
type AccessList,
|
|
6
|
+
type Account,
|
|
7
|
+
type Address,
|
|
8
|
+
type AuthorizationList,
|
|
9
|
+
type FeeValuesEIP1559,
|
|
10
|
+
type ParseTransactionReturnType,
|
|
11
|
+
type SignedAuthorizationList,
|
|
12
|
+
type TransactionBase,
|
|
13
|
+
type TransactionRequestBase,
|
|
14
|
+
type TransactionSerializableBase,
|
|
15
|
+
type TransactionSerializedGeneric,
|
|
16
|
+
getTransactionType as viem_getTransactionType,
|
|
17
|
+
parseTransaction as viem_parseTransaction,
|
|
18
|
+
type RpcTransaction as viem_RpcTransaction,
|
|
19
|
+
type RpcTransactionRequest as viem_RpcTransactionRequest,
|
|
20
|
+
type Signature as viem_Signature,
|
|
21
|
+
serializeTransaction as viem_serializeTransaction,
|
|
22
|
+
type Transaction as viem_Transaction,
|
|
23
|
+
type TransactionRequest as viem_TransactionRequest,
|
|
24
|
+
type TransactionSerializable as viem_TransactionSerializable,
|
|
25
|
+
type TransactionSerialized as viem_TransactionSerialized,
|
|
26
|
+
type TransactionType as viem_TransactionType,
|
|
27
|
+
} from 'viem'
|
|
28
|
+
import type { ExactPartial, OneOf, PartialBy } from '../internal/types.js'
|
|
29
|
+
import * as SignatureEnvelope from '../ox/SignatureEnvelope.js'
|
|
30
|
+
import * as TxAA from '../ox/TransactionEnvelopeAA.js'
|
|
31
|
+
|
|
32
|
+
export type Transaction<
|
|
33
|
+
bigintType = bigint,
|
|
34
|
+
numberType = number,
|
|
35
|
+
pending extends boolean = false,
|
|
36
|
+
> = OneOf<
|
|
37
|
+
| viem_Transaction<bigintType, numberType, pending>
|
|
38
|
+
| TransactionAA<bigintType, numberType, pending>
|
|
39
|
+
>
|
|
40
|
+
export type TransactionRpc<pending extends boolean = false> = OneOf<
|
|
41
|
+
| viem_RpcTransaction<pending>
|
|
42
|
+
| TransactionAA<Hex.Hex, Hex.Hex, pending, '0x76'>
|
|
43
|
+
>
|
|
44
|
+
|
|
45
|
+
export type TransactionAA<
|
|
46
|
+
quantity = bigint,
|
|
47
|
+
index = number,
|
|
48
|
+
isPending extends boolean = boolean,
|
|
49
|
+
type = 'aa',
|
|
50
|
+
> = PartialBy<
|
|
51
|
+
Omit<
|
|
52
|
+
TransactionBase<quantity, index, isPending>,
|
|
53
|
+
'data' | 'input' | 'value' | 'to'
|
|
54
|
+
>,
|
|
55
|
+
'r' | 's' | 'v' | 'yParity'
|
|
56
|
+
> & {
|
|
57
|
+
accessList: AccessList
|
|
58
|
+
authorizationList?: SignedAuthorizationList | undefined
|
|
59
|
+
calls: readonly TxAA.Call<quantity>[]
|
|
60
|
+
chainId: index
|
|
61
|
+
feeToken?: Address | undefined
|
|
62
|
+
feePayer?: Address | undefined
|
|
63
|
+
feePayerSignature?: viem_Signature | undefined
|
|
64
|
+
nonceKey?: quantity | undefined
|
|
65
|
+
type: type
|
|
66
|
+
validBefore?: index | undefined
|
|
67
|
+
validAfter?: index | undefined
|
|
68
|
+
} & FeeValuesEIP1559<quantity>
|
|
69
|
+
|
|
70
|
+
export type TransactionRequest<
|
|
71
|
+
bigintType = bigint,
|
|
72
|
+
numberType = number,
|
|
73
|
+
> = OneOf<
|
|
74
|
+
| viem_TransactionRequest<bigintType, numberType>
|
|
75
|
+
| TransactionRequestAA<bigintType, numberType>
|
|
76
|
+
>
|
|
77
|
+
export type TransactionRequestRpc = OneOf<
|
|
78
|
+
viem_RpcTransactionRequest | TransactionRequestAA<Hex.Hex, Hex.Hex, '0x76'>
|
|
79
|
+
>
|
|
80
|
+
|
|
81
|
+
export type TransactionRequestAA<
|
|
82
|
+
quantity = bigint,
|
|
83
|
+
index = number,
|
|
84
|
+
type = 'aa',
|
|
85
|
+
> = TransactionRequestBase<quantity, index, type> &
|
|
86
|
+
ExactPartial<FeeValuesEIP1559<quantity>> & {
|
|
87
|
+
accessList?: AccessList | undefined
|
|
88
|
+
authorizationList?: AuthorizationList<index, boolean> | undefined
|
|
89
|
+
calls?: readonly TxAA.Call<quantity>[] | undefined
|
|
90
|
+
feePayer?: Account | true | undefined
|
|
91
|
+
feeToken?: Address | bigint | undefined
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export type TransactionSerializable = OneOf<
|
|
95
|
+
viem_TransactionSerializable | TransactionSerializableAA
|
|
96
|
+
>
|
|
97
|
+
|
|
98
|
+
export type TransactionSerializableAA<
|
|
99
|
+
quantity = bigint,
|
|
100
|
+
index = number,
|
|
101
|
+
> = TransactionSerializableBase<quantity, index> &
|
|
102
|
+
ExactPartial<FeeValuesEIP1559<quantity>> & {
|
|
103
|
+
accessList?: AccessList | undefined
|
|
104
|
+
authorizationList?: SignedAuthorizationList | undefined
|
|
105
|
+
calls: readonly TxAA.Call<quantity>[]
|
|
106
|
+
chainId: number
|
|
107
|
+
feeToken?: Address | bigint | undefined
|
|
108
|
+
feePayerSignature?: viem_Signature | null | undefined
|
|
109
|
+
nonceKey?: quantity | undefined
|
|
110
|
+
signature?: SignatureEnvelope.SignatureEnvelope<quantity, index> | undefined
|
|
111
|
+
validBefore?: index | undefined
|
|
112
|
+
validAfter?: index | undefined
|
|
113
|
+
type?: 'aa' | undefined
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export type TransactionSerialized<
|
|
117
|
+
type extends TransactionType = TransactionType,
|
|
118
|
+
> = viem_TransactionSerialized<type> | TransactionSerializedAA
|
|
119
|
+
|
|
120
|
+
export type TransactionSerializedAA = `0x76${string}`
|
|
121
|
+
|
|
122
|
+
export type TransactionType = viem_TransactionType | 'aa'
|
|
123
|
+
|
|
124
|
+
export function getType(
|
|
125
|
+
transaction: Record<string, unknown>,
|
|
126
|
+
): Transaction['type'] {
|
|
127
|
+
if (
|
|
128
|
+
typeof transaction.calls !== 'undefined' ||
|
|
129
|
+
typeof transaction.feePayer !== 'undefined' ||
|
|
130
|
+
typeof transaction.feeToken !== 'undefined' ||
|
|
131
|
+
typeof transaction.signature !== 'undefined' ||
|
|
132
|
+
typeof transaction.validBefore !== 'undefined' ||
|
|
133
|
+
typeof transaction.validAfter !== 'undefined'
|
|
134
|
+
)
|
|
135
|
+
return 'aa' as never
|
|
136
|
+
if (transaction.type) return transaction.type as never
|
|
137
|
+
return viem_getTransactionType(transaction) as never
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function isTempo(transaction: Record<string, unknown>) {
|
|
141
|
+
try {
|
|
142
|
+
const type = getType(transaction)
|
|
143
|
+
return type === 'aa'
|
|
144
|
+
} catch {
|
|
145
|
+
return false
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function deserialize<
|
|
150
|
+
const serialized extends TransactionSerializedGeneric,
|
|
151
|
+
>(serializedTransaction: serialized): deserialize.ReturnValue<serialized> {
|
|
152
|
+
const type = Hex.slice(serializedTransaction, 0, 1)
|
|
153
|
+
if (type === '0x76')
|
|
154
|
+
return deserializeAA(serializedTransaction as `0x76${string}`) as never
|
|
155
|
+
return viem_parseTransaction(serializedTransaction) as never
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export declare namespace deserialize {
|
|
159
|
+
export type ReturnValue<
|
|
160
|
+
serialized extends
|
|
161
|
+
TransactionSerializedGeneric = TransactionSerializedGeneric,
|
|
162
|
+
> = serialized extends TransactionSerializedAA
|
|
163
|
+
? TransactionSerializableAA
|
|
164
|
+
: ParseTransactionReturnType<serialized>
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export async function serialize(
|
|
168
|
+
transaction: TransactionSerializable & {
|
|
169
|
+
feePayer?: Account | true | undefined
|
|
170
|
+
from?: Address | undefined
|
|
171
|
+
},
|
|
172
|
+
signature?: viem_Signature | undefined,
|
|
173
|
+
) {
|
|
174
|
+
if (!isTempo(transaction))
|
|
175
|
+
return viem_serializeTransaction(transaction as never, signature)
|
|
176
|
+
|
|
177
|
+
const type = getType(transaction)
|
|
178
|
+
if (type === 'aa')
|
|
179
|
+
return serializeAA(transaction as TransactionSerializableAA, signature)
|
|
180
|
+
|
|
181
|
+
throw new Error('Unsupported transaction type')
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
////////////////////////////////////////////////////////////////////////////////////
|
|
185
|
+
// Internal
|
|
186
|
+
|
|
187
|
+
/** @internal */
|
|
188
|
+
function deserializeAA(
|
|
189
|
+
serializedTransaction: TransactionSerializedAA,
|
|
190
|
+
): TransactionSerializableAA {
|
|
191
|
+
const { authorizationList, feePayerSignature, nonce, ...tx } =
|
|
192
|
+
TxAA.deserialize(serializedTransaction)
|
|
193
|
+
return {
|
|
194
|
+
...tx,
|
|
195
|
+
authorizationList: authorizationList?.map((auth) => ({
|
|
196
|
+
...auth,
|
|
197
|
+
nonce: Number(auth.nonce ?? 0n),
|
|
198
|
+
r: Hex.fromNumber(auth.r, { size: 32 }),
|
|
199
|
+
s: Hex.fromNumber(auth.s, { size: 32 }),
|
|
200
|
+
})),
|
|
201
|
+
nonce: Number(nonce ?? 0n),
|
|
202
|
+
feePayerSignature: feePayerSignature
|
|
203
|
+
? {
|
|
204
|
+
r: Hex.fromNumber(feePayerSignature.r, { size: 32 }),
|
|
205
|
+
s: Hex.fromNumber(feePayerSignature.s, { size: 32 }),
|
|
206
|
+
yParity: feePayerSignature.yParity,
|
|
207
|
+
}
|
|
208
|
+
: feePayerSignature,
|
|
209
|
+
} satisfies TransactionSerializableAA
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** @internal */
|
|
213
|
+
async function serializeAA(
|
|
214
|
+
transaction: TransactionSerializableAA & {
|
|
215
|
+
feePayer?: Account | true | undefined
|
|
216
|
+
from?: Address | undefined
|
|
217
|
+
},
|
|
218
|
+
sig?: viem_Signature | undefined,
|
|
219
|
+
) {
|
|
220
|
+
const signature = (() => {
|
|
221
|
+
if (transaction.signature) return transaction.signature
|
|
222
|
+
if (sig)
|
|
223
|
+
return SignatureEnvelope.from({
|
|
224
|
+
r: BigInt(sig.r!),
|
|
225
|
+
s: BigInt(sig.s!),
|
|
226
|
+
yParity: Number(sig.yParity!),
|
|
227
|
+
})
|
|
228
|
+
return undefined
|
|
229
|
+
})()
|
|
230
|
+
|
|
231
|
+
const {
|
|
232
|
+
authorizationList,
|
|
233
|
+
chainId,
|
|
234
|
+
feePayer,
|
|
235
|
+
feePayerSignature,
|
|
236
|
+
nonce,
|
|
237
|
+
...rest
|
|
238
|
+
} = transaction
|
|
239
|
+
|
|
240
|
+
const transaction_ox = {
|
|
241
|
+
...rest,
|
|
242
|
+
authorizationList: authorizationList?.map((auth) => ({
|
|
243
|
+
...auth,
|
|
244
|
+
nonce: BigInt(auth.nonce),
|
|
245
|
+
r: BigInt(auth.r!),
|
|
246
|
+
s: BigInt(auth.s!),
|
|
247
|
+
yParity: Number(auth.yParity),
|
|
248
|
+
})),
|
|
249
|
+
calls: rest.calls?.length
|
|
250
|
+
? rest.calls
|
|
251
|
+
: [
|
|
252
|
+
{
|
|
253
|
+
to: rest.to || undefined,
|
|
254
|
+
value: rest.value,
|
|
255
|
+
data: rest.data,
|
|
256
|
+
},
|
|
257
|
+
],
|
|
258
|
+
chainId: Number(chainId),
|
|
259
|
+
feePayerSignature: feePayerSignature
|
|
260
|
+
? {
|
|
261
|
+
r: BigInt(feePayerSignature.r!),
|
|
262
|
+
s: BigInt(feePayerSignature.s!),
|
|
263
|
+
yParity: Number(feePayerSignature.yParity),
|
|
264
|
+
}
|
|
265
|
+
: feePayer
|
|
266
|
+
? null
|
|
267
|
+
: undefined,
|
|
268
|
+
type: 'aa',
|
|
269
|
+
...(nonce ? { nonce: BigInt(nonce) } : {}),
|
|
270
|
+
} satisfies TxAA.TransactionEnvelopeAA
|
|
271
|
+
|
|
272
|
+
if (signature && typeof transaction.feePayer === 'object') {
|
|
273
|
+
const tx = TxAA.from(transaction_ox, {
|
|
274
|
+
signature,
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
const sender = (() => {
|
|
278
|
+
if (signature.type === 'secp256k1')
|
|
279
|
+
return Secp256k1.recoverAddress({
|
|
280
|
+
payload: TxAA.getSignPayload(tx),
|
|
281
|
+
signature: signature.signature,
|
|
282
|
+
})
|
|
283
|
+
throw new Error('Unsupported signature type')
|
|
284
|
+
})()
|
|
285
|
+
|
|
286
|
+
const hash = TxAA.getFeePayerSignPayload(tx, {
|
|
287
|
+
sender,
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
const feePayerSignature = await transaction.feePayer.sign!({
|
|
291
|
+
hash,
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
return TxAA.serialize(tx, {
|
|
295
|
+
feePayerSignature: Signature.from(feePayerSignature),
|
|
296
|
+
})
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return TxAA.serialize(transaction_ox, {
|
|
300
|
+
feePayerSignature: feePayer === true ? null : undefined,
|
|
301
|
+
signature,
|
|
302
|
+
})
|
|
303
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createTransport, type Transport } from 'viem'
|
|
2
|
-
import
|
|
2
|
+
import * as Transaction from './Transaction.js'
|
|
3
3
|
|
|
4
|
-
export type
|
|
4
|
+
export type FeePayer = Transport<typeof withFeePayer.type>
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Creates a fee payer transport that routes requests between
|
|
@@ -27,8 +27,8 @@ export function withFeePayer(
|
|
|
27
27
|
method === 'eth_sendRawTransactionSync' ||
|
|
28
28
|
method === 'eth_sendRawTransaction'
|
|
29
29
|
) {
|
|
30
|
-
const serialized = (params as any)[0] as `
|
|
31
|
-
const transaction =
|
|
30
|
+
const serialized = (params as any)[0] as `0x76${string}`
|
|
31
|
+
const transaction = Transaction.deserialize(serialized)
|
|
32
32
|
// If the transaction is intended to be sponsored, forward it to the relay.
|
|
33
33
|
if (transaction.feePayerSignature === null)
|
|
34
34
|
return transport_relay.request({ method, params }, options) as never
|
|
@@ -43,5 +43,5 @@ export function withFeePayer(
|
|
|
43
43
|
export declare namespace withFeePayer {
|
|
44
44
|
export const type = 'feePayer'
|
|
45
45
|
|
|
46
|
-
export type ReturnValue =
|
|
46
|
+
export type ReturnValue = FeePayer
|
|
47
47
|
}
|