ox 0.14.12 → 0.14.14
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 +12 -0
- package/_cjs/tempo/KeyAuthorization.js +21 -12
- package/_cjs/tempo/KeyAuthorization.js.map +1 -1
- package/_cjs/tempo/RpcSchema.js +3 -0
- package/_cjs/tempo/RpcSchema.js.map +1 -0
- package/_cjs/tempo/index.js +2 -1
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/tempo/KeyAuthorization.js +23 -14
- package/_esm/tempo/KeyAuthorization.js.map +1 -1
- package/_esm/tempo/RpcSchema.js +2 -0
- package/_esm/tempo/RpcSchema.js.map +1 -0
- package/_esm/tempo/index.js +19 -0
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/core/RpcSchema.d.ts +64 -0
- package/_types/core/RpcSchema.d.ts.map +1 -1
- package/_types/tempo/KeyAuthorization.d.ts +11 -7
- package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
- package/_types/tempo/RpcSchema.d.ts +70 -0
- package/_types/tempo/RpcSchema.d.ts.map +1 -0
- package/_types/tempo/index.d.ts +19 -0
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/core/RpcSchema.ts +85 -0
- package/package.json +6 -1
- package/tempo/KeyAuthorization.test.ts +105 -10
- package/tempo/KeyAuthorization.ts +37 -23
- package/tempo/RpcSchema/package.json +6 -0
- package/tempo/RpcSchema.ts +74 -0
- package/tempo/e2e.test.ts +87 -8
- package/tempo/index.ts +20 -0
- package/version.ts +1 -1
package/tempo/e2e.test.ts
CHANGED
|
@@ -781,6 +781,87 @@ test('behavior: feePayerSignature (user → feePayer)', async () => {
|
|
|
781
781
|
expect(from).toBe(senderAddress)
|
|
782
782
|
})
|
|
783
783
|
|
|
784
|
+
test('behavior: feePayerSignature (feePayer → user)', async () => {
|
|
785
|
+
const userPrivateKey = Secp256k1.randomPrivateKey()
|
|
786
|
+
const userAddress = Address.fromPublicKey(
|
|
787
|
+
Secp256k1.getPublicKey({ privateKey: userPrivateKey }),
|
|
788
|
+
)
|
|
789
|
+
|
|
790
|
+
const feePayerPrivateKey = Secp256k1.randomPrivateKey()
|
|
791
|
+
const feePayerAddress = Address.fromPublicKey(
|
|
792
|
+
Secp256k1.getPublicKey({ privateKey: feePayerPrivateKey }),
|
|
793
|
+
)
|
|
794
|
+
|
|
795
|
+
await Promise.all([
|
|
796
|
+
fundAddress(client, { address: userAddress }),
|
|
797
|
+
fundAddress(client, { address: feePayerAddress }),
|
|
798
|
+
])
|
|
799
|
+
|
|
800
|
+
const nonce = await getTransactionCount(client, {
|
|
801
|
+
address: userAddress,
|
|
802
|
+
blockTag: 'pending',
|
|
803
|
+
})
|
|
804
|
+
|
|
805
|
+
//////////////////////////////////////////////////////////////////
|
|
806
|
+
// Fee payer flow
|
|
807
|
+
|
|
808
|
+
// 1. Build the transaction with `feePayerSignature: null` to indicate
|
|
809
|
+
// fee sponsorship intent. The user does NOT commit to `feeToken`.
|
|
810
|
+
const transaction = TxEnvelopeTempo.from({
|
|
811
|
+
calls: [
|
|
812
|
+
{
|
|
813
|
+
to: '0x0000000000000000000000000000000000000000',
|
|
814
|
+
},
|
|
815
|
+
],
|
|
816
|
+
chainId,
|
|
817
|
+
feePayerSignature: null,
|
|
818
|
+
feeToken: '0x20c0000000000000000000000000000000000001',
|
|
819
|
+
nonce: BigInt(nonce),
|
|
820
|
+
gas: 500_000n,
|
|
821
|
+
maxFeePerGas: Value.fromGwei('20'),
|
|
822
|
+
maxPriorityFeePerGas: Value.fromGwei('10'),
|
|
823
|
+
})
|
|
824
|
+
|
|
825
|
+
// 2. Fee payer signs first — commits to the sender address and fee token.
|
|
826
|
+
const feePayerSignature = Secp256k1.sign({
|
|
827
|
+
payload: TxEnvelopeTempo.getFeePayerSignPayload(transaction, {
|
|
828
|
+
sender: userAddress,
|
|
829
|
+
}),
|
|
830
|
+
privateKey: feePayerPrivateKey,
|
|
831
|
+
})
|
|
832
|
+
|
|
833
|
+
// 3. Attach fee payer signature to the transaction.
|
|
834
|
+
const transaction_feePayer = TxEnvelopeTempo.from(transaction, {
|
|
835
|
+
feePayerSignature,
|
|
836
|
+
})
|
|
837
|
+
|
|
838
|
+
//////////////////////////////////////////////////////////////////
|
|
839
|
+
// User flow
|
|
840
|
+
|
|
841
|
+
// 4. User signs second — `feePayerSignature` presence causes `feeToken`
|
|
842
|
+
// to be skipped from the user's signing payload.
|
|
843
|
+
const userSignature = Secp256k1.sign({
|
|
844
|
+
payload: TxEnvelopeTempo.getSignPayload(transaction_feePayer),
|
|
845
|
+
privateKey: userPrivateKey,
|
|
846
|
+
})
|
|
847
|
+
|
|
848
|
+
// 5. Serialize with both signatures.
|
|
849
|
+
const serialized_signed = TxEnvelopeTempo.serialize(transaction_feePayer, {
|
|
850
|
+
signature: SignatureEnvelope.from(userSignature),
|
|
851
|
+
})
|
|
852
|
+
|
|
853
|
+
const receipt = (await client
|
|
854
|
+
.request({
|
|
855
|
+
method: 'eth_sendRawTransactionSync',
|
|
856
|
+
params: [serialized_signed],
|
|
857
|
+
})
|
|
858
|
+
.then((tx) => TransactionReceipt.fromRpc(tx as any)))!
|
|
859
|
+
expect(receipt).toBeDefined()
|
|
860
|
+
expect(receipt.status).toBe('success')
|
|
861
|
+
expect(receipt.from).toBe(userAddress)
|
|
862
|
+
expect(receipt.feePayer).toBe(feePayerAddress)
|
|
863
|
+
})
|
|
864
|
+
|
|
784
865
|
describe('behavior: keyAuthorization', () => {
|
|
785
866
|
const privateKey = Secp256k1.randomPrivateKey()
|
|
786
867
|
const address = Address.fromPublicKey(Secp256k1.getPublicKey({ privateKey }))
|
|
@@ -2070,7 +2151,7 @@ describe('behavior: keyAuthorization', () => {
|
|
|
2070
2151
|
limits: [{ token, limit: Value.from('10000', 6) }],
|
|
2071
2152
|
scopes: [
|
|
2072
2153
|
{
|
|
2073
|
-
|
|
2154
|
+
address: token,
|
|
2074
2155
|
selector: AbiFunction.getSelector(transfer),
|
|
2075
2156
|
},
|
|
2076
2157
|
],
|
|
@@ -2136,9 +2217,7 @@ describe('behavior: keyAuthorization', () => {
|
|
|
2136
2217
|
|
|
2137
2218
|
expect(response.from).toBe(root.address)
|
|
2138
2219
|
expect(response.keyAuthorization).toBeDefined()
|
|
2139
|
-
expect(response.keyAuthorization?.scopes?.[0]?.
|
|
2140
|
-
token,
|
|
2141
|
-
)
|
|
2220
|
+
expect(response.keyAuthorization?.scopes?.[0]?.address).toBe(token)
|
|
2142
2221
|
expect(response.keyAuthorization?.scopes?.[0]?.selector).toBe(
|
|
2143
2222
|
'0xa9059cbb',
|
|
2144
2223
|
)
|
|
@@ -2172,7 +2251,7 @@ describe('behavior: keyAuthorization', () => {
|
|
|
2172
2251
|
limits: [{ token, limit: Value.from('10000', 6) }],
|
|
2173
2252
|
scopes: [
|
|
2174
2253
|
{
|
|
2175
|
-
|
|
2254
|
+
address: token,
|
|
2176
2255
|
selector: AbiFunction.getSelector(transfer),
|
|
2177
2256
|
recipients: [recipient],
|
|
2178
2257
|
},
|
|
@@ -2274,7 +2353,7 @@ describe('behavior: keyAuthorization', () => {
|
|
|
2274
2353
|
type: 'secp256k1',
|
|
2275
2354
|
scopes: [
|
|
2276
2355
|
{
|
|
2277
|
-
|
|
2356
|
+
address: token1,
|
|
2278
2357
|
selector: AbiFunction.getSelector(transfer),
|
|
2279
2358
|
},
|
|
2280
2359
|
],
|
|
@@ -2357,7 +2436,7 @@ describe('behavior: keyAuthorization', () => {
|
|
|
2357
2436
|
type: 'secp256k1',
|
|
2358
2437
|
scopes: [
|
|
2359
2438
|
{
|
|
2360
|
-
|
|
2439
|
+
address: token,
|
|
2361
2440
|
selector: AbiFunction.getSelector(transfer),
|
|
2362
2441
|
},
|
|
2363
2442
|
],
|
|
@@ -2439,7 +2518,7 @@ describe('behavior: keyAuthorization', () => {
|
|
|
2439
2518
|
type: 'secp256k1',
|
|
2440
2519
|
scopes: [
|
|
2441
2520
|
{
|
|
2442
|
-
|
|
2521
|
+
address: token,
|
|
2443
2522
|
selector: AbiFunction.getSelector(transfer),
|
|
2444
2523
|
recipients: [allowedRecipient],
|
|
2445
2524
|
},
|
package/tempo/index.ts
CHANGED
|
@@ -129,6 +129,26 @@ export * as Period from './Period.js'
|
|
|
129
129
|
*/
|
|
130
130
|
export * as PoolId from './PoolId.js'
|
|
131
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Union of all JSON-RPC Methods for the `tempo_` namespace.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts twoslash
|
|
137
|
+
* import { Provider, RpcSchema } from 'ox'
|
|
138
|
+
* import { RpcSchema as TempoRpcSchema } from 'ox/tempo'
|
|
139
|
+
*
|
|
140
|
+
* const schema = RpcSchema.from<
|
|
141
|
+
* | RpcSchema.Default
|
|
142
|
+
* | TempoRpcSchema.Tempo
|
|
143
|
+
* >()
|
|
144
|
+
*
|
|
145
|
+
* const provider = Provider.from(window.ethereum!, { schema })
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @category Reference
|
|
149
|
+
*/
|
|
150
|
+
export * as RpcSchema from './RpcSchema.js'
|
|
151
|
+
|
|
132
152
|
/**
|
|
133
153
|
* Signature envelope utilities for secp256k1, P256, WebAuthn, and keychain signatures.
|
|
134
154
|
*
|
package/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
export const version = '0.14.
|
|
2
|
+
export const version = '0.14.14'
|