ox 1.0.0-beta.20 → 1.0.0-beta.21
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/tempo/TransactionReceipt.d.ts +3 -3
- package/dist/tempo/TransactionReceipt.d.ts.map +1 -1
- package/dist/tempo/TransactionReceipt.js +8 -1
- package/dist/tempo/TransactionReceipt.js.map +1 -1
- package/package.json +1 -1
- package/src/tempo/TransactionReceipt.test.ts +76 -0
- package/src/tempo/TransactionReceipt.ts +11 -5
- package/src/tempo/e2e.test.ts +7 -7
- package/src/version.ts +1 -1
|
@@ -10,13 +10,13 @@ import * as ox_TransactionReceipt from '../core/TransactionReceipt.js';
|
|
|
10
10
|
*
|
|
11
11
|
* @see {@link https://docs.tempo.xyz/protocol/transactions}
|
|
12
12
|
*/
|
|
13
|
-
export type TransactionReceipt<status = ox_TransactionReceipt.Status, type =
|
|
13
|
+
export type TransactionReceipt<status = ox_TransactionReceipt.Status, type = Type, bigintType = bigint, numberType = number> = Compute<ox_TransactionReceipt.TransactionReceipt<status, type, bigintType, numberType> & {
|
|
14
14
|
/** Address of the fee payer. */
|
|
15
15
|
feePayer?: Address.Address | undefined;
|
|
16
16
|
/** Address of the fee token. */
|
|
17
17
|
feeToken?: Address.Address | undefined;
|
|
18
18
|
}>;
|
|
19
|
-
export type Rpc = TransactionReceipt<ox_TransactionReceipt.RpcStatus,
|
|
19
|
+
export type Rpc = TransactionReceipt<ox_TransactionReceipt.RpcStatus, RpcType, Hex.Hex, Hex.Hex>;
|
|
20
20
|
export type Type = 'tempo' | ox_TransactionReceipt.Type;
|
|
21
21
|
export type RpcType = '0x76' | ox_TransactionReceipt.RpcType;
|
|
22
22
|
export type Status = ox_TransactionReceipt.Status;
|
|
@@ -161,7 +161,7 @@ export declare namespace fromRpc {
|
|
|
161
161
|
export declare function toRpc(receipt: toRpc.Input): Rpc;
|
|
162
162
|
export declare namespace toRpc {
|
|
163
163
|
/** Numberish input accepted by {@link ox#TransactionReceipt.(toRpc:function)}. */
|
|
164
|
-
type Input = TransactionReceipt<ox_TransactionReceipt.Status,
|
|
164
|
+
type Input = TransactionReceipt<ox_TransactionReceipt.Status, Type, Hex.Hex | bigint | number, Hex.Hex | number>;
|
|
165
165
|
type ErrorType = ox_TransactionReceipt.toRpc.ErrorType;
|
|
166
166
|
}
|
|
167
167
|
//# sourceMappingURL=TransactionReceipt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionReceipt.d.ts","sourceRoot":"","sources":["../../src/tempo/TransactionReceipt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,KAAK,GAAG,MAAM,gBAAgB,CAAA;AAC1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,KAAK,qBAAqB,MAAM,+BAA+B,CAAA;AAEtE;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,CAC5B,MAAM,GAAG,qBAAqB,CAAC,MAAM,EACrC,IAAI,GAAG,
|
|
1
|
+
{"version":3,"file":"TransactionReceipt.d.ts","sourceRoot":"","sources":["../../src/tempo/TransactionReceipt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,KAAK,GAAG,MAAM,gBAAgB,CAAA;AAC1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,KAAK,qBAAqB,MAAM,+BAA+B,CAAA;AAEtE;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,CAC5B,MAAM,GAAG,qBAAqB,CAAC,MAAM,EACrC,IAAI,GAAG,IAAI,EACX,UAAU,GAAG,MAAM,EACnB,UAAU,GAAG,MAAM,IACjB,OAAO,CACT,qBAAqB,CAAC,kBAAkB,CACtC,MAAM,EACN,IAAI,EACJ,UAAU,EACV,UAA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AAK,CAAC;IAC7B,kFAAkF;IAClF,KAAY,KAAK,GAAG,kBAAkB,CACpC,qBAAqB,CAAC,MAAM,EAC5B,IAAI,EACJ,GAAG,CAAC,GAAG,GAAG,MAAM,GAAG,MAAM,EACzB,GAAG,CAAC,GAAG,GAAG,MAAM,CACjB,CAAA;IAED,KAAY,SAAS,GAAG,qBAAqB,CAAC,KAAK,CAAC,SAAS,CAAA;CAC9D"}
|
|
@@ -68,7 +68,13 @@ export const toRpcType = {
|
|
|
68
68
|
* @returns A TransactionReceipt.
|
|
69
69
|
*/
|
|
70
70
|
export function fromRpc(receipt) {
|
|
71
|
-
|
|
71
|
+
const decoded = ox_TransactionReceipt.fromRpc(receipt);
|
|
72
|
+
if (!decoded)
|
|
73
|
+
return null;
|
|
74
|
+
return {
|
|
75
|
+
...decoded,
|
|
76
|
+
type: fromRpcType[receipt.type] ?? receipt.type,
|
|
77
|
+
};
|
|
72
78
|
}
|
|
73
79
|
/**
|
|
74
80
|
* Converts a TransactionReceipt to an RPC receipt.
|
|
@@ -133,6 +139,7 @@ export function toRpc(receipt) {
|
|
|
133
139
|
...rpc,
|
|
134
140
|
feePayer: receipt.feePayer,
|
|
135
141
|
feeToken: receipt.feeToken,
|
|
142
|
+
type: toRpcType[receipt.type] ?? receipt.type,
|
|
136
143
|
};
|
|
137
144
|
}
|
|
138
145
|
//# sourceMappingURL=TransactionReceipt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionReceipt.js","sourceRoot":"","sources":["../../src/tempo/TransactionReceipt.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,qBAAqB,MAAM,+BAA+B,CAAA;AA4CtE,gCAAgC;AAChC,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,GAAG,qBAAqB,CAAC,WAAW;IACpC,MAAM,EAAE,OAAO;CACP,CAAA;AAEV,gCAAgC;AAChC,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,GAAG,qBAAqB,CAAC,SAAS;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AAI,EAAG,SAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI;KACvD,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { TransactionReceipt } from 'ox/tempo'
|
|
2
|
+
import { describe, expect, test } from 'vite-plus/test'
|
|
3
|
+
|
|
4
|
+
const rpc = {
|
|
5
|
+
blockHash:
|
|
6
|
+
'0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
|
|
7
|
+
blockNumber: '0x12f296f',
|
|
8
|
+
contractAddress: null,
|
|
9
|
+
cumulativeGasUsed: '0x82515',
|
|
10
|
+
effectiveGasPrice: '0x21c2f6c09',
|
|
11
|
+
feePayer: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
|
|
12
|
+
feeToken: '0x20c0000000000000000000000000000000000001',
|
|
13
|
+
from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
|
|
14
|
+
gasUsed: '0x2abba',
|
|
15
|
+
logs: [],
|
|
16
|
+
logsBloom: `0x${'00'.repeat(256)}`,
|
|
17
|
+
status: '0x1',
|
|
18
|
+
to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
|
|
19
|
+
transactionHash:
|
|
20
|
+
'0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
|
|
21
|
+
transactionIndex: '0x2',
|
|
22
|
+
type: '0x76',
|
|
23
|
+
} as const satisfies TransactionReceipt.Rpc
|
|
24
|
+
|
|
25
|
+
describe('fromRpc', () => {
|
|
26
|
+
test('default', () => {
|
|
27
|
+
const receipt = TransactionReceipt.fromRpc(rpc)
|
|
28
|
+
expect(receipt).toMatchInlineSnapshot(`
|
|
29
|
+
{
|
|
30
|
+
"blobGasPrice": undefined,
|
|
31
|
+
"blobGasUsed": undefined,
|
|
32
|
+
"blockHash": "0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b",
|
|
33
|
+
"blockNumber": 19868015n,
|
|
34
|
+
"contractAddress": null,
|
|
35
|
+
"cumulativeGasUsed": 533781n,
|
|
36
|
+
"effectiveGasPrice": 9062804489n,
|
|
37
|
+
"feePayer": "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
|
|
38
|
+
"feeToken": "0x20c0000000000000000000000000000000000001",
|
|
39
|
+
"from": "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
|
|
40
|
+
"gasUsed": 175034n,
|
|
41
|
+
"logs": [],
|
|
42
|
+
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
|
43
|
+
"status": "success",
|
|
44
|
+
"to": "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
|
|
45
|
+
"transactionHash": "0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0",
|
|
46
|
+
"transactionIndex": 2,
|
|
47
|
+
"type": "tempo",
|
|
48
|
+
}
|
|
49
|
+
`)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
test('behavior: non-tempo type passes through the generic mapping', () => {
|
|
53
|
+
const receipt = TransactionReceipt.fromRpc({ ...rpc, type: '0x2' })
|
|
54
|
+
expect(receipt.type).toBe('eip1559')
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
test('behavior: null', () => {
|
|
58
|
+
expect(TransactionReceipt.fromRpc(null)).toBeNull()
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
describe('toRpc', () => {
|
|
63
|
+
test('default', () => {
|
|
64
|
+
const receipt = TransactionReceipt.fromRpc(rpc)
|
|
65
|
+
const encoded = TransactionReceipt.toRpc(receipt)
|
|
66
|
+
expect(encoded.type).toBe('0x76')
|
|
67
|
+
expect(encoded.feePayer).toBe(rpc.feePayer)
|
|
68
|
+
expect(encoded.feeToken).toBe(rpc.feeToken)
|
|
69
|
+
expect(TransactionReceipt.fromRpc(encoded)).toEqual(receipt)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
test('behavior: non-tempo type passes through the generic mapping', () => {
|
|
73
|
+
const receipt = TransactionReceipt.fromRpc({ ...rpc, type: '0x2' })
|
|
74
|
+
expect(TransactionReceipt.toRpc(receipt).type).toBe('0x2')
|
|
75
|
+
})
|
|
76
|
+
})
|
|
@@ -13,7 +13,7 @@ import * as ox_TransactionReceipt from '../core/TransactionReceipt.js'
|
|
|
13
13
|
*/
|
|
14
14
|
export type TransactionReceipt<
|
|
15
15
|
status = ox_TransactionReceipt.Status,
|
|
16
|
-
type =
|
|
16
|
+
type = Type,
|
|
17
17
|
bigintType = bigint,
|
|
18
18
|
numberType = number,
|
|
19
19
|
> = Compute<
|
|
@@ -32,7 +32,7 @@ export type TransactionReceipt<
|
|
|
32
32
|
|
|
33
33
|
export type Rpc = TransactionReceipt<
|
|
34
34
|
ox_TransactionReceipt.RpcStatus,
|
|
35
|
-
|
|
35
|
+
RpcType,
|
|
36
36
|
Hex.Hex,
|
|
37
37
|
Hex.Hex
|
|
38
38
|
>
|
|
@@ -118,9 +118,14 @@ export const toRpcType = {
|
|
|
118
118
|
export function fromRpc<const receipt extends Rpc | null>(
|
|
119
119
|
receipt: receipt | Rpc | null,
|
|
120
120
|
): receipt extends Rpc ? TransactionReceipt : null {
|
|
121
|
-
|
|
121
|
+
const decoded = ox_TransactionReceipt.fromRpc(
|
|
122
122
|
receipt as ox_TransactionReceipt.Rpc,
|
|
123
|
-
)
|
|
123
|
+
)
|
|
124
|
+
if (!decoded) return null as never
|
|
125
|
+
return {
|
|
126
|
+
...decoded,
|
|
127
|
+
type: (fromRpcType as any)[receipt!.type] ?? receipt!.type,
|
|
128
|
+
} as never
|
|
124
129
|
}
|
|
125
130
|
|
|
126
131
|
export declare namespace fromRpc {
|
|
@@ -192,6 +197,7 @@ export function toRpc(receipt: toRpc.Input): Rpc {
|
|
|
192
197
|
...rpc,
|
|
193
198
|
feePayer: receipt.feePayer,
|
|
194
199
|
feeToken: receipt.feeToken,
|
|
200
|
+
type: (toRpcType as any)[receipt.type] ?? receipt.type,
|
|
195
201
|
}
|
|
196
202
|
}
|
|
197
203
|
|
|
@@ -199,7 +205,7 @@ export declare namespace toRpc {
|
|
|
199
205
|
/** Numberish input accepted by {@link ox#TransactionReceipt.(toRpc:function)}. */
|
|
200
206
|
export type Input = TransactionReceipt<
|
|
201
207
|
ox_TransactionReceipt.Status,
|
|
202
|
-
|
|
208
|
+
Type,
|
|
203
209
|
Hex.Hex | bigint | number,
|
|
204
210
|
Hex.Hex | number
|
|
205
211
|
>
|
package/src/tempo/e2e.test.ts
CHANGED
|
@@ -158,7 +158,7 @@ test('behavior: default (secp256k1)', async () => {
|
|
|
158
158
|
"contractAddress": null,
|
|
159
159
|
"status": "success",
|
|
160
160
|
"to": "0x0000000000000000000000000000000000000000",
|
|
161
|
-
"type": "
|
|
161
|
+
"type": "tempo",
|
|
162
162
|
}
|
|
163
163
|
`)
|
|
164
164
|
})
|
|
@@ -365,7 +365,7 @@ test('behavior: default (p256)', async () => {
|
|
|
365
365
|
"contractAddress": null,
|
|
366
366
|
"status": "success",
|
|
367
367
|
"to": "0x0000000000000000000000000000000000000000",
|
|
368
|
-
"type": "
|
|
368
|
+
"type": "tempo",
|
|
369
369
|
}
|
|
370
370
|
`)
|
|
371
371
|
})
|
|
@@ -504,7 +504,7 @@ test('behavior: default (p256 - webcrypto)', async () => {
|
|
|
504
504
|
"contractAddress": null,
|
|
505
505
|
"status": "success",
|
|
506
506
|
"to": "0x0000000000000000000000000000000000000000",
|
|
507
|
-
"type": "
|
|
507
|
+
"type": "tempo",
|
|
508
508
|
}
|
|
509
509
|
`)
|
|
510
510
|
})
|
|
@@ -650,7 +650,7 @@ test('behavior: default (webauthn)', async () => {
|
|
|
650
650
|
"contractAddress": null,
|
|
651
651
|
"status": "success",
|
|
652
652
|
"to": "0x0000000000000000000000000000000000000000",
|
|
653
|
-
"type": "
|
|
653
|
+
"type": "tempo",
|
|
654
654
|
}
|
|
655
655
|
`)
|
|
656
656
|
})
|
|
@@ -759,7 +759,7 @@ test('behavior: feePayerSignature (user → feePayer)', async () => {
|
|
|
759
759
|
"contractAddress": null,
|
|
760
760
|
"status": "success",
|
|
761
761
|
"to": "0x0000000000000000000000000000000000000000",
|
|
762
|
-
"type": "
|
|
762
|
+
"type": "tempo",
|
|
763
763
|
}
|
|
764
764
|
`)
|
|
765
765
|
}
|
|
@@ -1029,7 +1029,7 @@ describe('behavior: keyAuthorization', () => {
|
|
|
1029
1029
|
"contractAddress": null,
|
|
1030
1030
|
"status": "success",
|
|
1031
1031
|
"to": "0x0000000000000000000000000000000000000000",
|
|
1032
|
-
"type": "
|
|
1032
|
+
"type": "tempo",
|
|
1033
1033
|
}
|
|
1034
1034
|
`)
|
|
1035
1035
|
|
|
@@ -1243,7 +1243,7 @@ describe('behavior: keyAuthorization', () => {
|
|
|
1243
1243
|
"contractAddress": null,
|
|
1244
1244
|
"status": "success",
|
|
1245
1245
|
"to": "0x0000000000000000000000000000000000000000",
|
|
1246
|
-
"type": "
|
|
1246
|
+
"type": "tempo",
|
|
1247
1247
|
}
|
|
1248
1248
|
`)
|
|
1249
1249
|
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
export const version = '1.0.0-beta.
|
|
2
|
+
export const version = '1.0.0-beta.21'
|