tempo.ts 0.7.6 → 0.8.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 +32 -0
- package/dist/chains.d.ts +6 -20
- package/dist/chains.d.ts.map +1 -1
- package/dist/chains.js +14 -15
- package/dist/chains.js.map +1 -1
- package/dist/ox/KeyAuthorization.d.ts +356 -0
- package/dist/ox/KeyAuthorization.d.ts.map +1 -0
- package/dist/ox/KeyAuthorization.js +360 -0
- package/dist/ox/KeyAuthorization.js.map +1 -0
- package/dist/ox/SignatureEnvelope.d.ts +21 -6
- package/dist/ox/SignatureEnvelope.d.ts.map +1 -1
- package/dist/ox/SignatureEnvelope.js +43 -3
- package/dist/ox/SignatureEnvelope.js.map +1 -1
- package/dist/ox/Transaction.d.ts +5 -1
- package/dist/ox/Transaction.d.ts.map +1 -1
- package/dist/ox/Transaction.js +5 -0
- package/dist/ox/Transaction.js.map +1 -1
- package/dist/ox/TransactionEnvelopeAA.d.ts +9 -0
- package/dist/ox/TransactionEnvelopeAA.d.ts.map +1 -1
- package/dist/ox/TransactionEnvelopeAA.js +17 -4
- package/dist/ox/TransactionEnvelopeAA.js.map +1 -1
- package/dist/ox/TransactionRequest.d.ts +7 -1
- package/dist/ox/TransactionRequest.d.ts.map +1 -1
- package/dist/ox/TransactionRequest.js +12 -0
- package/dist/ox/TransactionRequest.js.map +1 -1
- package/dist/ox/index.d.ts +1 -0
- package/dist/ox/index.d.ts.map +1 -1
- package/dist/ox/index.js +1 -0
- package/dist/ox/index.js.map +1 -1
- package/dist/prool/Instance.js +1 -1
- package/dist/prool/Instance.js.map +1 -1
- package/{src/prool/internal → dist/prool}/chain.json +4 -2
- package/dist/viem/Abis.d.ts +319 -6
- package/dist/viem/Abis.d.ts.map +1 -1
- package/dist/viem/Abis.js +199 -7
- package/dist/viem/Abis.js.map +1 -1
- package/dist/viem/Account.d.ts +103 -14
- package/dist/viem/Account.d.ts.map +1 -1
- package/dist/viem/Account.js +177 -23
- package/dist/viem/Account.js.map +1 -1
- package/dist/viem/Actions/account.d.ts.map +1 -1
- package/dist/viem/Actions/account.js +4 -5
- package/dist/viem/Actions/account.js.map +1 -1
- package/dist/viem/Actions/amm.d.ts +72 -0
- package/dist/viem/Actions/amm.d.ts.map +1 -1
- package/dist/viem/Actions/dex.d.ts +156 -4
- package/dist/viem/Actions/dex.d.ts.map +1 -1
- package/dist/viem/Actions/fee.d.ts +4 -0
- package/dist/viem/Actions/fee.d.ts.map +1 -1
- package/dist/viem/Actions/reward.d.ts +158 -0
- package/dist/viem/Actions/reward.d.ts.map +1 -1
- package/dist/viem/Actions/reward.js +54 -0
- package/dist/viem/Actions/reward.js.map +1 -1
- package/dist/viem/Actions/token.d.ts +585 -0
- package/dist/viem/Actions/token.d.ts.map +1 -1
- package/dist/viem/Actions/token.js +2 -2
- package/dist/viem/Actions/token.js.map +1 -1
- package/dist/viem/Addresses.d.ts +1 -1
- package/dist/viem/Addresses.d.ts.map +1 -1
- package/dist/viem/Addresses.js +1 -1
- package/dist/viem/Addresses.js.map +1 -1
- package/dist/viem/Chain.d.ts +35 -0
- package/dist/viem/Chain.d.ts.map +1 -1
- package/dist/viem/Chain.js +37 -0
- package/dist/viem/Chain.js.map +1 -1
- package/dist/viem/Decorator.d.ts +74 -0
- package/dist/viem/Decorator.d.ts.map +1 -1
- package/dist/viem/Decorator.js +3 -0
- package/dist/viem/Decorator.js.map +1 -1
- package/dist/viem/Formatters.d.ts.map +1 -1
- package/dist/viem/Formatters.js +8 -7
- package/dist/viem/Formatters.js.map +1 -1
- package/dist/viem/Storage.d.ts +1 -0
- package/dist/viem/Storage.d.ts.map +1 -1
- package/dist/viem/Storage.js +21 -0
- package/dist/viem/Storage.js.map +1 -1
- package/dist/viem/TokenIds.d.ts +1 -1
- package/dist/viem/TokenIds.d.ts.map +1 -1
- package/dist/viem/TokenIds.js +1 -1
- package/dist/viem/TokenIds.js.map +1 -1
- package/dist/viem/Transaction.d.ts +9 -1
- package/dist/viem/Transaction.d.ts.map +1 -1
- package/dist/viem/Transaction.js +2 -1
- package/dist/viem/Transaction.js.map +1 -1
- package/dist/viem/WebAuthnP256.d.ts +4 -1
- package/dist/viem/WebAuthnP256.d.ts.map +1 -1
- package/dist/viem/WebAuthnP256.js +3 -1
- package/dist/viem/WebAuthnP256.js.map +1 -1
- package/dist/wagmi/Actions/reward.d.ts +44 -0
- package/dist/wagmi/Actions/reward.d.ts.map +1 -1
- package/dist/wagmi/Actions/reward.js +49 -0
- package/dist/wagmi/Actions/reward.js.map +1 -1
- package/dist/wagmi/Connector.d.ts +25 -8
- package/dist/wagmi/Connector.d.ts.map +1 -1
- package/dist/wagmi/Connector.js +120 -27
- package/dist/wagmi/Connector.js.map +1 -1
- package/dist/wagmi/Hooks/reward.d.ts +32 -0
- package/dist/wagmi/Hooks/reward.d.ts.map +1 -1
- package/dist/wagmi/Hooks/reward.js +39 -0
- package/dist/wagmi/Hooks/reward.js.map +1 -1
- package/package.json +3 -2
- package/src/chains.ts +14 -15
- package/src/ox/KeyAuthorization.test.ts +1332 -0
- package/src/ox/KeyAuthorization.ts +542 -0
- package/src/ox/SignatureEnvelope.test.ts +624 -0
- package/src/ox/SignatureEnvelope.ts +89 -9
- package/src/ox/Transaction.test.ts +214 -0
- package/src/ox/Transaction.ts +13 -1
- package/src/ox/TransactionEnvelopeAA.test.ts +164 -4
- package/src/ox/TransactionEnvelopeAA.ts +36 -3
- package/src/ox/TransactionRequest.ts +22 -1
- package/src/ox/e2e.test.ts +612 -5
- package/src/ox/index.ts +1 -0
- package/src/prool/Instance.ts +1 -1
- package/src/prool/chain.json +238 -0
- package/src/server/Handler.test.ts +20 -36
- package/src/viem/Abis.ts +200 -7
- package/src/viem/Account.test.ts +444 -0
- package/src/viem/Account.ts +355 -42
- package/src/viem/Actions/account.ts +3 -5
- package/src/viem/Actions/amm.test.ts +4 -4
- package/src/viem/Actions/reward.test.ts +84 -0
- package/src/viem/Actions/reward.ts +73 -0
- package/src/viem/Actions/token.test.ts +8 -8
- package/src/viem/Actions/token.ts +2 -2
- package/src/viem/Addresses.ts +1 -1
- package/src/viem/Chain.test.ts +168 -0
- package/src/viem/Chain.ts +37 -1
- package/src/viem/Decorator.ts +84 -0
- package/src/viem/Formatters.ts +8 -7
- package/src/viem/Storage.ts +22 -0
- package/src/viem/TokenIds.ts +1 -1
- package/src/viem/Transaction.ts +14 -2
- package/src/viem/WebAuthnP256.ts +8 -2
- package/src/viem/e2e.test.ts +299 -96
- package/src/wagmi/Actions/amm.test.ts +2 -2
- package/src/wagmi/Actions/reward.test.ts +36 -0
- package/src/wagmi/Actions/reward.ts +91 -0
- package/src/wagmi/Connector.test.ts +1 -1
- package/src/wagmi/Connector.ts +184 -54
- package/src/wagmi/Hooks/amm.test.ts +4 -4
- package/src/wagmi/Hooks/fee.test.ts +10 -4
- package/src/wagmi/Hooks/reward.test.ts +72 -0
- package/src/wagmi/Hooks/reward.ts +68 -0
- package/src/wagmi/Hooks/token.test.ts +0 -488
- package/dist/viem/internal/account.d.ts +0 -21
- package/dist/viem/internal/account.d.ts.map +0 -1
- package/dist/viem/internal/account.js +0 -61
- package/dist/viem/internal/account.js.map +0 -1
- package/src/viem/internal/account.ts +0 -89
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Hex, P256, Rlp, Secp256k1, Value } from 'ox'
|
|
1
|
+
import { Hex, P256, Rlp, Secp256k1, Value, WebAuthnP256 } from 'ox'
|
|
2
2
|
import { describe, expect, test } from 'vitest'
|
|
3
3
|
import { SignatureEnvelope } from './index.js'
|
|
4
|
+
import * as KeyAuthorization from './KeyAuthorization.js'
|
|
4
5
|
import * as TransactionEnvelopeAA from './TransactionEnvelopeAA.js'
|
|
5
6
|
|
|
6
7
|
const privateKey =
|
|
@@ -254,6 +255,37 @@ describe('deserialize', () => {
|
|
|
254
255
|
)
|
|
255
256
|
})
|
|
256
257
|
|
|
258
|
+
test('keyAuthorization', () => {
|
|
259
|
+
const keyAuthorization = KeyAuthorization.from({
|
|
260
|
+
expiry: 1234567890,
|
|
261
|
+
address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
|
|
262
|
+
type: 'secp256k1',
|
|
263
|
+
limits: [
|
|
264
|
+
{
|
|
265
|
+
token: '0x20c0000000000000000000000000000000000001',
|
|
266
|
+
limit: Value.from('10', 6),
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
signature: SignatureEnvelope.from({
|
|
270
|
+
r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
|
|
271
|
+
s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
|
|
272
|
+
yParity: 0,
|
|
273
|
+
}),
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
const transaction_keyAuthorization = TransactionEnvelopeAA.from({
|
|
277
|
+
...transaction,
|
|
278
|
+
keyAuthorization,
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
const serialized = TransactionEnvelopeAA.serialize(
|
|
282
|
+
transaction_keyAuthorization,
|
|
283
|
+
)
|
|
284
|
+
expect(TransactionEnvelopeAA.deserialize(serialized)).toEqual(
|
|
285
|
+
transaction_keyAuthorization,
|
|
286
|
+
)
|
|
287
|
+
})
|
|
288
|
+
|
|
257
289
|
describe('signature', () => {
|
|
258
290
|
test('secp256k1', () => {
|
|
259
291
|
const signature = Secp256k1.sign({
|
|
@@ -456,7 +488,7 @@ describe('deserialize', () => {
|
|
|
456
488
|
[TransactionEnvelope.InvalidSerializedError: Invalid serialized transaction of type "aa" was provided.
|
|
457
489
|
|
|
458
490
|
Serialized Transaction: "0x76c0"
|
|
459
|
-
Missing Attributes: chainId, maxPriorityFeePerGas, maxFeePerGas, gas, calls, accessList, nonceKey, nonce, validBefore, validAfter, feeToken, feePayerSignatureOrSender]
|
|
491
|
+
Missing Attributes: chainId, maxPriorityFeePerGas, maxFeePerGas, gas, calls, accessList, keyAuthorization, nonceKey, nonce, validBefore, validAfter, feeToken, feePayerSignatureOrSender]
|
|
460
492
|
`)
|
|
461
493
|
})
|
|
462
494
|
|
|
@@ -469,7 +501,7 @@ describe('deserialize', () => {
|
|
|
469
501
|
[TransactionEnvelope.InvalidSerializedError: Invalid serialized transaction of type "aa" was provided.
|
|
470
502
|
|
|
471
503
|
Serialized Transaction: "0x76c20001"
|
|
472
|
-
Missing Attributes: maxFeePerGas, gas, calls, accessList, nonceKey, nonce, validBefore, validAfter, feeToken, feePayerSignatureOrSender]
|
|
504
|
+
Missing Attributes: maxFeePerGas, gas, calls, accessList, keyAuthorization, nonceKey, nonce, validBefore, validAfter, feeToken, feePayerSignatureOrSender]
|
|
473
505
|
`)
|
|
474
506
|
})
|
|
475
507
|
|
|
@@ -520,6 +552,7 @@ describe('deserialize', () => {
|
|
|
520
552
|
'0x', // feeToken
|
|
521
553
|
'0x', // feePayerSignature
|
|
522
554
|
[], // authorizationList
|
|
555
|
+
[], // keyAuthorization
|
|
523
556
|
'0x1234', // signature
|
|
524
557
|
'0x5678', // extra field
|
|
525
558
|
]).slice(2)}`,
|
|
@@ -527,7 +560,7 @@ describe('deserialize', () => {
|
|
|
527
560
|
).toThrowErrorMatchingInlineSnapshot(`
|
|
528
561
|
[TransactionEnvelope.InvalidSerializedError: Invalid serialized transaction of type "aa" was provided.
|
|
529
562
|
|
|
530
|
-
Serialized Transaction: "
|
|
563
|
+
Serialized Transaction: "0x76ec01010101d8d7940000000000000000000000000000000000000000008080000080808080c0c0821234825678"]
|
|
531
564
|
`)
|
|
532
565
|
})
|
|
533
566
|
})
|
|
@@ -764,6 +797,133 @@ describe('serialize', () => {
|
|
|
764
797
|
)
|
|
765
798
|
})
|
|
766
799
|
|
|
800
|
+
test('keyAuthorization (secp256k1)', () => {
|
|
801
|
+
const keyAuthorization = KeyAuthorization.from({
|
|
802
|
+
address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
|
|
803
|
+
expiry: 1234567890,
|
|
804
|
+
type: 'secp256k1',
|
|
805
|
+
limits: [
|
|
806
|
+
{
|
|
807
|
+
token: '0x20c0000000000000000000000000000000000001',
|
|
808
|
+
limit: Value.from('10', 6),
|
|
809
|
+
},
|
|
810
|
+
],
|
|
811
|
+
signature: SignatureEnvelope.from({
|
|
812
|
+
r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
|
|
813
|
+
s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
|
|
814
|
+
yParity: 0,
|
|
815
|
+
}),
|
|
816
|
+
})
|
|
817
|
+
|
|
818
|
+
const transaction = TransactionEnvelopeAA.from({
|
|
819
|
+
chainId: 1,
|
|
820
|
+
calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' }],
|
|
821
|
+
nonce: 0n,
|
|
822
|
+
keyAuthorization,
|
|
823
|
+
})
|
|
824
|
+
|
|
825
|
+
const serialized = TransactionEnvelopeAA.serialize(transaction)
|
|
826
|
+
expect(serialized).toMatchInlineSnapshot(
|
|
827
|
+
`"0x76f8a201808080d8d79470997970c51812dc3a010c7d01b50e0d17dc79c88080c0808080808080c0f87bf7808094be95c3f554e9fc85ec51be69a3d807a0d55bcf2c84499602d2dad99420c000000000000000000000000000000000000183989680b841635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f05401b"`,
|
|
828
|
+
)
|
|
829
|
+
|
|
830
|
+
const deserialized = TransactionEnvelopeAA.deserialize(serialized)
|
|
831
|
+
expect(deserialized.keyAuthorization).toEqual(keyAuthorization)
|
|
832
|
+
})
|
|
833
|
+
|
|
834
|
+
test('keyAuthorization (p256)', () => {
|
|
835
|
+
const keyAuthorization = KeyAuthorization.from({
|
|
836
|
+
address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
|
|
837
|
+
expiry: 1234567890,
|
|
838
|
+
type: 'p256',
|
|
839
|
+
limits: [
|
|
840
|
+
{
|
|
841
|
+
token: '0x20c0000000000000000000000000000000000001',
|
|
842
|
+
limit: Value.from('10', 6),
|
|
843
|
+
},
|
|
844
|
+
],
|
|
845
|
+
signature: SignatureEnvelope.from({
|
|
846
|
+
signature: {
|
|
847
|
+
r: 92602584010956101470289867944347135737570451066466093224269890121909314569518n,
|
|
848
|
+
s: 54171125190222965779385658110416711469231271457324878825831748147306957269813n,
|
|
849
|
+
},
|
|
850
|
+
publicKey: {
|
|
851
|
+
prefix: 4,
|
|
852
|
+
x: 78495282704852028275327922540131762143565388050940484317945369745559774511861n,
|
|
853
|
+
y: 8109764566587999957624872393871720746996669263962991155166704261108473113504n,
|
|
854
|
+
},
|
|
855
|
+
prehash: true,
|
|
856
|
+
}),
|
|
857
|
+
})
|
|
858
|
+
|
|
859
|
+
const transaction = TransactionEnvelopeAA.from({
|
|
860
|
+
chainId: 1,
|
|
861
|
+
calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' }],
|
|
862
|
+
nonce: 0n,
|
|
863
|
+
keyAuthorization,
|
|
864
|
+
})
|
|
865
|
+
|
|
866
|
+
const serialized = TransactionEnvelopeAA.serialize(transaction)
|
|
867
|
+
expect(serialized).toMatchInlineSnapshot(
|
|
868
|
+
`"0x76f8e301808080d8d79470997970c51812dc3a010c7d01b50e0d17dc79c88080c0808080808080c0f8bcf7800194be95c3f554e9fc85ec51be69a3d807a0d55bcf2c84499602d2dad99420c000000000000000000000000000000000000183989680b88201ccbb3485d4726235f13cb15ef394fb7158179fb7b1925eccec0147671090c52e77c3c53373cc1e3b05e7c23f609deb17cea8fe097300c45411237e9fe4166b35ad8ac16e167d6992c3e120d7f17d2376bc1cbcf30c46ba6dd00ce07303e742f511edf6ce1c32de66846f56afa7be1cbd729bc35750b6d0cdcf3ec9d75461aba001"`,
|
|
869
|
+
)
|
|
870
|
+
|
|
871
|
+
const deserialized = TransactionEnvelopeAA.deserialize(serialized)
|
|
872
|
+
expect(deserialized.keyAuthorization).toEqual(keyAuthorization)
|
|
873
|
+
})
|
|
874
|
+
|
|
875
|
+
test('keyAuthorization (webAuthn)', () => {
|
|
876
|
+
const metadata = {
|
|
877
|
+
authenticatorData: WebAuthnP256.getAuthenticatorData({
|
|
878
|
+
rpId: 'localhost',
|
|
879
|
+
}),
|
|
880
|
+
clientDataJSON: WebAuthnP256.getClientDataJSON({
|
|
881
|
+
challenge: '0xdeadbeef',
|
|
882
|
+
origin: 'http://localhost',
|
|
883
|
+
}),
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
const keyAuthorization = KeyAuthorization.from({
|
|
887
|
+
address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
|
|
888
|
+
expiry: 1234567890,
|
|
889
|
+
type: 'webAuthn',
|
|
890
|
+
limits: [
|
|
891
|
+
{
|
|
892
|
+
token: '0x20c0000000000000000000000000000000000001',
|
|
893
|
+
limit: Value.from('10', 6),
|
|
894
|
+
},
|
|
895
|
+
],
|
|
896
|
+
signature: SignatureEnvelope.from({
|
|
897
|
+
signature: {
|
|
898
|
+
r: 92602584010956101470289867944347135737570451066466093224269890121909314569518n,
|
|
899
|
+
s: 54171125190222965779385658110416711469231271457324878825831748147306957269813n,
|
|
900
|
+
},
|
|
901
|
+
publicKey: {
|
|
902
|
+
prefix: 4,
|
|
903
|
+
x: 78495282704852028275327922540131762143565388050940484317945369745559774511861n,
|
|
904
|
+
y: 8109764566587999957624872393871720746996669263962991155166704261108473113504n,
|
|
905
|
+
},
|
|
906
|
+
metadata,
|
|
907
|
+
}),
|
|
908
|
+
})
|
|
909
|
+
|
|
910
|
+
const transaction = TransactionEnvelopeAA.from({
|
|
911
|
+
chainId: 1,
|
|
912
|
+
calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' }],
|
|
913
|
+
nonce: 0n,
|
|
914
|
+
keyAuthorization,
|
|
915
|
+
})
|
|
916
|
+
|
|
917
|
+
const serialized = TransactionEnvelopeAA.serialize(transaction)
|
|
918
|
+
expect(serialized).toMatchInlineSnapshot(
|
|
919
|
+
`"0x76f9016501808080d8d79470997970c51812dc3a010c7d01b50e0d17dc79c88080c0808080808080c0f9013df7800294be95c3f554e9fc85ec51be69a3d807a0d55bcf2c84499602d2dad99420c000000000000000000000000000000000000183989680b901020249960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d976305000000007b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a223371322d3777222c226f726967696e223a22687474703a2f2f6c6f63616c686f7374222c2263726f73734f726967696e223a66616c73657dccbb3485d4726235f13cb15ef394fb7158179fb7b1925eccec0147671090c52e77c3c53373cc1e3b05e7c23f609deb17cea8fe097300c45411237e9fe4166b35ad8ac16e167d6992c3e120d7f17d2376bc1cbcf30c46ba6dd00ce07303e742f511edf6ce1c32de66846f56afa7be1cbd729bc35750b6d0cdcf3ec9d75461aba0"`,
|
|
920
|
+
)
|
|
921
|
+
|
|
922
|
+
// Verify roundtrip
|
|
923
|
+
const deserialized = TransactionEnvelopeAA.deserialize(serialized)
|
|
924
|
+
expect(deserialized.keyAuthorization).toEqual(keyAuthorization)
|
|
925
|
+
})
|
|
926
|
+
|
|
767
927
|
describe('with signature', () => {
|
|
768
928
|
test('secp256k1', () => {
|
|
769
929
|
const transaction = TransactionEnvelopeAA.from({
|
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
PartialBy,
|
|
15
15
|
UnionPartialBy,
|
|
16
16
|
} from '../internal/types.js'
|
|
17
|
+
import * as KeyAuthorization from './KeyAuthorization.js'
|
|
17
18
|
import * as SignatureEnvelope from './SignatureEnvelope.js'
|
|
18
19
|
import * as TokenId from './TokenId.js'
|
|
19
20
|
|
|
@@ -57,6 +58,16 @@ export type TransactionEnvelopeAA<
|
|
|
57
58
|
| undefined
|
|
58
59
|
/** Fee token preference. Address or ID of the TIP-20 token. */
|
|
59
60
|
feeToken?: TokenId.TokenIdOrAddress | undefined
|
|
61
|
+
/**
|
|
62
|
+
* Key authorization for provisioning a new access key.
|
|
63
|
+
*
|
|
64
|
+
* When present, this transaction will add the specified key to the AccountKeychain precompile,
|
|
65
|
+
* before verifying the transaction signature.
|
|
66
|
+
* The authorization must be signed with the root key, the tx can be signed by the Keychain signature.
|
|
67
|
+
*/
|
|
68
|
+
keyAuthorization?:
|
|
69
|
+
| KeyAuthorization.Signed<bigintType, numberType>
|
|
70
|
+
| undefined
|
|
60
71
|
/** Total fee per gas in wei (gasPrice/baseFeePerGas + maxPriorityFeePerGas). */
|
|
61
72
|
maxFeePerGas?: bigintType | undefined
|
|
62
73
|
/** Max priority fee per gas (in wei). */
|
|
@@ -216,10 +227,24 @@ export function deserialize(
|
|
|
216
227
|
feeToken,
|
|
217
228
|
feePayerSignatureOrSender,
|
|
218
229
|
_authorizationList, // TODO: add
|
|
219
|
-
|
|
230
|
+
keyAuthorizationOrSignature,
|
|
231
|
+
maybeSignature,
|
|
220
232
|
] = transactionArray as readonly Hex.Hex[]
|
|
221
233
|
|
|
222
|
-
|
|
234
|
+
const keyAuthorization = Array.isArray(keyAuthorizationOrSignature)
|
|
235
|
+
? keyAuthorizationOrSignature
|
|
236
|
+
: undefined
|
|
237
|
+
const signature = keyAuthorization
|
|
238
|
+
? maybeSignature
|
|
239
|
+
: keyAuthorizationOrSignature
|
|
240
|
+
|
|
241
|
+
if (
|
|
242
|
+
!(
|
|
243
|
+
transactionArray.length === 13 ||
|
|
244
|
+
transactionArray.length === 14 ||
|
|
245
|
+
transactionArray.length === 15
|
|
246
|
+
)
|
|
247
|
+
)
|
|
223
248
|
throw new TransactionEnvelope.InvalidSerializedError({
|
|
224
249
|
attributes: {
|
|
225
250
|
chainId,
|
|
@@ -228,6 +253,7 @@ export function deserialize(
|
|
|
228
253
|
gas,
|
|
229
254
|
calls,
|
|
230
255
|
accessList,
|
|
256
|
+
keyAuthorization,
|
|
231
257
|
nonceKey,
|
|
232
258
|
nonce,
|
|
233
259
|
validBefore,
|
|
@@ -296,6 +322,11 @@ export function deserialize(
|
|
|
296
322
|
)
|
|
297
323
|
}
|
|
298
324
|
|
|
325
|
+
if (keyAuthorization)
|
|
326
|
+
transaction.keyAuthorization = KeyAuthorization.fromTuple(
|
|
327
|
+
keyAuthorization as never,
|
|
328
|
+
)
|
|
329
|
+
|
|
299
330
|
const signatureEnvelope = signature
|
|
300
331
|
? SignatureEnvelope.deserialize(signature)
|
|
301
332
|
: undefined
|
|
@@ -516,6 +547,7 @@ export function serialize(
|
|
|
516
547
|
chainId,
|
|
517
548
|
feeToken,
|
|
518
549
|
gas,
|
|
550
|
+
keyAuthorization,
|
|
519
551
|
nonce,
|
|
520
552
|
nonceKey,
|
|
521
553
|
maxFeePerGas,
|
|
@@ -562,7 +594,8 @@ export function serialize(
|
|
|
562
594
|
? TokenId.toAddress(feeToken)
|
|
563
595
|
: '0x',
|
|
564
596
|
feePayerSignatureOrSender,
|
|
565
|
-
[], // TODO:
|
|
597
|
+
[], // TODO: authList
|
|
598
|
+
...(keyAuthorization ? [KeyAuthorization.toTuple(keyAuthorization)] : []),
|
|
566
599
|
...(signature
|
|
567
600
|
? [SignatureEnvelope.serialize(SignatureEnvelope.from(signature))]
|
|
568
601
|
: []),
|
|
@@ -3,6 +3,7 @@ import type * as Errors from 'ox/Errors'
|
|
|
3
3
|
import * as Hex from 'ox/Hex'
|
|
4
4
|
import * as ox_TransactionRequest from 'ox/TransactionRequest'
|
|
5
5
|
import type { Compute } from '../internal/types.js'
|
|
6
|
+
import * as KeyAuthorization from './KeyAuthorization.js'
|
|
6
7
|
import * as TokenId from './TokenId.js'
|
|
7
8
|
import * as Transaction from './Transaction.js'
|
|
8
9
|
import type { Call } from './TransactionEnvelopeAA.js'
|
|
@@ -17,16 +18,24 @@ export type TransactionRequest<
|
|
|
17
18
|
> = Compute<
|
|
18
19
|
ox_TransactionRequest.TransactionRequest<bigintType, numberType, type> & {
|
|
19
20
|
calls?: readonly Call<bigintType>[] | undefined
|
|
21
|
+
keyAuthorization?: KeyAuthorization.KeyAuthorization<true> | undefined
|
|
20
22
|
keyData?: Hex.Hex | undefined
|
|
21
23
|
keyType?: KeyType | undefined
|
|
22
24
|
feeToken?: TokenId.TokenIdOrAddress | undefined
|
|
25
|
+
nonceKey?: 'random' | bigintType | undefined
|
|
23
26
|
validBefore?: numberType | undefined
|
|
24
27
|
validAfter?: numberType | undefined
|
|
25
28
|
}
|
|
26
29
|
>
|
|
27
30
|
|
|
28
31
|
/** RPC representation of a {@link ox#TransactionRequest.TransactionRequest}. */
|
|
29
|
-
export type Rpc =
|
|
32
|
+
export type Rpc = Omit<
|
|
33
|
+
TransactionRequest<Hex.Hex, Hex.Hex, string>,
|
|
34
|
+
'keyAuthorization'
|
|
35
|
+
> & {
|
|
36
|
+
keyAuthorization?: KeyAuthorization.Rpc | undefined
|
|
37
|
+
nonceKey?: Hex.Hex | undefined
|
|
38
|
+
}
|
|
30
39
|
|
|
31
40
|
/**
|
|
32
41
|
* Converts a {@link ox#TransactionRequest.TransactionRequest} to a {@link ox#TransactionRequest.Rpc}.
|
|
@@ -82,11 +91,23 @@ export function toRpc(request: TransactionRequest): Rpc {
|
|
|
82
91
|
}))
|
|
83
92
|
if (typeof request.feeToken !== 'undefined')
|
|
84
93
|
request_rpc.feeToken = TokenId.toAddress(request.feeToken)
|
|
94
|
+
if (request.keyAuthorization)
|
|
95
|
+
request_rpc.keyAuthorization = KeyAuthorization.toRpc(
|
|
96
|
+
request.keyAuthorization,
|
|
97
|
+
)
|
|
85
98
|
if (typeof request.validBefore !== 'undefined')
|
|
86
99
|
request_rpc.validBefore = Hex.fromNumber(request.validBefore)
|
|
87
100
|
if (typeof request.validAfter !== 'undefined')
|
|
88
101
|
request_rpc.validAfter = Hex.fromNumber(request.validAfter)
|
|
89
102
|
|
|
103
|
+
const nonceKey = (() => {
|
|
104
|
+
if (request.nonceKey === 'random') return Hex.random(6)
|
|
105
|
+
if (typeof request.nonceKey === 'bigint')
|
|
106
|
+
return Hex.fromNumber(request.nonceKey)
|
|
107
|
+
return undefined
|
|
108
|
+
})()
|
|
109
|
+
if (nonceKey) request_rpc.nonceKey = nonceKey
|
|
110
|
+
|
|
90
111
|
if (
|
|
91
112
|
request.calls ||
|
|
92
113
|
typeof request.feeToken !== 'undefined' ||
|