ox 0.14.23 → 0.14.25
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/Channel.js +30 -10
- package/_cjs/tempo/Channel.js.map +1 -1
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/tempo/Channel.js +55 -12
- package/_esm/tempo/Channel.js.map +1 -1
- package/_esm/tempo/index.js +9 -8
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/tempo/Channel.d.ts +68 -19
- package/_types/tempo/Channel.d.ts.map +1 -1
- package/_types/tempo/index.d.ts +9 -8
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/package.json +1 -1
- package/tempo/Channel.test.ts +100 -18
- package/tempo/Channel.ts +122 -28
- package/tempo/index.ts +9 -8
- package/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# ox
|
|
2
2
|
|
|
3
|
+
## 0.14.25
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#256](https://github.com/wevm/ox/pull/256) [`ad7610b`](https://github.com/wevm/ox/commit/ad7610b115c1ebc20739289bfacead52652160be) Thanks [@jxom](https://github.com/jxom)! - Renamed `ChannelDescriptor.from` to `Channel.from`, made `Channel.Channel` the descriptor type, and changed `Channel.computeId` to receive channel and options separately.
|
|
8
|
+
|
|
9
|
+
## 0.14.24
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#254](https://github.com/wevm/ox/pull/254) [`d837628`](https://github.com/wevm/ox/commit/d8376284988f6c2b56d9cb18ac2b677465f3b835) Thanks [@jxom](https://github.com/jxom)! - Added `ChannelDescriptor.from` for normalizing TIP-20 channel reserve descriptors.
|
|
14
|
+
|
|
3
15
|
## 0.14.23
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/_cjs/tempo/Channel.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.voucherTypehash = exports.closeGracePeriod = exports.address = void 0;
|
|
4
|
+
exports.from = from;
|
|
4
5
|
exports.computeId = computeId;
|
|
5
6
|
exports.domainSeparator = domainSeparator;
|
|
6
7
|
exports.getVoucherSignPayload = getVoucherSignPayload;
|
|
7
8
|
const AbiParameters = require("../core/AbiParameters.js");
|
|
9
|
+
const Address = require("../core/Address.js");
|
|
8
10
|
const Hash = require("../core/Hash.js");
|
|
9
11
|
const Hex = require("../core/Hex.js");
|
|
10
|
-
const TempoAddress = require("./TempoAddress.js");
|
|
11
12
|
const TokenId = require("./TokenId.js");
|
|
12
13
|
const channelIdParameters = AbiParameters.from('address, address, address, address, bytes32, address, bytes32, address, uint256');
|
|
13
14
|
const domainSeparatorParameters = AbiParameters.from('bytes32, bytes32, bytes32, uint256, address');
|
|
@@ -15,20 +16,36 @@ const voucherHashParameters = AbiParameters.from('bytes32, bytes32, uint96');
|
|
|
15
16
|
const eip712DomainTypehash = Hash.keccak256(Hex.fromString('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'));
|
|
16
17
|
const nameHash = Hash.keccak256(Hex.fromString('TIP20 Channel Reserve'));
|
|
17
18
|
const versionHash = Hash.keccak256(Hex.fromString('1'));
|
|
19
|
+
const zeroAddress = '0x0000000000000000000000000000000000000000';
|
|
18
20
|
exports.address = '0x4d50500000000000000000000000000000000000';
|
|
19
21
|
exports.closeGracePeriod = 900n;
|
|
20
22
|
exports.voucherTypehash = Hash.keccak256(Hex.fromString('Voucher(bytes32 channelId,uint96 cumulativeAmount)'));
|
|
21
|
-
function
|
|
23
|
+
function from(value) {
|
|
24
|
+
const { authorizedSigner = zeroAddress, expiringNonceHash, operator = zeroAddress, payee, payer, salt, token, } = value;
|
|
25
|
+
return {
|
|
26
|
+
authorizedSigner: resolveAddress(authorizedSigner),
|
|
27
|
+
expiringNonceHash,
|
|
28
|
+
operator: resolveAddress(operator),
|
|
29
|
+
payee: resolveAddress(payee),
|
|
30
|
+
payer: resolveAddress(payer),
|
|
31
|
+
salt,
|
|
32
|
+
token: typeof token === 'string'
|
|
33
|
+
? resolveAddress(token)
|
|
34
|
+
: TokenId.toAddress(token),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function computeId(channel, options) {
|
|
38
|
+
const channel_ = from(channel);
|
|
22
39
|
return Hash.keccak256(AbiParameters.encode(channelIdParameters, [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
40
|
+
channel_.payer,
|
|
41
|
+
channel_.payee,
|
|
42
|
+
channel_.operator,
|
|
43
|
+
channel_.token,
|
|
44
|
+
channel_.salt,
|
|
45
|
+
channel_.authorizedSigner,
|
|
46
|
+
channel_.expiringNonceHash,
|
|
30
47
|
exports.address,
|
|
31
|
-
BigInt(
|
|
48
|
+
BigInt(options.chainId),
|
|
32
49
|
]));
|
|
33
50
|
}
|
|
34
51
|
function domainSeparator(value) {
|
|
@@ -48,4 +65,7 @@ function getVoucherSignPayload(value) {
|
|
|
48
65
|
]));
|
|
49
66
|
return Hash.keccak256(Hex.concat('0x1901', domainSeparator({ chainId: value.chainId }), voucherHash));
|
|
50
67
|
}
|
|
68
|
+
function resolveAddress(address) {
|
|
69
|
+
return Address.from(address);
|
|
70
|
+
}
|
|
51
71
|
//# sourceMappingURL=Channel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Channel.js","sourceRoot":"","sources":["../../tempo/Channel.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Channel.js","sourceRoot":"","sources":["../../tempo/Channel.ts"],"names":[],"mappings":";;;AA2FA,oBAuBC;AAwDD,8BAkBC;AAgCD,0CAUC;AA+BD,sDAiB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AAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AAC9B,CAAC"}
|
package/_cjs/tempo/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../tempo/index.ts"],"names":[],"mappings":";;;AAoCA,gEAA6D;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../tempo/index.ts"],"names":[],"mappings":";;;AAoCA,gEAA6D;AA2B7D,0CAAuC;AAwCvC,4DAAyD;AA6BzD,wCAAqC;AAsBrC,wCAAqC;AAoBrC,wDAAqD;AAuBrD,8DAA2D;AAmB3D,oDAAiD;AAoBjD,oCAAiC;AAqBjC,0CAAuC;AAkBvC,8CAA2C;AAkD3C,kDAA+C;AAuB/C,gEAA6D;AAqB7D,gEAA6D;AA6B7D,0DAAuD;AA4BvD,wDAAqD;AAyBrD,sDAAmD;AAqBnD,wCAAqC;AAmCrC,sEAAmE"}
|
package/_cjs/version.js
CHANGED
package/_esm/tempo/Channel.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as AbiParameters from '../core/AbiParameters.js';
|
|
2
|
+
import * as Address from '../core/Address.js';
|
|
2
3
|
import * as Hash from '../core/Hash.js';
|
|
3
4
|
import * as Hex from '../core/Hex.js';
|
|
4
|
-
import * as TempoAddress from './TempoAddress.js';
|
|
5
5
|
import * as TokenId from './TokenId.js';
|
|
6
6
|
const channelIdParameters = AbiParameters.from('address, address, address, address, bytes32, address, bytes32, address, uint256');
|
|
7
7
|
const domainSeparatorParameters = AbiParameters.from('bytes32, bytes32, bytes32, uint256, address');
|
|
@@ -9,6 +9,7 @@ const voucherHashParameters = AbiParameters.from('bytes32, bytes32, uint96');
|
|
|
9
9
|
const eip712DomainTypehash = Hash.keccak256(Hex.fromString('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'));
|
|
10
10
|
const nameHash = Hash.keccak256(Hex.fromString('TIP20 Channel Reserve'));
|
|
11
11
|
const versionHash = Hash.keccak256(Hex.fromString('1'));
|
|
12
|
+
const zeroAddress = '0x0000000000000000000000000000000000000000';
|
|
12
13
|
/**
|
|
13
14
|
* TIP-20 channel reserve precompile address.
|
|
14
15
|
*/
|
|
@@ -21,6 +22,42 @@ export const closeGracePeriod = 900n;
|
|
|
21
22
|
* EIP-712 type hash for `Voucher(bytes32 channelId,uint96 cumulativeAmount)`.
|
|
22
23
|
*/
|
|
23
24
|
export const voucherTypehash = Hash.keccak256(Hex.fromString('Voucher(bytes32 channelId,uint96 cumulativeAmount)'));
|
|
25
|
+
/**
|
|
26
|
+
* Instantiates a TIP-20 channel reserve descriptor.
|
|
27
|
+
*
|
|
28
|
+
* Accepts a TIP-20 token ID or address, and defaults `operator` and
|
|
29
|
+
* `authorizedSigner` to the zero address.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts twoslash
|
|
33
|
+
* import { Channel } from 'ox/tempo'
|
|
34
|
+
*
|
|
35
|
+
* const channel = Channel.from({
|
|
36
|
+
* expiringNonceHash: '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
37
|
+
* payee: '0x2222222222222222222222222222222222222222',
|
|
38
|
+
* payer: '0x1111111111111111111111111111111111111111',
|
|
39
|
+
* salt: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
40
|
+
* token: 1n,
|
|
41
|
+
* })
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @param value - The channel descriptor input.
|
|
45
|
+
* @returns The normalized channel descriptor.
|
|
46
|
+
*/
|
|
47
|
+
export function from(value) {
|
|
48
|
+
const { authorizedSigner = zeroAddress, expiringNonceHash, operator = zeroAddress, payee, payer, salt, token, } = value;
|
|
49
|
+
return {
|
|
50
|
+
authorizedSigner: resolveAddress(authorizedSigner),
|
|
51
|
+
expiringNonceHash,
|
|
52
|
+
operator: resolveAddress(operator),
|
|
53
|
+
payee: resolveAddress(payee),
|
|
54
|
+
payer: resolveAddress(payer),
|
|
55
|
+
salt,
|
|
56
|
+
token: typeof token === 'string'
|
|
57
|
+
? resolveAddress(token)
|
|
58
|
+
: TokenId.toAddress(token),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
24
61
|
/**
|
|
25
62
|
* Computes the canonical TIP-20 channel id for a descriptor.
|
|
26
63
|
*
|
|
@@ -33,30 +70,33 @@ export const voucherTypehash = Hash.keccak256(Hex.fromString('Voucher(bytes32 ch
|
|
|
33
70
|
*
|
|
34
71
|
* const channelId = Channel.computeId({
|
|
35
72
|
* authorizedSigner: '0x0000000000000000000000000000000000000000',
|
|
36
|
-
* chainId: 4217,
|
|
37
73
|
* expiringNonceHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
38
74
|
* operator: '0x0000000000000000000000000000000000000000',
|
|
39
75
|
* payee: '0x2222222222222222222222222222222222222222',
|
|
40
76
|
* payer: '0x1111111111111111111111111111111111111111',
|
|
41
77
|
* salt: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
42
78
|
* token: 1n,
|
|
79
|
+
* }, {
|
|
80
|
+
* chainId: 4217,
|
|
43
81
|
* })
|
|
44
82
|
* ```
|
|
45
83
|
*
|
|
46
|
-
* @param
|
|
84
|
+
* @param channel - Channel descriptor.
|
|
85
|
+
* @param options - Options.
|
|
47
86
|
* @returns The channel id.
|
|
48
87
|
*/
|
|
49
|
-
export function computeId(
|
|
88
|
+
export function computeId(channel, options) {
|
|
89
|
+
const channel_ = from(channel);
|
|
50
90
|
return Hash.keccak256(AbiParameters.encode(channelIdParameters, [
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
91
|
+
channel_.payer,
|
|
92
|
+
channel_.payee,
|
|
93
|
+
channel_.operator,
|
|
94
|
+
channel_.token,
|
|
95
|
+
channel_.salt,
|
|
96
|
+
channel_.authorizedSigner,
|
|
97
|
+
channel_.expiringNonceHash,
|
|
58
98
|
address,
|
|
59
|
-
BigInt(
|
|
99
|
+
BigInt(options.chainId),
|
|
60
100
|
]));
|
|
61
101
|
}
|
|
62
102
|
/**
|
|
@@ -112,4 +152,7 @@ export function getVoucherSignPayload(value) {
|
|
|
112
152
|
]));
|
|
113
153
|
return Hash.keccak256(Hex.concat('0x1901', domainSeparator({ chainId: value.chainId }), voucherHash));
|
|
114
154
|
}
|
|
155
|
+
function resolveAddress(address) {
|
|
156
|
+
return Address.from(address);
|
|
157
|
+
}
|
|
115
158
|
//# sourceMappingURL=Channel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Channel.js","sourceRoot":"","sources":["../../tempo/Channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"Channel.js","sourceRoot":"","sources":["../../tempo/Channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAE7C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC,MAAM,mBAAmB,GAAG,aAAa,CAAC,IAAI,CAC5C,iFAAiF,CAClF,CAAA;AACD,MAAM,yBAAyB,GAAG,aAAa,CAAC,IAAI,CAClD,6CAA6C,CAC9C,CAAA;AACD,MAAM,qBAAqB,GAAG,aAAa,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAA;AAE5E,MAAM,oBAAoB,GAAG,IAAI,CAAC,SAAS,CACzC,GAAG,CAAC,UAAU,CACZ,oFAAoF,CACrF,CACF,CAAA;AACD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAC,CAAA;AACxE,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,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,QAAQ,CAAC,KAAK;QACd,QAAQ,CAAC,IAAI;QACb,QAAQ,CAAC,gBAAgB;QACzB,QAAQ,CAAC,iBAAiB;QAC1B,OAAO;QACP,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;KACxB,CAAC,CACH,CAAA;AACH,CAAC;AAgBD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,eAAe,CAAC,KAA4B;IAC1D,OAAO,IAAI,CAAC,SAAS,CACnB,aAAa,CAAC,MAAM,CAAC,yBAAyB,EAAE;QAC9C,oBAAoB;QACpB,QAAQ;QACR,WAAW;QACX,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;QACrB,OAAO;KACR,CAAC,CACH,CAAA;AACH,CAAC;AAWD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAkC;IAElC,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAChC,aAAa,CAAC,MAAM,CAAC,qBAAqB,EAAE;QAC1C,eAAe;QACf,KAAK,CAAC,SAAS;QACf,KAAK,CAAC,gBAAgB;KACvB,CAAC,CACH,CAAA;IACD,OAAO,IAAI,CAAC,SAAS,CACnB,GAAG,CAAC,MAAM,CACR,QAAQ,EACR,eAAe,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,EAC3C,WAAW,CACZ,CACF,CAAA;AACH,CAAC;AAkBD,SAAS,cAAc,CAAC,OAAwB;IAC9C,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AAC9B,CAAC"}
|
package/_esm/tempo/index.js
CHANGED
|
@@ -32,26 +32,27 @@
|
|
|
32
32
|
*/
|
|
33
33
|
export * as AuthorizationTempo from './AuthorizationTempo.js';
|
|
34
34
|
/**
|
|
35
|
-
* TIP-20 channel reserve constants and deterministic hashing utilities.
|
|
35
|
+
* TIP-20 channel reserve descriptor, constants, and deterministic hashing utilities.
|
|
36
36
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
* Channel descriptors are emitted by `Channel.open` and then reused to settle,
|
|
38
|
+
* top up, close, request close, withdraw, or compute the channel ID. The channel
|
|
39
|
+
* reserve precompile exposes helper methods for channel identifiers, voucher sign
|
|
40
|
+
* payloads, and its EIP-712 domain separator. These utilities compute the same
|
|
41
|
+
* values locally when the chain id and channel fields are known.
|
|
40
42
|
*
|
|
41
43
|
* @example
|
|
42
44
|
* ```ts twoslash
|
|
43
45
|
* import { Channel } from 'ox/tempo'
|
|
44
46
|
*
|
|
45
|
-
* const
|
|
46
|
-
* authorizedSigner: '0x0000000000000000000000000000000000000000',
|
|
47
|
-
* chainId: 4217,
|
|
47
|
+
* const channel = Channel.from({
|
|
48
48
|
* expiringNonceHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
49
|
-
* operator: '0x0000000000000000000000000000000000000000',
|
|
50
49
|
* payee: '0x2222222222222222222222222222222222222222',
|
|
51
50
|
* payer: '0x1111111111111111111111111111111111111111',
|
|
52
51
|
* salt: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
53
52
|
* token: 1n,
|
|
54
53
|
* })
|
|
54
|
+
*
|
|
55
|
+
* const channelId = Channel.computeId(channel, { chainId: 4217 })
|
|
55
56
|
* ```
|
|
56
57
|
*
|
|
57
58
|
* @category Reference
|
package/_esm/tempo/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../tempo/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAC7D
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../tempo/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAC7D;;;;;;;;;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M,qBAAqB,CAAA;AACrD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAEnD;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,KAAK,qBAAqB,MAAM,4BAA4B,CAAA"}
|
package/_esm/version.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as AbiParameters from '../core/AbiParameters.js';
|
|
2
|
+
import * as Address from '../core/Address.js';
|
|
3
|
+
import type * as Errors from '../core/Errors.js';
|
|
2
4
|
import * as Hash from '../core/Hash.js';
|
|
3
5
|
import * as Hex from '../core/Hex.js';
|
|
4
|
-
import * as TempoAddress from './TempoAddress.js';
|
|
5
6
|
import * as TokenId from './TokenId.js';
|
|
6
7
|
/**
|
|
7
8
|
* TIP-20 channel reserve precompile address.
|
|
@@ -18,22 +19,67 @@ export declare const voucherTypehash: `0x${string}`;
|
|
|
18
19
|
/**
|
|
19
20
|
* TIP-20 channel descriptor.
|
|
20
21
|
*/
|
|
21
|
-
export type
|
|
22
|
-
/** Account that funded the channel and receives refunds. */
|
|
23
|
-
payer: TempoAddress.Address;
|
|
24
|
-
/** Account that receives settled voucher payments. */
|
|
25
|
-
payee: TempoAddress.Address;
|
|
26
|
-
/** Optional relayer allowed to submit `settle` for the payee. */
|
|
27
|
-
operator: TempoAddress.Address;
|
|
28
|
-
/** TIP-20 token address held by the channel. */
|
|
29
|
-
token: TokenId.TokenIdOrAddress<TempoAddress.Address>;
|
|
30
|
-
/** User-supplied salt to distinguish otherwise identical channels. */
|
|
31
|
-
salt: Hex.Hex;
|
|
22
|
+
export type Channel<addressType = Address.Address, tokenType = TokenId.TokenIdOrAddress<addressType>> = {
|
|
32
23
|
/** Optional signer for vouchers. Zero means `payer` signs. */
|
|
33
|
-
authorizedSigner:
|
|
24
|
+
authorizedSigner: addressType;
|
|
34
25
|
/** Transaction-derived hash assigned when the channel was opened. */
|
|
35
26
|
expiringNonceHash: Hex.Hex;
|
|
27
|
+
/** Optional relayer allowed to submit `settle` for the payee. */
|
|
28
|
+
operator: addressType;
|
|
29
|
+
/** Account that receives settled voucher payments. */
|
|
30
|
+
payee: addressType;
|
|
31
|
+
/** Account that funded the channel and receives refunds. */
|
|
32
|
+
payer: addressType;
|
|
33
|
+
/** User-supplied salt to distinguish otherwise identical channels. */
|
|
34
|
+
salt: Hex.Hex;
|
|
35
|
+
/** TIP-20 token address held by the channel. */
|
|
36
|
+
token: tokenType;
|
|
36
37
|
};
|
|
38
|
+
/** Hex-address-normalized {@link ox#Channel.Channel}. */
|
|
39
|
+
export type Resolved = Channel<Address.Address, Address.Address>;
|
|
40
|
+
/**
|
|
41
|
+
* Instantiates a TIP-20 channel reserve descriptor.
|
|
42
|
+
*
|
|
43
|
+
* Accepts a TIP-20 token ID or address, and defaults `operator` and
|
|
44
|
+
* `authorizedSigner` to the zero address.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts twoslash
|
|
48
|
+
* import { Channel } from 'ox/tempo'
|
|
49
|
+
*
|
|
50
|
+
* const channel = Channel.from({
|
|
51
|
+
* expiringNonceHash: '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
52
|
+
* payee: '0x2222222222222222222222222222222222222222',
|
|
53
|
+
* payer: '0x1111111111111111111111111111111111111111',
|
|
54
|
+
* salt: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
55
|
+
* token: 1n,
|
|
56
|
+
* })
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @param value - The channel descriptor input.
|
|
60
|
+
* @returns The normalized channel descriptor.
|
|
61
|
+
*/
|
|
62
|
+
export declare function from(value: from.Value): from.ReturnType;
|
|
63
|
+
export declare namespace from {
|
|
64
|
+
type Value = {
|
|
65
|
+
/** Optional signer for vouchers. Zero means `payer` signs. */
|
|
66
|
+
authorizedSigner?: Address.Address | undefined;
|
|
67
|
+
/** Transaction-derived hash assigned when the channel was opened. */
|
|
68
|
+
expiringNonceHash: Hex.Hex;
|
|
69
|
+
/** Optional relayer allowed to submit `settle` for the payee. */
|
|
70
|
+
operator?: Address.Address | undefined;
|
|
71
|
+
/** Account that receives settled voucher payments. */
|
|
72
|
+
payee: Address.Address;
|
|
73
|
+
/** Account that funded the channel and receives refunds. */
|
|
74
|
+
payer: Address.Address;
|
|
75
|
+
/** User-supplied salt to distinguish otherwise identical channels. */
|
|
76
|
+
salt: Hex.Hex;
|
|
77
|
+
/** TIP-20 token address or ID held by the channel. */
|
|
78
|
+
token: TokenId.TokenIdOrAddress<Address.Address>;
|
|
79
|
+
};
|
|
80
|
+
type ReturnType = Resolved;
|
|
81
|
+
type ErrorType = Address.from.ErrorType | Hex.concat.ErrorType | Hex.fromNumber.ErrorType | Errors.GlobalErrorType;
|
|
82
|
+
}
|
|
37
83
|
/**
|
|
38
84
|
* Computes the canonical TIP-20 channel id for a descriptor.
|
|
39
85
|
*
|
|
@@ -46,26 +92,29 @@ export type Descriptor = {
|
|
|
46
92
|
*
|
|
47
93
|
* const channelId = Channel.computeId({
|
|
48
94
|
* authorizedSigner: '0x0000000000000000000000000000000000000000',
|
|
49
|
-
* chainId: 4217,
|
|
50
95
|
* expiringNonceHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
51
96
|
* operator: '0x0000000000000000000000000000000000000000',
|
|
52
97
|
* payee: '0x2222222222222222222222222222222222222222',
|
|
53
98
|
* payer: '0x1111111111111111111111111111111111111111',
|
|
54
99
|
* salt: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
55
100
|
* token: 1n,
|
|
101
|
+
* }, {
|
|
102
|
+
* chainId: 4217,
|
|
56
103
|
* })
|
|
57
104
|
* ```
|
|
58
105
|
*
|
|
59
|
-
* @param
|
|
106
|
+
* @param channel - Channel descriptor.
|
|
107
|
+
* @param options - Options.
|
|
60
108
|
* @returns The channel id.
|
|
61
109
|
*/
|
|
62
|
-
export declare function computeId(
|
|
110
|
+
export declare function computeId(channel: computeId.Channel, options: computeId.Options): Hex.Hex;
|
|
63
111
|
export declare namespace computeId {
|
|
64
|
-
type
|
|
65
|
-
|
|
112
|
+
type Channel = from.Value;
|
|
113
|
+
type Options = {
|
|
114
|
+
/** Chain ID used by the channel reserve precompile. */
|
|
66
115
|
chainId: number | bigint;
|
|
67
116
|
};
|
|
68
|
-
type ErrorType = AbiParameters.encode.ErrorType |
|
|
117
|
+
type ErrorType = AbiParameters.encode.ErrorType | from.ErrorType | Hash.keccak256.ErrorType;
|
|
69
118
|
}
|
|
70
119
|
/**
|
|
71
120
|
* Computes the EIP-712 domain separator for the TIP-20 channel reserve.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Channel.d.ts","sourceRoot":"","sources":["../../tempo/Channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"Channel.d.ts","sourceRoot":"","sources":["../../tempo/Channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAoBvC;;GAEG;AACH,eAAO,MAAM,OAAO,8CAC6D,CAAA;AAEjF;;GAEG;AACH,eAAO,MAAM,gBAAgB,OAAO,CAAA;AAEpC;;GAEG;AACH,eAAO,MAAM,eAAe,eAE3B,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,OAAO,CACjB,WAAW,GAAG,OAAO,CAAC,OAAO,EAC7B,SAAS,GAAG,OAAO,CAAC,gBAAgB,CA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AE,GAAG,CAAC,GAAG,CAAA;QAClB,mDAAmD;QACnD,gBAAgB,EAAE,MAAM,CAAA;KACzB,CAAA;IAED,KAAK,SAAS,GACV,aAAa,CAAC,MAAM,CAAC,SAAS,GAC9B,eAAe,CAAC,SAAS,GACzB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAA;CAC7B"}
|
package/_types/tempo/index.d.ts
CHANGED
|
@@ -34,26 +34,27 @@ export type {};
|
|
|
34
34
|
*/
|
|
35
35
|
export * as AuthorizationTempo from './AuthorizationTempo.js';
|
|
36
36
|
/**
|
|
37
|
-
* TIP-20 channel reserve constants and deterministic hashing utilities.
|
|
37
|
+
* TIP-20 channel reserve descriptor, constants, and deterministic hashing utilities.
|
|
38
38
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
39
|
+
* Channel descriptors are emitted by `Channel.open` and then reused to settle,
|
|
40
|
+
* top up, close, request close, withdraw, or compute the channel ID. The channel
|
|
41
|
+
* reserve precompile exposes helper methods for channel identifiers, voucher sign
|
|
42
|
+
* payloads, and its EIP-712 domain separator. These utilities compute the same
|
|
43
|
+
* values locally when the chain id and channel fields are known.
|
|
42
44
|
*
|
|
43
45
|
* @example
|
|
44
46
|
* ```ts twoslash
|
|
45
47
|
* import { Channel } from 'ox/tempo'
|
|
46
48
|
*
|
|
47
|
-
* const
|
|
48
|
-
* authorizedSigner: '0x0000000000000000000000000000000000000000',
|
|
49
|
-
* chainId: 4217,
|
|
49
|
+
* const channel = Channel.from({
|
|
50
50
|
* expiringNonceHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
51
|
-
* operator: '0x0000000000000000000000000000000000000000',
|
|
52
51
|
* payee: '0x2222222222222222222222222222222222222222',
|
|
53
52
|
* payer: '0x1111111111111111111111111111111111111111',
|
|
54
53
|
* salt: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
55
54
|
* token: 1n,
|
|
56
55
|
* })
|
|
56
|
+
*
|
|
57
|
+
* const channelId = Channel.computeId(channel, { chainId: 4217 })
|
|
57
58
|
* ```
|
|
58
59
|
*
|
|
59
60
|
* @category Reference
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../tempo/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAEhC,YAAY,EAAE,CAAA;AAEd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAC7D
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../tempo/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAEhC,YAAY,EAAE,CAAA;AAEd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAC7D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAA;AACzD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AAErD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA;AAC3D;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AACjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAC7D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAA;AACvD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AACrD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAEnD;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,KAAK,qBAAqB,MAAM,4BAA4B,CAAA"}
|
package/_types/version.d.ts
CHANGED
package/package.json
CHANGED
package/tempo/Channel.test.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Hash, Hex, TypedData } from 'ox'
|
|
1
|
+
import { type Address, Hash, Hex, TypedData } from 'ox'
|
|
2
2
|
import { Channel } from 'ox/tempo'
|
|
3
3
|
import { describe, expect, test } from 'vitest'
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const channel = {
|
|
6
6
|
authorizedSigner: '0x3333333333333333333333333333333333333333',
|
|
7
|
-
chainId: 4217,
|
|
8
7
|
expiringNonceHash:
|
|
9
8
|
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
10
9
|
operator: '0x0000000000000000000000000000000000000000',
|
|
@@ -14,6 +13,8 @@ const descriptor = {
|
|
|
14
13
|
token: 1n,
|
|
15
14
|
} as const
|
|
16
15
|
|
|
16
|
+
const chainId = 4217
|
|
17
|
+
|
|
17
18
|
describe('address', () => {
|
|
18
19
|
test('default', () => {
|
|
19
20
|
expect(Channel.address).toMatchInlineSnapshot(
|
|
@@ -41,39 +42,120 @@ describe('voucherTypehash', () => {
|
|
|
41
42
|
})
|
|
42
43
|
})
|
|
43
44
|
|
|
45
|
+
describe('from', () => {
|
|
46
|
+
test('default', () => {
|
|
47
|
+
expect(
|
|
48
|
+
Channel.from({
|
|
49
|
+
...channel,
|
|
50
|
+
operator: '0x4444444444444444444444444444444444444444',
|
|
51
|
+
}),
|
|
52
|
+
).toMatchInlineSnapshot(`
|
|
53
|
+
{
|
|
54
|
+
"authorizedSigner": "0x3333333333333333333333333333333333333333",
|
|
55
|
+
"expiringNonceHash": "0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
56
|
+
"operator": "0x4444444444444444444444444444444444444444",
|
|
57
|
+
"payee": "0x2222222222222222222222222222222222222222",
|
|
58
|
+
"payer": "0x1111111111111111111111111111111111111111",
|
|
59
|
+
"salt": "0x0000000000000000000000000000000000000000000000000000000000000001",
|
|
60
|
+
"token": "0x20c0000000000000000000000000000000000001",
|
|
61
|
+
}
|
|
62
|
+
`)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
test('default values', () => {
|
|
66
|
+
expect(
|
|
67
|
+
Channel.from({
|
|
68
|
+
expiringNonceHash: channel.expiringNonceHash,
|
|
69
|
+
payee: channel.payee,
|
|
70
|
+
payer: channel.payer,
|
|
71
|
+
salt: channel.salt,
|
|
72
|
+
token: channel.token,
|
|
73
|
+
}),
|
|
74
|
+
).toMatchInlineSnapshot(`
|
|
75
|
+
{
|
|
76
|
+
"authorizedSigner": "0x0000000000000000000000000000000000000000",
|
|
77
|
+
"expiringNonceHash": "0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
78
|
+
"operator": "0x0000000000000000000000000000000000000000",
|
|
79
|
+
"payee": "0x2222222222222222222222222222222222222222",
|
|
80
|
+
"payer": "0x1111111111111111111111111111111111111111",
|
|
81
|
+
"salt": "0x0000000000000000000000000000000000000000000000000000000000000001",
|
|
82
|
+
"token": "0x20c0000000000000000000000000000000000001",
|
|
83
|
+
}
|
|
84
|
+
`)
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
test('token address input', () => {
|
|
88
|
+
expect(
|
|
89
|
+
Channel.from({
|
|
90
|
+
...channel,
|
|
91
|
+
operator: '0x4444444444444444444444444444444444444444',
|
|
92
|
+
token: '0x20c0000000000000000000000000000000000001',
|
|
93
|
+
}),
|
|
94
|
+
).toMatchInlineSnapshot(`
|
|
95
|
+
{
|
|
96
|
+
"authorizedSigner": "0x3333333333333333333333333333333333333333",
|
|
97
|
+
"expiringNonceHash": "0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
98
|
+
"operator": "0x4444444444444444444444444444444444444444",
|
|
99
|
+
"payee": "0x2222222222222222222222222222222222222222",
|
|
100
|
+
"payer": "0x1111111111111111111111111111111111111111",
|
|
101
|
+
"salt": "0x0000000000000000000000000000000000000000000000000000000000000001",
|
|
102
|
+
"token": "0x20c0000000000000000000000000000000000001",
|
|
103
|
+
}
|
|
104
|
+
`)
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
test('return type', () => {
|
|
108
|
+
const resolved = Channel.from({
|
|
109
|
+
expiringNonceHash:
|
|
110
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
111
|
+
payee: '0x2222222222222222222222222222222222222222',
|
|
112
|
+
payer: '0x1111111111111111111111111111111111111111',
|
|
113
|
+
salt: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
114
|
+
token: 1n,
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
resolved satisfies Channel.Resolved
|
|
118
|
+
resolved satisfies Channel.Channel
|
|
119
|
+
resolved.payer satisfies Address.Address
|
|
120
|
+
resolved.token satisfies Address.Address
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
|
|
44
124
|
describe('computeId', () => {
|
|
45
125
|
test('default', () => {
|
|
46
|
-
expect(Channel.computeId(
|
|
126
|
+
expect(Channel.computeId(channel, { chainId })).toMatchInlineSnapshot(
|
|
47
127
|
`"0xa392474fdbb5c6753e8789236893343f11200f43ba53cca09c0cda3651946ef2"`,
|
|
48
128
|
)
|
|
49
129
|
})
|
|
50
130
|
|
|
51
|
-
test('address
|
|
131
|
+
test('token address input', () => {
|
|
52
132
|
expect(
|
|
53
|
-
Channel.computeId(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
133
|
+
Channel.computeId(
|
|
134
|
+
{
|
|
135
|
+
...channel,
|
|
136
|
+
token: '0x20c0000000000000000000000000000000000001',
|
|
137
|
+
},
|
|
138
|
+
{ chainId },
|
|
139
|
+
),
|
|
140
|
+
).toBe(Channel.computeId(channel, { chainId }))
|
|
59
141
|
})
|
|
60
142
|
|
|
61
143
|
test('chain id bigint', () => {
|
|
62
|
-
expect(Channel.computeId({
|
|
63
|
-
Channel.computeId(
|
|
144
|
+
expect(Channel.computeId(channel, { chainId: 4217n })).toBe(
|
|
145
|
+
Channel.computeId(channel, { chainId }),
|
|
64
146
|
)
|
|
65
147
|
})
|
|
66
148
|
})
|
|
67
149
|
|
|
68
150
|
describe('domainSeparator', () => {
|
|
69
151
|
test('default', () => {
|
|
70
|
-
const separator = Channel.domainSeparator({ chainId
|
|
152
|
+
const separator = Channel.domainSeparator({ chainId })
|
|
71
153
|
|
|
72
154
|
expect(separator).toBe(
|
|
73
155
|
TypedData.domainSeparator({
|
|
74
156
|
name: 'TIP20 Channel Reserve',
|
|
75
157
|
version: '1',
|
|
76
|
-
chainId
|
|
158
|
+
chainId,
|
|
77
159
|
verifyingContract: Channel.address,
|
|
78
160
|
}),
|
|
79
161
|
)
|
|
@@ -85,10 +167,10 @@ describe('domainSeparator', () => {
|
|
|
85
167
|
|
|
86
168
|
describe('getVoucherSignPayload', () => {
|
|
87
169
|
test('default', () => {
|
|
88
|
-
const channelId = Channel.computeId(
|
|
170
|
+
const channelId = Channel.computeId(channel, { chainId })
|
|
89
171
|
const cumulativeAmount = 100n
|
|
90
172
|
const payload = Channel.getVoucherSignPayload({
|
|
91
|
-
chainId
|
|
173
|
+
chainId,
|
|
92
174
|
channelId,
|
|
93
175
|
cumulativeAmount,
|
|
94
176
|
})
|
|
@@ -98,7 +180,7 @@ describe('getVoucherSignPayload', () => {
|
|
|
98
180
|
domain: {
|
|
99
181
|
name: 'TIP20 Channel Reserve',
|
|
100
182
|
version: '1',
|
|
101
|
-
chainId
|
|
183
|
+
chainId,
|
|
102
184
|
verifyingContract: Channel.address,
|
|
103
185
|
},
|
|
104
186
|
message: {
|
package/tempo/Channel.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as AbiParameters from '../core/AbiParameters.js'
|
|
2
|
-
import
|
|
2
|
+
import * as Address from '../core/Address.js'
|
|
3
|
+
import type * as Errors from '../core/Errors.js'
|
|
3
4
|
import * as Hash from '../core/Hash.js'
|
|
4
5
|
import * as Hex from '../core/Hex.js'
|
|
5
|
-
import * as TempoAddress from './TempoAddress.js'
|
|
6
6
|
import * as TokenId from './TokenId.js'
|
|
7
7
|
|
|
8
8
|
const channelIdParameters = AbiParameters.from(
|
|
@@ -20,6 +20,8 @@ const eip712DomainTypehash = Hash.keccak256(
|
|
|
20
20
|
)
|
|
21
21
|
const nameHash = Hash.keccak256(Hex.fromString('TIP20 Channel Reserve'))
|
|
22
22
|
const versionHash = Hash.keccak256(Hex.fromString('1'))
|
|
23
|
+
const zeroAddress =
|
|
24
|
+
'0x0000000000000000000000000000000000000000' as const satisfies Address.Address
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* TIP-20 channel reserve precompile address.
|
|
@@ -42,21 +44,101 @@ export const voucherTypehash = Hash.keccak256(
|
|
|
42
44
|
/**
|
|
43
45
|
* TIP-20 channel descriptor.
|
|
44
46
|
*/
|
|
45
|
-
export type
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
payee: TempoAddress.Address
|
|
50
|
-
/** Optional relayer allowed to submit `settle` for the payee. */
|
|
51
|
-
operator: TempoAddress.Address
|
|
52
|
-
/** TIP-20 token address held by the channel. */
|
|
53
|
-
token: TokenId.TokenIdOrAddress<TempoAddress.Address>
|
|
54
|
-
/** User-supplied salt to distinguish otherwise identical channels. */
|
|
55
|
-
salt: Hex.Hex
|
|
47
|
+
export type Channel<
|
|
48
|
+
addressType = Address.Address,
|
|
49
|
+
tokenType = TokenId.TokenIdOrAddress<addressType>,
|
|
50
|
+
> = {
|
|
56
51
|
/** Optional signer for vouchers. Zero means `payer` signs. */
|
|
57
|
-
authorizedSigner:
|
|
52
|
+
authorizedSigner: addressType
|
|
58
53
|
/** Transaction-derived hash assigned when the channel was opened. */
|
|
59
54
|
expiringNonceHash: Hex.Hex
|
|
55
|
+
/** Optional relayer allowed to submit `settle` for the payee. */
|
|
56
|
+
operator: addressType
|
|
57
|
+
/** Account that receives settled voucher payments. */
|
|
58
|
+
payee: addressType
|
|
59
|
+
/** Account that funded the channel and receives refunds. */
|
|
60
|
+
payer: addressType
|
|
61
|
+
/** User-supplied salt to distinguish otherwise identical channels. */
|
|
62
|
+
salt: Hex.Hex
|
|
63
|
+
/** TIP-20 token address held by the channel. */
|
|
64
|
+
token: tokenType
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Hex-address-normalized {@link ox#Channel.Channel}. */
|
|
68
|
+
export type Resolved = Channel<Address.Address, Address.Address>
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Instantiates a TIP-20 channel reserve descriptor.
|
|
72
|
+
*
|
|
73
|
+
* Accepts a TIP-20 token ID or address, and defaults `operator` and
|
|
74
|
+
* `authorizedSigner` to the zero address.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts twoslash
|
|
78
|
+
* import { Channel } from 'ox/tempo'
|
|
79
|
+
*
|
|
80
|
+
* const channel = Channel.from({
|
|
81
|
+
* expiringNonceHash: '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
82
|
+
* payee: '0x2222222222222222222222222222222222222222',
|
|
83
|
+
* payer: '0x1111111111111111111111111111111111111111',
|
|
84
|
+
* salt: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
85
|
+
* token: 1n,
|
|
86
|
+
* })
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @param value - The channel descriptor input.
|
|
90
|
+
* @returns The normalized channel descriptor.
|
|
91
|
+
*/
|
|
92
|
+
export function from(value: from.Value): from.ReturnType {
|
|
93
|
+
const {
|
|
94
|
+
authorizedSigner = zeroAddress,
|
|
95
|
+
expiringNonceHash,
|
|
96
|
+
operator = zeroAddress,
|
|
97
|
+
payee,
|
|
98
|
+
payer,
|
|
99
|
+
salt,
|
|
100
|
+
token,
|
|
101
|
+
} = value
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
authorizedSigner: resolveAddress(authorizedSigner),
|
|
105
|
+
expiringNonceHash,
|
|
106
|
+
operator: resolveAddress(operator),
|
|
107
|
+
payee: resolveAddress(payee),
|
|
108
|
+
payer: resolveAddress(payer),
|
|
109
|
+
salt,
|
|
110
|
+
token:
|
|
111
|
+
typeof token === 'string'
|
|
112
|
+
? resolveAddress(token)
|
|
113
|
+
: TokenId.toAddress(token),
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export declare namespace from {
|
|
118
|
+
type Value = {
|
|
119
|
+
/** Optional signer for vouchers. Zero means `payer` signs. */
|
|
120
|
+
authorizedSigner?: Address.Address | undefined
|
|
121
|
+
/** Transaction-derived hash assigned when the channel was opened. */
|
|
122
|
+
expiringNonceHash: Hex.Hex
|
|
123
|
+
/** Optional relayer allowed to submit `settle` for the payee. */
|
|
124
|
+
operator?: Address.Address | undefined
|
|
125
|
+
/** Account that receives settled voucher payments. */
|
|
126
|
+
payee: Address.Address
|
|
127
|
+
/** Account that funded the channel and receives refunds. */
|
|
128
|
+
payer: Address.Address
|
|
129
|
+
/** User-supplied salt to distinguish otherwise identical channels. */
|
|
130
|
+
salt: Hex.Hex
|
|
131
|
+
/** TIP-20 token address or ID held by the channel. */
|
|
132
|
+
token: TokenId.TokenIdOrAddress<Address.Address>
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
type ReturnType = Resolved
|
|
136
|
+
|
|
137
|
+
type ErrorType =
|
|
138
|
+
| Address.from.ErrorType
|
|
139
|
+
| Hex.concat.ErrorType
|
|
140
|
+
| Hex.fromNumber.ErrorType
|
|
141
|
+
| Errors.GlobalErrorType
|
|
60
142
|
}
|
|
61
143
|
|
|
62
144
|
/**
|
|
@@ -71,45 +153,53 @@ export type Descriptor = {
|
|
|
71
153
|
*
|
|
72
154
|
* const channelId = Channel.computeId({
|
|
73
155
|
* authorizedSigner: '0x0000000000000000000000000000000000000000',
|
|
74
|
-
* chainId: 4217,
|
|
75
156
|
* expiringNonceHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
76
157
|
* operator: '0x0000000000000000000000000000000000000000',
|
|
77
158
|
* payee: '0x2222222222222222222222222222222222222222',
|
|
78
159
|
* payer: '0x1111111111111111111111111111111111111111',
|
|
79
160
|
* salt: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
80
161
|
* token: 1n,
|
|
162
|
+
* }, {
|
|
163
|
+
* chainId: 4217,
|
|
81
164
|
* })
|
|
82
165
|
* ```
|
|
83
166
|
*
|
|
84
|
-
* @param
|
|
167
|
+
* @param channel - Channel descriptor.
|
|
168
|
+
* @param options - Options.
|
|
85
169
|
* @returns The channel id.
|
|
86
170
|
*/
|
|
87
|
-
export function computeId(
|
|
171
|
+
export function computeId(
|
|
172
|
+
channel: computeId.Channel,
|
|
173
|
+
options: computeId.Options,
|
|
174
|
+
): Hex.Hex {
|
|
175
|
+
const channel_ = from(channel)
|
|
88
176
|
return Hash.keccak256(
|
|
89
177
|
AbiParameters.encode(channelIdParameters, [
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
178
|
+
channel_.payer,
|
|
179
|
+
channel_.payee,
|
|
180
|
+
channel_.operator,
|
|
181
|
+
channel_.token,
|
|
182
|
+
channel_.salt,
|
|
183
|
+
channel_.authorizedSigner,
|
|
184
|
+
channel_.expiringNonceHash,
|
|
97
185
|
address,
|
|
98
|
-
BigInt(
|
|
186
|
+
BigInt(options.chainId),
|
|
99
187
|
]),
|
|
100
188
|
)
|
|
101
189
|
}
|
|
102
190
|
|
|
103
191
|
export declare namespace computeId {
|
|
104
|
-
type
|
|
105
|
-
|
|
192
|
+
type Channel = from.Value
|
|
193
|
+
|
|
194
|
+
type Options = {
|
|
195
|
+
/** Chain ID used by the channel reserve precompile. */
|
|
106
196
|
chainId: number | bigint
|
|
107
197
|
}
|
|
108
198
|
|
|
109
199
|
type ErrorType =
|
|
110
200
|
| AbiParameters.encode.ErrorType
|
|
201
|
+
| from.ErrorType
|
|
111
202
|
| Hash.keccak256.ErrorType
|
|
112
|
-
| TempoAddress.parse.ErrorType
|
|
113
203
|
}
|
|
114
204
|
|
|
115
205
|
/**
|
|
@@ -203,3 +293,7 @@ export declare namespace getVoucherSignPayload {
|
|
|
203
293
|
| domainSeparator.ErrorType
|
|
204
294
|
| Hash.keccak256.ErrorType
|
|
205
295
|
}
|
|
296
|
+
|
|
297
|
+
function resolveAddress(address: Address.Address): Address.Address {
|
|
298
|
+
return Address.from(address)
|
|
299
|
+
}
|
package/tempo/index.ts
CHANGED
|
@@ -36,26 +36,27 @@ export type {}
|
|
|
36
36
|
*/
|
|
37
37
|
export * as AuthorizationTempo from './AuthorizationTempo.js'
|
|
38
38
|
/**
|
|
39
|
-
* TIP-20 channel reserve constants and deterministic hashing utilities.
|
|
39
|
+
* TIP-20 channel reserve descriptor, constants, and deterministic hashing utilities.
|
|
40
40
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
41
|
+
* Channel descriptors are emitted by `Channel.open` and then reused to settle,
|
|
42
|
+
* top up, close, request close, withdraw, or compute the channel ID. The channel
|
|
43
|
+
* reserve precompile exposes helper methods for channel identifiers, voucher sign
|
|
44
|
+
* payloads, and its EIP-712 domain separator. These utilities compute the same
|
|
45
|
+
* values locally when the chain id and channel fields are known.
|
|
44
46
|
*
|
|
45
47
|
* @example
|
|
46
48
|
* ```ts twoslash
|
|
47
49
|
* import { Channel } from 'ox/tempo'
|
|
48
50
|
*
|
|
49
|
-
* const
|
|
50
|
-
* authorizedSigner: '0x0000000000000000000000000000000000000000',
|
|
51
|
-
* chainId: 4217,
|
|
51
|
+
* const channel = Channel.from({
|
|
52
52
|
* expiringNonceHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
53
|
-
* operator: '0x0000000000000000000000000000000000000000',
|
|
54
53
|
* payee: '0x2222222222222222222222222222222222222222',
|
|
55
54
|
* payer: '0x1111111111111111111111111111111111111111',
|
|
56
55
|
* salt: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
57
56
|
* token: 1n,
|
|
58
57
|
* })
|
|
58
|
+
*
|
|
59
|
+
* const channelId = Channel.computeId(channel, { chainId: 4217 })
|
|
59
60
|
* ```
|
|
60
61
|
*
|
|
61
62
|
* @category Reference
|
package/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
export const version = '0.14.
|
|
2
|
+
export const version = '0.14.25'
|