tempo.ts 0.10.4 → 0.11.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 +36 -0
- package/README.md +0 -41
- package/dist/viem/Account.d.ts +8 -3
- package/dist/viem/Account.d.ts.map +1 -1
- package/dist/viem/Account.js +9 -2
- package/dist/viem/Account.js.map +1 -1
- package/dist/viem/Actions/amm.d.ts +1 -1
- package/dist/viem/Actions/amm.d.ts.map +1 -1
- package/dist/viem/Actions/amm.js +1 -2
- package/dist/viem/Actions/amm.js.map +1 -1
- package/dist/viem/Actions/dex.d.ts +0 -35
- package/dist/viem/Actions/dex.d.ts.map +1 -1
- package/dist/viem/Actions/dex.js +0 -43
- package/dist/viem/Actions/dex.js.map +1 -1
- package/dist/viem/Actions/fee.d.ts +1 -1
- package/dist/viem/Actions/fee.d.ts.map +1 -1
- package/dist/viem/Actions/fee.js +1 -1
- package/dist/viem/Actions/fee.js.map +1 -1
- package/dist/viem/Actions/nonce.d.ts.map +1 -1
- package/dist/viem/Actions/nonce.js +6 -4
- package/dist/viem/Actions/nonce.js.map +1 -1
- package/dist/viem/Actions/token.d.ts +1 -2
- package/dist/viem/Actions/token.d.ts.map +1 -1
- package/dist/viem/Actions/token.js +1 -2
- package/dist/viem/Actions/token.js.map +1 -1
- package/dist/viem/Chain.d.ts +35 -35
- package/dist/viem/Chain.d.ts.map +1 -1
- package/dist/viem/Chain.js +2 -0
- package/dist/viem/Chain.js.map +1 -1
- package/dist/viem/Formatters.d.ts.map +1 -1
- package/dist/viem/Formatters.js +5 -3
- package/dist/viem/Formatters.js.map +1 -1
- package/dist/viem/Transaction.d.ts +8 -5
- package/dist/viem/Transaction.d.ts.map +1 -1
- package/dist/viem/Transaction.js +13 -3
- package/dist/viem/Transaction.js.map +1 -1
- package/dist/viem/internal/types.d.ts +1 -1
- package/dist/viem/internal/types.d.ts.map +1 -1
- package/dist/wagmi/Actions/dex.d.ts +1 -45
- package/dist/wagmi/Actions/dex.d.ts.map +1 -1
- package/dist/wagmi/Actions/dex.js +0 -55
- package/dist/wagmi/Actions/dex.js.map +1 -1
- package/dist/wagmi/Connector.d.ts +1 -1
- package/dist/wagmi/Connector.d.ts.map +1 -1
- package/dist/wagmi/Connector.js +1 -2
- package/dist/wagmi/Connector.js.map +1 -1
- package/dist/wagmi/Hooks/dex.d.ts +3 -46
- package/dist/wagmi/Hooks/dex.d.ts.map +1 -1
- package/dist/wagmi/Hooks/dex.js +2 -54
- package/dist/wagmi/Hooks/dex.js.map +1 -1
- package/dist/wagmi/index.d.ts +1 -1
- package/dist/wagmi/index.d.ts.map +1 -1
- package/dist/wagmi/index.js +1 -1
- package/dist/wagmi/index.js.map +1 -1
- package/package.json +5 -23
- package/src/viem/Account.test.ts +1 -1
- package/src/viem/Account.ts +11 -2
- package/src/viem/Actions/account.ts +1 -1
- package/src/viem/Actions/amm.ts +1 -2
- package/src/viem/Actions/dex.test.ts +1 -195
- package/src/viem/Actions/dex.ts +0 -53
- package/src/viem/Actions/fee.test.ts +2 -2
- package/src/viem/Actions/fee.ts +1 -1
- package/src/viem/Actions/nonce.test.ts +27 -14
- package/src/viem/Actions/nonce.ts +6 -4
- package/src/viem/Actions/token.test.ts +18 -52
- package/src/viem/Actions/token.ts +1 -2
- package/src/viem/Chain.ts +4 -2
- package/src/viem/Decorator.ts +0 -30
- package/src/viem/Formatters.ts +9 -3
- package/src/viem/Transaction.ts +23 -7
- package/src/viem/e2e.test.ts +19 -0
- package/src/viem/index.ts +12 -1
- package/src/viem/internal/types.ts +1 -1
- package/src/wagmi/Actions/dex.test.ts +0 -26
- package/src/wagmi/Actions/dex.ts +1 -111
- package/src/wagmi/Actions/nonce.test.ts +8 -4
- package/src/wagmi/Actions/token.test.ts +2 -2
- package/src/wagmi/Connector.ts +1 -2
- package/src/wagmi/Hooks/dex.test.ts +0 -26
- package/src/wagmi/Hooks/dex.ts +1 -88
- package/src/wagmi/Hooks/nonce.test.ts +3 -3
- package/src/wagmi/index.ts +4 -1
- package/dist/chains.d.ts +0 -73
- package/dist/chains.d.ts.map +0 -1
- package/dist/chains.js +0 -51
- package/dist/chains.js.map +0 -1
- package/dist/ox/AuthorizationTempo.d.ts +0 -450
- package/dist/ox/AuthorizationTempo.d.ts.map +0 -1
- package/dist/ox/AuthorizationTempo.js +0 -433
- package/dist/ox/AuthorizationTempo.js.map +0 -1
- package/dist/ox/KeyAuthorization.d.ts +0 -356
- package/dist/ox/KeyAuthorization.d.ts.map +0 -1
- package/dist/ox/KeyAuthorization.js +0 -359
- package/dist/ox/KeyAuthorization.js.map +0 -1
- package/dist/ox/Order.d.ts +0 -92
- package/dist/ox/Order.d.ts.map +0 -1
- package/dist/ox/Order.js +0 -88
- package/dist/ox/Order.js.map +0 -1
- package/dist/ox/OrdersFilters.d.ts +0 -72
- package/dist/ox/OrdersFilters.d.ts.map +0 -1
- package/dist/ox/OrdersFilters.js +0 -100
- package/dist/ox/OrdersFilters.js.map +0 -1
- package/dist/ox/Pagination.d.ts +0 -128
- package/dist/ox/Pagination.d.ts.map +0 -1
- package/dist/ox/Pagination.js +0 -78
- package/dist/ox/Pagination.js.map +0 -1
- package/dist/ox/PoolId.d.ts +0 -18
- package/dist/ox/PoolId.d.ts.map +0 -1
- package/dist/ox/PoolId.js +0 -13
- package/dist/ox/PoolId.js.map +0 -1
- package/dist/ox/RpcSchema.d.ts +0 -32
- package/dist/ox/RpcSchema.d.ts.map +0 -1
- package/dist/ox/RpcSchema.js +0 -2
- package/dist/ox/RpcSchema.js.map +0 -1
- package/dist/ox/SignatureEnvelope.d.ts +0 -260
- package/dist/ox/SignatureEnvelope.d.ts.map +0 -1
- package/dist/ox/SignatureEnvelope.js +0 -477
- package/dist/ox/SignatureEnvelope.js.map +0 -1
- package/dist/ox/Tick.d.ts +0 -115
- package/dist/ox/Tick.d.ts.map +0 -1
- package/dist/ox/Tick.js +0 -127
- package/dist/ox/Tick.js.map +0 -1
- package/dist/ox/TokenId.d.ts +0 -25
- package/dist/ox/TokenId.d.ts.map +0 -1
- package/dist/ox/TokenId.js +0 -41
- package/dist/ox/TokenId.js.map +0 -1
- package/dist/ox/TokenRole.d.ts +0 -11
- package/dist/ox/TokenRole.d.ts.map +0 -1
- package/dist/ox/TokenRole.js +0 -22
- package/dist/ox/TokenRole.js.map +0 -1
- package/dist/ox/Transaction.d.ts +0 -201
- package/dist/ox/Transaction.d.ts.map +0 -1
- package/dist/ox/Transaction.js +0 -167
- package/dist/ox/Transaction.js.map +0 -1
- package/dist/ox/TransactionEnvelopeTempo.d.ts +0 -470
- package/dist/ox/TransactionEnvelopeTempo.d.ts.map +0 -1
- package/dist/ox/TransactionEnvelopeTempo.js +0 -547
- package/dist/ox/TransactionEnvelopeTempo.js.map +0 -1
- package/dist/ox/TransactionReceipt.d.ts +0 -155
- package/dist/ox/TransactionReceipt.d.ts.map +0 -1
- package/dist/ox/TransactionReceipt.js +0 -136
- package/dist/ox/TransactionReceipt.js.map +0 -1
- package/dist/ox/TransactionRequest.d.ts +0 -76
- package/dist/ox/TransactionRequest.d.ts.map +0 -1
- package/dist/ox/TransactionRequest.js +0 -93
- package/dist/ox/TransactionRequest.js.map +0 -1
- package/dist/ox/index.d.ts +0 -14
- package/dist/ox/index.d.ts.map +0 -1
- package/dist/ox/index.js +0 -14
- package/dist/ox/index.js.map +0 -1
- package/dist/prool/Instance.d.ts +0 -101
- package/dist/prool/Instance.d.ts.map +0 -1
- package/dist/prool/Instance.js +0 -136
- package/dist/prool/Instance.js.map +0 -1
- package/dist/prool/chain.json +0 -238
- package/dist/prool/index.d.ts +0 -2
- package/dist/prool/index.d.ts.map +0 -1
- package/dist/prool/index.js +0 -2
- package/dist/prool/index.js.map +0 -1
- package/dist/viem/Actions/account.d.ts +0 -40
- package/dist/viem/Actions/account.d.ts.map +0 -1
- package/dist/viem/Actions/account.js +0 -86
- package/dist/viem/Actions/account.js.map +0 -1
- package/dist/viem/Actions/index.d.ts +0 -10
- package/dist/viem/Actions/index.d.ts.map +0 -1
- package/dist/viem/Actions/index.js +0 -10
- package/dist/viem/Actions/index.js.map +0 -1
- package/dist/viem/Decorator.d.ts +0 -2810
- package/dist/viem/Decorator.d.ts.map +0 -1
- package/dist/viem/Decorator.js +0 -138
- package/dist/viem/Decorator.js.map +0 -1
- package/dist/viem/P256.d.ts +0 -2
- package/dist/viem/P256.d.ts.map +0 -1
- package/dist/viem/P256.js +0 -2
- package/dist/viem/P256.js.map +0 -1
- package/dist/viem/Secp256k1.d.ts +0 -2
- package/dist/viem/Secp256k1.d.ts.map +0 -1
- package/dist/viem/Secp256k1.js +0 -2
- package/dist/viem/Secp256k1.js.map +0 -1
- package/dist/viem/TokenIds.d.ts +0 -2
- package/dist/viem/TokenIds.d.ts.map +0 -1
- package/dist/viem/TokenIds.js +0 -2
- package/dist/viem/TokenIds.js.map +0 -1
- package/dist/viem/index.d.ts +0 -17
- package/dist/viem/index.d.ts.map +0 -1
- package/dist/viem/index.js +0 -17
- package/dist/viem/index.js.map +0 -1
- package/src/ox/AuthorizationTempo.test.ts +0 -1256
- package/src/ox/AuthorizationTempo.ts +0 -648
- package/src/ox/KeyAuthorization.test.ts +0 -1332
- package/src/ox/KeyAuthorization.ts +0 -540
- package/src/ox/Order.test.ts +0 -78
- package/src/ox/Order.ts +0 -125
- package/src/ox/OrdersFilters.test.ts +0 -182
- package/src/ox/OrdersFilters.ts +0 -125
- package/src/ox/Pagination.test.ts +0 -162
- package/src/ox/Pagination.ts +0 -164
- package/src/ox/PoolId.test.ts +0 -33
- package/src/ox/PoolId.ts +0 -27
- package/src/ox/RpcSchema.ts +0 -35
- package/src/ox/SignatureEnvelope.test.ts +0 -1876
- package/src/ox/SignatureEnvelope.ts +0 -791
- package/src/ox/Tick.test.ts +0 -281
- package/src/ox/Tick.ts +0 -181
- package/src/ox/TokenId.test.ts +0 -40
- package/src/ox/TokenId.ts +0 -50
- package/src/ox/TokenRole.test.ts +0 -16
- package/src/ox/TokenRole.ts +0 -27
- package/src/ox/Transaction.test.ts +0 -523
- package/src/ox/Transaction.ts +0 -332
- package/src/ox/TransactionEnvelopeTempo.test.ts +0 -1352
- package/src/ox/TransactionEnvelopeTempo.ts +0 -905
- package/src/ox/TransactionReceipt.ts +0 -190
- package/src/ox/TransactionRequest.ts +0 -147
- package/src/ox/e2e.test.ts +0 -1393
- package/src/ox/index.ts +0 -13
- package/src/prool/Instance.test.ts +0 -43
- package/src/prool/Instance.ts +0 -247
- package/src/prool/chain.json +0 -238
- package/src/prool/index.ts +0 -1
- package/src/viem/Actions/__snapshots__/dex.test.ts.snap +0 -850
- package/src/wagmi/Actions/__snapshots__/dex.test.ts.snap +0 -310
- package/src/wagmi/Hooks/__snapshots__/dex.test.ts.snap +0 -457
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
import * as Hash from 'ox/Hash';
|
|
2
|
-
import * as Hex from 'ox/Hex';
|
|
3
|
-
import * as Rlp from 'ox/Rlp';
|
|
4
|
-
import * as SignatureEnvelope from './SignatureEnvelope.js';
|
|
5
|
-
/**
|
|
6
|
-
* Converts a Key Authorization object into a typed {@link ox#KeyAuthorization.KeyAuthorization}.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* A Key Authorization can be instantiated from a Key Authorization tuple in object format.
|
|
10
|
-
*
|
|
11
|
-
* ```ts twoslash
|
|
12
|
-
* import { KeyAuthorization } from 'tempo.ts/ox'
|
|
13
|
-
* import { Value } from 'ox'
|
|
14
|
-
*
|
|
15
|
-
* const authorization = KeyAuthorization.from({
|
|
16
|
-
* expiry: 1234567890,
|
|
17
|
-
* keyId: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
|
|
18
|
-
* keyType: 'secp256k1',
|
|
19
|
-
* limits: [{
|
|
20
|
-
* token: '0x20c0000000000000000000000000000000000001',
|
|
21
|
-
* limit: Value.from('10', 6)
|
|
22
|
-
* }],
|
|
23
|
-
* })
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ### Attaching Signatures
|
|
28
|
-
*
|
|
29
|
-
* A {@link ox#SignatureEnvelope.SignatureEnvelope} can be attached with the `signature` option. The example below demonstrates signing
|
|
30
|
-
* a Key Authorization with {@link ox#Secp256k1.(sign:function)}.
|
|
31
|
-
*
|
|
32
|
-
* ```ts twoslash
|
|
33
|
-
* import { KeyAuthorization } from 'tempo.ts/ox'
|
|
34
|
-
* import { Secp256k1 } from 'ox'
|
|
35
|
-
*
|
|
36
|
-
* const authorization = KeyAuthorization.from({
|
|
37
|
-
* expiry: 1234567890,
|
|
38
|
-
* keyId: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
|
|
39
|
-
* keyType: 'secp256k1',
|
|
40
|
-
* limits: [{
|
|
41
|
-
* token: '0x20c0000000000000000000000000000000000001',
|
|
42
|
-
* limit: Value.from('10', 6)
|
|
43
|
-
* }],
|
|
44
|
-
* })
|
|
45
|
-
*
|
|
46
|
-
* const signature = Secp256k1.sign({
|
|
47
|
-
* payload: KeyAuthorization.getSignPayload(authorization),
|
|
48
|
-
* privateKey: '0x...',
|
|
49
|
-
* })
|
|
50
|
-
*
|
|
51
|
-
* const authorization_signed = KeyAuthorization.from(authorization, { signature }) // [!code focus]
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
* @param authorization - A Key Authorization tuple in object format.
|
|
55
|
-
* @param options - Key Authorization options.
|
|
56
|
-
* @returns The {@link ox#KeyAuthorization.KeyAuthorization}.
|
|
57
|
-
*/
|
|
58
|
-
export function from(authorization, options = {}) {
|
|
59
|
-
if (typeof authorization.expiry === 'string')
|
|
60
|
-
return fromRpc(authorization);
|
|
61
|
-
if (options.signature)
|
|
62
|
-
return { ...authorization, signature: options.signature };
|
|
63
|
-
return authorization;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Converts an {@link ox#AuthorizationAA.Rpc} to an {@link ox#AuthorizationAA.AuthorizationAA}.
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* ```ts twoslash
|
|
70
|
-
* import { KeyAuthorization } from 'tempo.ts/ox'
|
|
71
|
-
*
|
|
72
|
-
* const keyAuthorization = KeyAuthorization.fromRpc({
|
|
73
|
-
* expiry: '0x174876e800',
|
|
74
|
-
* keyId: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
|
|
75
|
-
* keyType: 'secp256k1',
|
|
76
|
-
* limits: [{ token: '0x20c0000000000000000000000000000000000001', limit: '0xf4240' }],
|
|
77
|
-
* signature: {
|
|
78
|
-
* type: 'secp256k1',
|
|
79
|
-
* r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',
|
|
80
|
-
* s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',
|
|
81
|
-
* yParity: '0x0'
|
|
82
|
-
* },
|
|
83
|
-
* })
|
|
84
|
-
* ```
|
|
85
|
-
*
|
|
86
|
-
* @param authorization - The RPC-formatted Key Authorization.
|
|
87
|
-
* @returns A signed {@link ox#AuthorizationAA.AuthorizationAA}.
|
|
88
|
-
*/
|
|
89
|
-
export function fromRpc(authorization) {
|
|
90
|
-
const { chainId = '0x0', keyId, expiry = 0, limits, keyType } = authorization;
|
|
91
|
-
const signature = SignatureEnvelope.fromRpc(authorization.signature);
|
|
92
|
-
return {
|
|
93
|
-
address: keyId,
|
|
94
|
-
chainId: chainId === '0x' ? 0n : Hex.toBigInt(chainId),
|
|
95
|
-
expiry: Number(expiry),
|
|
96
|
-
limits: limits?.map((limit) => ({
|
|
97
|
-
token: limit.token,
|
|
98
|
-
limit: BigInt(limit.limit),
|
|
99
|
-
})),
|
|
100
|
-
signature,
|
|
101
|
-
type: keyType,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Converts an {@link ox#KeyAuthorization.Tuple} to an {@link ox#KeyAuthorization.KeyAuthorization}.
|
|
106
|
-
*
|
|
107
|
-
* @example
|
|
108
|
-
* ```ts twoslash
|
|
109
|
-
* import { KeyAuthorization } from 'tempo.ts/ox'
|
|
110
|
-
*
|
|
111
|
-
* const authorization = KeyAuthorization.fromTuple([
|
|
112
|
-
* '0x174876e800',
|
|
113
|
-
* [['0x20c0000000000000000000000000000000000001', '0xf4240']],
|
|
114
|
-
* 'secp256k1',
|
|
115
|
-
* '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
|
|
116
|
-
* '0x01a068a020a209d3d56c46f38cc50a33f704f4a9a10a59377f8dd762ac66910e9b907e865ad05c4035ab5792787d4a0297a43617ae897930a6fe4d822b8faea52064'
|
|
117
|
-
* ])
|
|
118
|
-
* // @log: {
|
|
119
|
-
* // @log: expiry: 1234567890,
|
|
120
|
-
* // @log: keyId: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
|
|
121
|
-
* // @log: keyType: 'secp256k1',
|
|
122
|
-
* // @log: limits: [{ token: '0x20c0000000000000000000000000000000000001', limit: '0xf4240' }],
|
|
123
|
-
* // @log: signature: {
|
|
124
|
-
* // @log: type: 'secp256k1',
|
|
125
|
-
* // @log: r: '0x68a020a209d3d56c46f38cc50a33f704f4a9a10a59377f8dd762ac66910e9b90',
|
|
126
|
-
* // @log: s: '0x7e865ad05c4035ab5792787d4a0297a43617ae897930a6fe4d822b8faea52064',
|
|
127
|
-
* // @log: yParity: 0,
|
|
128
|
-
* // @log: },
|
|
129
|
-
* // @log: }
|
|
130
|
-
* ```
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* It is also possible to append a serialized SignatureEnvelope to the end of a Key Authorization tuple.
|
|
134
|
-
*
|
|
135
|
-
* ```ts twoslash
|
|
136
|
-
* import { KeyAuthorization } from 'tempo.ts/ox'
|
|
137
|
-
*
|
|
138
|
-
* const authorization = KeyAuthorization.fromTuple([
|
|
139
|
-
* '0x174876e800',
|
|
140
|
-
* [['0x20c0000000000000000000000000000000000001', '0xf4240']],
|
|
141
|
-
* 'secp256k1',
|
|
142
|
-
* '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
|
|
143
|
-
* '0x01a068a020a209d3d56c46f38cc50a33f704f4a9a10a59377f8dd762ac66910e9b907e865ad05c4035ab5792787d4a0297a43617ae897930a6fe4d822b8faea52064',
|
|
144
|
-
* ])
|
|
145
|
-
* // @log: {
|
|
146
|
-
* // @log: expiry: 1234567890,
|
|
147
|
-
* // @log: keyId: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
|
|
148
|
-
* // @log: keyType: 'secp256k1',
|
|
149
|
-
* // @log: limits: [{ token: '0x20c0000000000000000000000000000000000001', limit: '0xf4240' }],
|
|
150
|
-
* // @log: signature: {
|
|
151
|
-
* // @log: type: 'secp256k1',
|
|
152
|
-
* // @log: r: '0x68a020a209d3d56c46f38cc50a33f704f4a9a10a59377f8dd762ac66910e9b90',
|
|
153
|
-
* // @log: s: '0x7e865ad05c4035ab5792787d4a0297a43617ae897930a6fe4d822b8faea52064',
|
|
154
|
-
* // @log: yParity: 0,
|
|
155
|
-
* // @log: },
|
|
156
|
-
* // @log: }
|
|
157
|
-
* ```
|
|
158
|
-
*
|
|
159
|
-
* @param tuple - The Key Authorization tuple.
|
|
160
|
-
* @returns The {@link ox#KeyAuthorization.KeyAuthorization}.
|
|
161
|
-
*/
|
|
162
|
-
export function fromTuple(tuple) {
|
|
163
|
-
const [authorization, signatureSerialized] = tuple;
|
|
164
|
-
const [chainId, keyType_hex, keyId, expiry, limits] = authorization;
|
|
165
|
-
const keyType = (() => {
|
|
166
|
-
switch (keyType_hex) {
|
|
167
|
-
case '0x':
|
|
168
|
-
case '0x00':
|
|
169
|
-
return 'secp256k1';
|
|
170
|
-
case '0x01':
|
|
171
|
-
return 'p256';
|
|
172
|
-
case '0x02':
|
|
173
|
-
return 'webAuthn';
|
|
174
|
-
default:
|
|
175
|
-
throw new Error(`Invalid key type: ${keyType_hex}`);
|
|
176
|
-
}
|
|
177
|
-
})();
|
|
178
|
-
const args = {
|
|
179
|
-
address: keyId,
|
|
180
|
-
expiry: typeof expiry !== 'undefined' ? Hex.toNumber(expiry) : undefined,
|
|
181
|
-
type: keyType,
|
|
182
|
-
...(chainId !== '0x' ? { chainId: Hex.toBigInt(chainId) } : {}),
|
|
183
|
-
...(typeof expiry !== 'undefined' ? { expiry: Hex.toNumber(expiry) } : {}),
|
|
184
|
-
...(typeof limits !== 'undefined'
|
|
185
|
-
? {
|
|
186
|
-
limits: limits.map(([token, limit]) => ({
|
|
187
|
-
token,
|
|
188
|
-
limit: BigInt(limit),
|
|
189
|
-
})),
|
|
190
|
-
}
|
|
191
|
-
: {}),
|
|
192
|
-
};
|
|
193
|
-
if (signatureSerialized)
|
|
194
|
-
args.signature = SignatureEnvelope.deserialize(signatureSerialized);
|
|
195
|
-
return from(args);
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Computes the sign payload for an {@link ox#KeyAuthorization.KeyAuthorization}.
|
|
199
|
-
*
|
|
200
|
-
* @example
|
|
201
|
-
* The example below demonstrates computing the sign payload for an {@link ox#KeyAuthorization.KeyAuthorization}. This payload
|
|
202
|
-
* can then be passed to signing functions like {@link ox#Secp256k1.(sign:function)}.
|
|
203
|
-
*
|
|
204
|
-
* ```ts twoslash
|
|
205
|
-
* import { KeyAuthorization } from 'tempo.ts/ox'
|
|
206
|
-
* import { Secp256k1 } from 'ox'
|
|
207
|
-
*
|
|
208
|
-
* const authorization = KeyAuthorization.from({
|
|
209
|
-
* expiry: 1234567890,
|
|
210
|
-
* keyId: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
|
|
211
|
-
* keyType: 'secp256k1',
|
|
212
|
-
* limits: [{
|
|
213
|
-
* token: '0x20c0000000000000000000000000000000000001',
|
|
214
|
-
* limit: Value.from('10', 6)
|
|
215
|
-
* }],
|
|
216
|
-
* })
|
|
217
|
-
*
|
|
218
|
-
* const payload = KeyAuthorization.getSignPayload(authorization) // [!code focus]
|
|
219
|
-
*
|
|
220
|
-
* const signature = Secp256k1.sign({
|
|
221
|
-
* payload,
|
|
222
|
-
* privateKey: '0x...',
|
|
223
|
-
* })
|
|
224
|
-
* ```
|
|
225
|
-
*
|
|
226
|
-
* @param authorization - The {@link ox#KeyAuthorization.KeyAuthorization}.
|
|
227
|
-
* @returns The sign payload.
|
|
228
|
-
*/
|
|
229
|
-
export function getSignPayload(authorization) {
|
|
230
|
-
return hash(authorization);
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Computes the hash for an {@link ox#KeyAuthorization.KeyAuthorization}.
|
|
234
|
-
*
|
|
235
|
-
* @example
|
|
236
|
-
* ```ts twoslash
|
|
237
|
-
* import { KeyAuthorization } from 'tempo.ts/ox'
|
|
238
|
-
* import { Value } from 'ox'
|
|
239
|
-
*
|
|
240
|
-
* const authorization = KeyAuthorization.from({
|
|
241
|
-
* expiry: 1234567890,
|
|
242
|
-
* keyId: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
|
|
243
|
-
* keyType: 'secp256k1',
|
|
244
|
-
* limits: [{
|
|
245
|
-
* token: '0x20c0000000000000000000000000000000000001',
|
|
246
|
-
* limit: Value.from('10', 6)
|
|
247
|
-
* }],
|
|
248
|
-
* })
|
|
249
|
-
*
|
|
250
|
-
* const hash = KeyAuthorization.hash(authorization) // [!code focus]
|
|
251
|
-
* ```
|
|
252
|
-
*
|
|
253
|
-
* @param authorization - The {@link ox#KeyAuthorization.KeyAuthorization}.
|
|
254
|
-
* @returns The hash.
|
|
255
|
-
*/
|
|
256
|
-
export function hash(authorization) {
|
|
257
|
-
const [authorizationTuple] = toTuple(authorization);
|
|
258
|
-
const serialized = Rlp.fromHex(authorizationTuple);
|
|
259
|
-
return Hash.keccak256(serialized);
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Converts an {@link ox#KeyAuthorization.KeyAuthorization} to an {@link ox#KeyAuthorization.Rpc}.
|
|
263
|
-
*
|
|
264
|
-
* @example
|
|
265
|
-
* ```ts twoslash
|
|
266
|
-
* import { KeyAuthorization } from 'tempo.ts/ox'
|
|
267
|
-
*
|
|
268
|
-
* const authorization = KeyAuthorization.toRpc({
|
|
269
|
-
* expiry: 1234567890,
|
|
270
|
-
* keyId: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
|
|
271
|
-
* keyType: 'secp256k1',
|
|
272
|
-
* limits: [{
|
|
273
|
-
* token: '0x20c0000000000000000000000000000000000001',
|
|
274
|
-
* limit: Value.from('10', 6)
|
|
275
|
-
* }],
|
|
276
|
-
* signature: {
|
|
277
|
-
* type: 'secp256k1',
|
|
278
|
-
* r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
|
|
279
|
-
* s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
|
|
280
|
-
* yParity: 0,
|
|
281
|
-
* },
|
|
282
|
-
* })
|
|
283
|
-
* ```
|
|
284
|
-
*
|
|
285
|
-
* @param authorization - A Key Authorization.
|
|
286
|
-
* @returns An RPC-formatted Key Authorization.
|
|
287
|
-
*/
|
|
288
|
-
export function toRpc(authorization) {
|
|
289
|
-
const { address, chainId = 0n, expiry, limits, type, signature, } = authorization;
|
|
290
|
-
return {
|
|
291
|
-
chainId: chainId === 0n ? '0x' : Hex.fromNumber(chainId),
|
|
292
|
-
expiry: typeof expiry === 'number' ? Hex.fromNumber(expiry) : undefined,
|
|
293
|
-
limits: limits?.map(({ token, limit }) => ({
|
|
294
|
-
token,
|
|
295
|
-
limit: Hex.fromNumber(limit),
|
|
296
|
-
})),
|
|
297
|
-
keyId: address,
|
|
298
|
-
signature: SignatureEnvelope.toRpc(signature),
|
|
299
|
-
keyType: type,
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Converts an {@link ox#KeyAuthorization.KeyAuthorization} to an {@link ox#KeyAuthorization.Tuple}.
|
|
304
|
-
*
|
|
305
|
-
* @example
|
|
306
|
-
* ```ts twoslash
|
|
307
|
-
* import { KeyAuthorization } from 'tempo.ts/ox'
|
|
308
|
-
* import { Value } from 'ox'
|
|
309
|
-
*
|
|
310
|
-
* const authorization = KeyAuthorization.from({
|
|
311
|
-
* expiry: 1234567890,
|
|
312
|
-
* keyId: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
|
|
313
|
-
* keyType: 'secp256k1',
|
|
314
|
-
* limits: [{
|
|
315
|
-
* token: '0x20c0000000000000000000000000000000000001',
|
|
316
|
-
* limit: Value.from('10', 6)
|
|
317
|
-
* }],
|
|
318
|
-
* })
|
|
319
|
-
*
|
|
320
|
-
* const tuple = KeyAuthorization.toTuple(authorization) // [!code focus]
|
|
321
|
-
* // @log: [
|
|
322
|
-
* // @log: '0x174876e800',
|
|
323
|
-
* // @log: [['0x20c0000000000000000000000000000000000001', '0xf4240']],
|
|
324
|
-
* // @log: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
|
|
325
|
-
* // @log: 'secp256k1',
|
|
326
|
-
* // @log: ]
|
|
327
|
-
* ```
|
|
328
|
-
*
|
|
329
|
-
* @param authorization - The {@link ox#KeyAuthorization.KeyAuthorization}.
|
|
330
|
-
* @returns A Tempo Key Authorization tuple.
|
|
331
|
-
*/
|
|
332
|
-
export function toTuple(authorization) {
|
|
333
|
-
const { address, chainId = 0n, expiry, limits } = authorization;
|
|
334
|
-
const signature = authorization.signature
|
|
335
|
-
? SignatureEnvelope.serialize(authorization.signature)
|
|
336
|
-
: undefined;
|
|
337
|
-
const type = (() => {
|
|
338
|
-
switch (authorization.type) {
|
|
339
|
-
case 'secp256k1':
|
|
340
|
-
return '0x';
|
|
341
|
-
case 'p256':
|
|
342
|
-
return '0x01';
|
|
343
|
-
case 'webAuthn':
|
|
344
|
-
return '0x02';
|
|
345
|
-
default:
|
|
346
|
-
throw new Error(`Invalid key type: ${authorization.type}`);
|
|
347
|
-
}
|
|
348
|
-
})();
|
|
349
|
-
const authorizationTuple = [
|
|
350
|
-
chainId === 0n ? '0x' : Hex.fromNumber(chainId),
|
|
351
|
-
type,
|
|
352
|
-
address,
|
|
353
|
-
typeof expiry === 'number' ? Hex.fromNumber(expiry) : undefined,
|
|
354
|
-
limits?.map((limit) => [limit.token, Hex.fromNumber(limit.limit)]) ??
|
|
355
|
-
undefined,
|
|
356
|
-
].filter(Boolean);
|
|
357
|
-
return [authorizationTuple, ...(signature ? [signature] : [])];
|
|
358
|
-
}
|
|
359
|
-
//# sourceMappingURL=KeyAuthorization.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"KeyAuthorization.js","sourceRoot":"","sources":["../../src/ox/KeyAuthorization.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,SAAS,CAAA;AAC/B,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAC7B,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAE7B,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA;AA2F3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,MAAM,UAAU,IAAI,CAMlB,aAA+C,EAC/C,UAAmC,EAAE;IAErC,IAAI,OAAO,aAAa,CAAC,MAAM,KAAK,QAAQ;QAC1C,OAAO,OAAO,CAAC,aAAoB,CAAU,CAAA;IAC/C,IAAI,OAAO,CAAC,SAAS;QACnB,OAAO,EAAE,GAAG,aAAa,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAW,CAAA;IACpE,OAAO,aAAsB,CAAA;AAC/B,CAAC;AA6BD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,OAAO,CAAC,aAAkB;IACxC,MAAM,EAAE,OAAO,GAAG,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,aAAa,CAAA;IAC7E,MAAM,SAAS,GAAG,iBAAiB,CAAC,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;IACpE,OAAO;QACL,OAAO,EAAE,KA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CAAC,IAAI,EAAE,CAAC,CAAA;QAC9D,CAAC;IACH,CAAC,CAAC,EAAE,CAAA;IACJ,MAAM,kBAAkB,GAAG;QACzB,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC;QAC/C,IAAI;QACJ,OAAO;QACP,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;QAC/D,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;YAChE,SAAS;KACZ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACjB,OAAO,CAAC,kBAAkB,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAU,CAAA;AACzE,CAAC"}
|
package/dist/ox/Order.d.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import type * as Address from 'ox/Address';
|
|
2
|
-
import * as Hex from 'ox/Hex';
|
|
3
|
-
/**
|
|
4
|
-
* Represents an order from the DEX orderbook.
|
|
5
|
-
*/
|
|
6
|
-
export type Order<bigintType = bigint> = {
|
|
7
|
-
/** Original order amount. */
|
|
8
|
-
amount: bigintType;
|
|
9
|
-
/** Address of the base token. */
|
|
10
|
-
baseToken: Address.Address;
|
|
11
|
-
/** Target tick to flip to when order is filled. */
|
|
12
|
-
flipTick: number;
|
|
13
|
-
/** Order side: true for buy (bid), false for sell (ask). */
|
|
14
|
-
isBid: boolean;
|
|
15
|
-
/** Whether this is a flip order that auto-flips when filled. */
|
|
16
|
-
isFlip: boolean;
|
|
17
|
-
/** Address of order maker. */
|
|
18
|
-
maker: Address.Address;
|
|
19
|
-
/** Next order ID in FIFO queue. */
|
|
20
|
-
next: bigintType;
|
|
21
|
-
/** Unique order ID. */
|
|
22
|
-
orderId: bigintType;
|
|
23
|
-
/** Address of the quote token. */
|
|
24
|
-
quoteToken: Address.Address;
|
|
25
|
-
/** Previous order ID in FIFO queue. */
|
|
26
|
-
prev: bigintType;
|
|
27
|
-
/** Remaining amount to fill. */
|
|
28
|
-
remaining: bigintType;
|
|
29
|
-
/** Price tick. */
|
|
30
|
-
tick: number;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* RPC-formatted order from the DEX orderbook.
|
|
34
|
-
*/
|
|
35
|
-
export type Rpc = Order<Hex.Hex>;
|
|
36
|
-
/**
|
|
37
|
-
* Converts an RPC-formatted order to an internal order representation.
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```ts twoslash
|
|
41
|
-
* import { Order } from 'tempo.ts/ox'
|
|
42
|
-
*
|
|
43
|
-
* const order = Order.fromRpc({
|
|
44
|
-
* amount: '0x64',
|
|
45
|
-
* baseToken: '0x20c0000000000000000000000000000000000001',
|
|
46
|
-
* flipTick: 0,
|
|
47
|
-
* isBid: true,
|
|
48
|
-
* isFlip: false,
|
|
49
|
-
* maker: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
|
|
50
|
-
* next: '0x0',
|
|
51
|
-
* orderId: '0x1',
|
|
52
|
-
* quoteToken: '0x20c0000000000000000000000000000000000002',
|
|
53
|
-
* prev: '0x0',
|
|
54
|
-
* remaining: '0x64',
|
|
55
|
-
* tick: 100,
|
|
56
|
-
* })
|
|
57
|
-
* // @log: { amount: 100n, orderId: 1n, ... }
|
|
58
|
-
* ```
|
|
59
|
-
*
|
|
60
|
-
* @param order - RPC-formatted order.
|
|
61
|
-
* @returns Internal order representation.
|
|
62
|
-
*/
|
|
63
|
-
export declare function fromRpc(order: Rpc): Order;
|
|
64
|
-
/**
|
|
65
|
-
* Converts an internal order representation to RPC format.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```ts twoslash
|
|
69
|
-
* import { Order } from 'tempo.ts/ox'
|
|
70
|
-
*
|
|
71
|
-
* const rpcOrder = Order.toRpc({
|
|
72
|
-
* amount: 100n,
|
|
73
|
-
* baseToken: '0x20c0000000000000000000000000000000000001',
|
|
74
|
-
* flipTick: 0,
|
|
75
|
-
* isBid: true,
|
|
76
|
-
* isFlip: false,
|
|
77
|
-
* maker: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
|
|
78
|
-
* next: 0n,
|
|
79
|
-
* orderId: 1n,
|
|
80
|
-
* quoteToken: '0x20c0000000000000000000000000000000000002',
|
|
81
|
-
* prev: 0n,
|
|
82
|
-
* remaining: 100n,
|
|
83
|
-
* tick: 100,
|
|
84
|
-
* })
|
|
85
|
-
* // @log: { amount: '0x64', orderId: '0x1', ... }
|
|
86
|
-
* ```
|
|
87
|
-
*
|
|
88
|
-
* @param order - Internal order representation.
|
|
89
|
-
* @returns RPC-formatted order.
|
|
90
|
-
*/
|
|
91
|
-
export declare function toRpc(order: Order): Rpc;
|
|
92
|
-
//# sourceMappingURL=Order.d.ts.map
|
package/dist/ox/Order.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Order.d.ts","sourceRoot":"","sources":["../../src/ox/Order.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,YAAY,CAAA;AAC1C,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAE7B;;GAEG;AACH,MAAM,MAAM,KAAK,CAAC,UAAU,GAAG,MAAM,IAAI;IACvC,6BAA6B;IAC7B,MAAM,EAAE,UAAU,CAAA;IAClB,iCAAiC;IACjC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAA;IAC1B,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAA;IAChB,4DAA4D;IAC5D,KAAK,EAAE,OAAO,CAAA;IACd,gEAAgE;IAChE,MAAM,EAAE,OAAO,CAAA;IACf,8BAA8B;IAC9B,KAAK,EAAE,OAAO,CAAC,OAAO,CAAA;IACtB,mCAAmC;IACnC,IAAI,EAAE,UAAU,CAAA;IAChB,uBAAuB;IACvB,OAAO,EAAE,UAAU,CAAA;IACnB,kCAAkC;IAClC,UAAU,EAAE,OAAO,CAAC,OAAO,CAAA;IAC3B,uCAAuC;IACvC,IAAI,EAAE,UAAU,CAAA;IAChB,gCAAgC;IAChC,SAAS,EAAE,UAAU,CAAA;IACrB,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,CAezC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,GAAG,CAevC"}
|
package/dist/ox/Order.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import * as Hex from 'ox/Hex';
|
|
2
|
-
/**
|
|
3
|
-
* Converts an RPC-formatted order to an internal order representation.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts twoslash
|
|
7
|
-
* import { Order } from 'tempo.ts/ox'
|
|
8
|
-
*
|
|
9
|
-
* const order = Order.fromRpc({
|
|
10
|
-
* amount: '0x64',
|
|
11
|
-
* baseToken: '0x20c0000000000000000000000000000000000001',
|
|
12
|
-
* flipTick: 0,
|
|
13
|
-
* isBid: true,
|
|
14
|
-
* isFlip: false,
|
|
15
|
-
* maker: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
|
|
16
|
-
* next: '0x0',
|
|
17
|
-
* orderId: '0x1',
|
|
18
|
-
* quoteToken: '0x20c0000000000000000000000000000000000002',
|
|
19
|
-
* prev: '0x0',
|
|
20
|
-
* remaining: '0x64',
|
|
21
|
-
* tick: 100,
|
|
22
|
-
* })
|
|
23
|
-
* // @log: { amount: 100n, orderId: 1n, ... }
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @param order - RPC-formatted order.
|
|
27
|
-
* @returns Internal order representation.
|
|
28
|
-
*/
|
|
29
|
-
export function fromRpc(order) {
|
|
30
|
-
return {
|
|
31
|
-
amount: Hex.toBigInt(order.amount),
|
|
32
|
-
baseToken: order.baseToken,
|
|
33
|
-
flipTick: order.flipTick,
|
|
34
|
-
isBid: order.isBid,
|
|
35
|
-
isFlip: order.isFlip,
|
|
36
|
-
maker: order.maker,
|
|
37
|
-
next: Hex.toBigInt(order.next),
|
|
38
|
-
orderId: Hex.toBigInt(order.orderId),
|
|
39
|
-
quoteToken: order.quoteToken,
|
|
40
|
-
prev: Hex.toBigInt(order.prev),
|
|
41
|
-
remaining: Hex.toBigInt(order.remaining),
|
|
42
|
-
tick: order.tick,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Converts an internal order representation to RPC format.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```ts twoslash
|
|
50
|
-
* import { Order } from 'tempo.ts/ox'
|
|
51
|
-
*
|
|
52
|
-
* const rpcOrder = Order.toRpc({
|
|
53
|
-
* amount: 100n,
|
|
54
|
-
* baseToken: '0x20c0000000000000000000000000000000000001',
|
|
55
|
-
* flipTick: 0,
|
|
56
|
-
* isBid: true,
|
|
57
|
-
* isFlip: false,
|
|
58
|
-
* maker: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
|
|
59
|
-
* next: 0n,
|
|
60
|
-
* orderId: 1n,
|
|
61
|
-
* quoteToken: '0x20c0000000000000000000000000000000000002',
|
|
62
|
-
* prev: 0n,
|
|
63
|
-
* remaining: 100n,
|
|
64
|
-
* tick: 100,
|
|
65
|
-
* })
|
|
66
|
-
* // @log: { amount: '0x64', orderId: '0x1', ... }
|
|
67
|
-
* ```
|
|
68
|
-
*
|
|
69
|
-
* @param order - Internal order representation.
|
|
70
|
-
* @returns RPC-formatted order.
|
|
71
|
-
*/
|
|
72
|
-
export function toRpc(order) {
|
|
73
|
-
return {
|
|
74
|
-
amount: Hex.fromNumber(order.amount),
|
|
75
|
-
baseToken: order.baseToken,
|
|
76
|
-
flipTick: order.flipTick,
|
|
77
|
-
isBid: order.isBid,
|
|
78
|
-
isFlip: order.isFlip,
|
|
79
|
-
maker: order.maker,
|
|
80
|
-
next: Hex.fromNumber(order.next),
|
|
81
|
-
orderId: Hex.fromNumber(order.orderId),
|
|
82
|
-
quoteToken: order.quoteToken,
|
|
83
|
-
prev: Hex.fromNumber(order.prev),
|
|
84
|
-
remaining: Hex.fromNumber(order.remaining),
|
|
85
|
-
tick: order.tick,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
//# sourceMappingURL=Order.js.map
|
package/dist/ox/Order.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Order.js","sourceRoot":"","sources":["../../src/ox/Order.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAqC7B;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,OAAO,CAAC,KAAU;IAChC,OAAO;QACL,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC;QAClC,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;QAC9B,OAAO,EAAE,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC;QACpC,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;QAC9B,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC;QACxC,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,KAAK,CAAC,KAAY;IAChC,OAAO;QACL,MAAM,EAAE,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC;QACpC,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,IAAI,EAAE,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC;QAChC,OAAO,EAAE,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC;QACtC,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,IAAI,EAAE,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC;QAChC,SAAS,EAAE,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC;QAC1C,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAA;AACH,CAAC"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type * as Address from 'ox/Address';
|
|
2
|
-
import * as Hex from 'ox/Hex';
|
|
3
|
-
import type * as Pagination from './Pagination.js';
|
|
4
|
-
import type * as Tick from './Tick.js';
|
|
5
|
-
/**
|
|
6
|
-
* Filter configuration for orders query.
|
|
7
|
-
*/
|
|
8
|
-
export type OrdersFilters<bigintType = bigint> = {
|
|
9
|
-
/** Filter by specific base token. */
|
|
10
|
-
baseToken?: Address.Address | undefined;
|
|
11
|
-
/** Filter by order side (true=buy, false=sell). */
|
|
12
|
-
isBid?: boolean | undefined;
|
|
13
|
-
/** Filter flip orders. */
|
|
14
|
-
isFlip?: boolean | undefined;
|
|
15
|
-
/** Filter by maker address. */
|
|
16
|
-
maker?: Address.Address | undefined;
|
|
17
|
-
/** Filter by quote token. */
|
|
18
|
-
quoteToken?: Address.Address | undefined;
|
|
19
|
-
/** Remaining amount in range. */
|
|
20
|
-
remaining?: Pagination.FilterRange<bigintType> | undefined;
|
|
21
|
-
/** Tick in range (from -2000 to 2000). */
|
|
22
|
-
tick?: Pagination.FilterRange<Tick.Tick> | undefined;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* RPC-formatted orders filters.
|
|
26
|
-
*/
|
|
27
|
-
export type Rpc = OrdersFilters<Hex.Hex>;
|
|
28
|
-
/**
|
|
29
|
-
* Converts RPC-formatted orders filters to internal representation.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```ts twoslash
|
|
33
|
-
* import { OrdersRequest } from 'tempo.ts/ox'
|
|
34
|
-
*
|
|
35
|
-
* const filters = OrdersRequest.fromRpc({
|
|
36
|
-
* baseToken: '0x20c0000000000000000000000000000000000001',
|
|
37
|
-
* isBid: true,
|
|
38
|
-
* remaining: {
|
|
39
|
-
* min: '0x64',
|
|
40
|
-
* max: '0x3e8',
|
|
41
|
-
* },
|
|
42
|
-
* })
|
|
43
|
-
* // @log: { baseToken: '0x20c0...', isBid: true, remaining: { min: 100n, max: 1000n } }
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* @param filters - RPC-formatted filters.
|
|
47
|
-
* @returns Internal filters representation.
|
|
48
|
-
*/
|
|
49
|
-
export declare function fromRpc(filters: Rpc): OrdersFilters;
|
|
50
|
-
/**
|
|
51
|
-
* Converts internal orders filters to RPC format.
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```ts twoslash
|
|
55
|
-
* import { OrdersRequest } from 'tempo.ts/ox'
|
|
56
|
-
*
|
|
57
|
-
* const rpcFilters = OrdersRequest.toRpc({
|
|
58
|
-
* baseToken: '0x20c0000000000000000000000000000000000001',
|
|
59
|
-
* isBid: true,
|
|
60
|
-
* remaining: {
|
|
61
|
-
* min: 100n,
|
|
62
|
-
* max: 1000n,
|
|
63
|
-
* },
|
|
64
|
-
* })
|
|
65
|
-
* // @log: { baseToken: '0x20c0...', isBid: true, remaining: { min: '0x64', max: '0x3e8' } }
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
|
-
* @param filters - Internal filters representation.
|
|
69
|
-
* @returns RPC-formatted filters.
|
|
70
|
-
*/
|
|
71
|
-
export declare function toRpc(filters: OrdersFilters): Rpc;
|
|
72
|
-
//# sourceMappingURL=OrdersFilters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OrdersFilters.d.ts","sourceRoot":"","sources":["../../src/ox/OrdersFilters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,YAAY,CAAA;AAC1C,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAC7B,OAAO,KAAK,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAClD,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAA;AAEtC;;GAEG;AACH,MAAM,MAAM,aAAa,CAAC,UAAU,GAAG,MAAM,IAAI;IAC/C,qCAAqC;IACrC,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,GAAG,SAAS,CAAA;IACvC,mDAAmD;IACnD,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC3B,0BAA0B;IAC1B,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC5B,+BAA+B;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,GAAG,SAAS,CAAA;IACnC,6BAA6B;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC,OAAO,GAAG,SAAS,CAAA;IACxC,iCAAiC;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