ox 0.14.23 → 0.14.24
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 +6 -0
- package/_cjs/tempo/Channel.js +9 -9
- package/_cjs/tempo/Channel.js.map +1 -1
- package/_cjs/tempo/ChannelDescriptor.js +24 -0
- package/_cjs/tempo/ChannelDescriptor.js.map +1 -0
- package/_cjs/tempo/index.js +2 -1
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/tempo/Channel.js +9 -9
- package/_esm/tempo/Channel.js.map +1 -1
- package/_esm/tempo/ChannelDescriptor.js +43 -0
- package/_esm/tempo/ChannelDescriptor.js.map +1 -0
- package/_esm/tempo/index.js +22 -0
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/tempo/Channel.d.ts +4 -20
- package/_types/tempo/Channel.d.ts.map +1 -1
- package/_types/tempo/ChannelDescriptor.d.ts +73 -0
- package/_types/tempo/ChannelDescriptor.d.ts.map +1 -0
- package/_types/tempo/index.d.ts +22 -0
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/package.json +6 -1
- package/tempo/Channel.test.ts +2 -3
- package/tempo/Channel.ts +12 -27
- package/tempo/ChannelDescriptor/package.json +6 -0
- package/tempo/ChannelDescriptor.test.ts +93 -0
- package/tempo/ChannelDescriptor.ts +115 -0
- package/tempo/index.ts +22 -0
- package/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# ox
|
|
2
2
|
|
|
3
|
+
## 0.14.24
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#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.
|
|
8
|
+
|
|
3
9
|
## 0.14.23
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/_cjs/tempo/Channel.js
CHANGED
|
@@ -7,8 +7,7 @@ exports.getVoucherSignPayload = getVoucherSignPayload;
|
|
|
7
7
|
const AbiParameters = require("../core/AbiParameters.js");
|
|
8
8
|
const Hash = require("../core/Hash.js");
|
|
9
9
|
const Hex = require("../core/Hex.js");
|
|
10
|
-
const
|
|
11
|
-
const TokenId = require("./TokenId.js");
|
|
10
|
+
const ChannelDescriptor = require("./ChannelDescriptor.js");
|
|
12
11
|
const channelIdParameters = AbiParameters.from('address, address, address, address, bytes32, address, bytes32, address, uint256');
|
|
13
12
|
const domainSeparatorParameters = AbiParameters.from('bytes32, bytes32, bytes32, uint256, address');
|
|
14
13
|
const voucherHashParameters = AbiParameters.from('bytes32, bytes32, uint96');
|
|
@@ -19,14 +18,15 @@ exports.address = '0x4d50500000000000000000000000000000000000';
|
|
|
19
18
|
exports.closeGracePeriod = 900n;
|
|
20
19
|
exports.voucherTypehash = Hash.keccak256(Hex.fromString('Voucher(bytes32 channelId,uint96 cumulativeAmount)'));
|
|
21
20
|
function computeId(value) {
|
|
21
|
+
const descriptor = ChannelDescriptor.from(value);
|
|
22
22
|
return Hash.keccak256(AbiParameters.encode(channelIdParameters, [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
descriptor.payer,
|
|
24
|
+
descriptor.payee,
|
|
25
|
+
descriptor.operator,
|
|
26
|
+
descriptor.token,
|
|
27
|
+
descriptor.salt,
|
|
28
|
+
descriptor.authorizedSigner,
|
|
29
|
+
descriptor.expiringNonceHash,
|
|
30
30
|
exports.address,
|
|
31
31
|
BigInt(value.chainId),
|
|
32
32
|
]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Channel.js","sourceRoot":"","sources":["../../tempo/Channel.ts"],"names":[],"mapp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B;QAC5B,eAAO;QACP,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;KACtB,CAAC,CACH,CAAA;AACH,CAAC;AA8BD,SAAgB,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,eAAO;KACR,CAAC,CACH,CAAA;AACH,CAAC;AA+BD,SAAgB,qBAAqB,CACnC,KAAkC;IAElC,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAChC,aAAa,CAAC,MAAM,CAAC,qBAAqB,EAAE;QAC1C,uBAAe;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"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.from = from;
|
|
4
|
+
const Address = require("../core/Address.js");
|
|
5
|
+
const TokenId = require("./TokenId.js");
|
|
6
|
+
const zeroAddress = '0x0000000000000000000000000000000000000000';
|
|
7
|
+
function from(value) {
|
|
8
|
+
const { authorizedSigner = zeroAddress, expiringNonceHash, operator = zeroAddress, payee, payer, salt, token, } = value;
|
|
9
|
+
return {
|
|
10
|
+
authorizedSigner: resolveAddress(authorizedSigner),
|
|
11
|
+
expiringNonceHash,
|
|
12
|
+
operator: resolveAddress(operator),
|
|
13
|
+
payee: resolveAddress(payee),
|
|
14
|
+
payer: resolveAddress(payer),
|
|
15
|
+
salt,
|
|
16
|
+
token: typeof token === 'string'
|
|
17
|
+
? resolveAddress(token)
|
|
18
|
+
: TokenId.toAddress(token),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function resolveAddress(address) {
|
|
22
|
+
return Address.from(address);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=ChannelDescriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChannelDescriptor.js","sourceRoot":"","sources":["../../tempo/ChannelDescriptor.ts"],"names":[],"mappings":";;AA4DA,oBAuBC;AAnFD,8CAA6C;AAG7C,wCAAuC;AAEvC,MAAM,WAAW,GACf,4CAA+E,CAAA;AAsDjF,SAAgB,IAAI,CAAC,KAAiB;IACpC,MAAM,EACJ,gBAAgB,GAAG,WAAW,EAC9B,iBAAiB,EACjB,QAAQ,GAAG,WAAW,EACtB,KAAK,EACL,KAAK,EACL,IAAI,EACJ,KAAK,GACN,GAAG,KAAK,CAAA;IAET,OAAO;QACL,gBAAgB,EAAE,cAAc,CAAC,gBAAgB,CAAC;QAClD,iBAAiB;QACjB,QAAQ,EAAE,cAAc,CAAC,QAAQ,CAAC;QAClC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC;QAC5B,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC;QAC5B,IAAI;QACJ,KAAK,EACH,OAAO,KAAK,KAAK,QAAQ;YACvB,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC;YACvB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC;KAC/B,CAAA;AACH,CAAC;AA6BD,SAAS,cAAc,CAAC,OAAwB;IAC9C,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AAC9B,CAAC"}
|
package/_cjs/tempo/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZoneRpcAuthentication = exports.ZoneId = exports.VirtualMaster = exports.VirtualAddress = exports.TxEnvelopeTempo = exports.TransactionRequest = exports.TransactionReceipt = exports.Transaction = exports.TokenRole = exports.TokenId = exports.Tick = exports.TempoAddress = exports.SignatureEnvelope = exports.RpcSchemaTempo = exports.PoolId = exports.Period = exports.KeyAuthorization = exports.Channel = exports.AuthorizationTempo = void 0;
|
|
3
|
+
exports.ZoneRpcAuthentication = exports.ZoneId = exports.VirtualMaster = exports.VirtualAddress = exports.TxEnvelopeTempo = exports.TransactionRequest = exports.TransactionReceipt = exports.Transaction = exports.TokenRole = exports.TokenId = exports.Tick = exports.TempoAddress = exports.SignatureEnvelope = exports.RpcSchemaTempo = exports.PoolId = exports.Period = exports.KeyAuthorization = exports.ChannelDescriptor = exports.Channel = exports.AuthorizationTempo = void 0;
|
|
4
4
|
exports.AuthorizationTempo = require("./AuthorizationTempo.js");
|
|
5
5
|
exports.Channel = require("./Channel.js");
|
|
6
|
+
exports.ChannelDescriptor = require("./ChannelDescriptor.js");
|
|
6
7
|
exports.KeyAuthorization = require("./KeyAuthorization.js");
|
|
7
8
|
exports.Period = require("./Period.js");
|
|
8
9
|
exports.PoolId = require("./PoolId.js");
|
package/_cjs/tempo/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../tempo/index.ts"],"names":[],"mappings":";;;AAoCA,gEAA6D;AA0B7D,0CAAuC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../tempo/index.ts"],"names":[],"mappings":";;;AAoCA,gEAA6D;AA0B7D,0CAAuC;AAsBvC,8DAA2D;AAwC3D,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,8 +1,7 @@
|
|
|
1
1
|
import * as AbiParameters from '../core/AbiParameters.js';
|
|
2
2
|
import * as Hash from '../core/Hash.js';
|
|
3
3
|
import * as Hex from '../core/Hex.js';
|
|
4
|
-
import * as
|
|
5
|
-
import * as TokenId from './TokenId.js';
|
|
4
|
+
import * as ChannelDescriptor from './ChannelDescriptor.js';
|
|
6
5
|
const channelIdParameters = AbiParameters.from('address, address, address, address, bytes32, address, bytes32, address, uint256');
|
|
7
6
|
const domainSeparatorParameters = AbiParameters.from('bytes32, bytes32, bytes32, uint256, address');
|
|
8
7
|
const voucherHashParameters = AbiParameters.from('bytes32, bytes32, uint96');
|
|
@@ -47,14 +46,15 @@ export const voucherTypehash = Hash.keccak256(Hex.fromString('Voucher(bytes32 ch
|
|
|
47
46
|
* @returns The channel id.
|
|
48
47
|
*/
|
|
49
48
|
export function computeId(value) {
|
|
49
|
+
const descriptor = ChannelDescriptor.from(value);
|
|
50
50
|
return Hash.keccak256(AbiParameters.encode(channelIdParameters, [
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
descriptor.payer,
|
|
52
|
+
descriptor.payee,
|
|
53
|
+
descriptor.operator,
|
|
54
|
+
descriptor.token,
|
|
55
|
+
descriptor.salt,
|
|
56
|
+
descriptor.authorizedSigner,
|
|
57
|
+
descriptor.expiringNonceHash,
|
|
58
58
|
address,
|
|
59
59
|
BigInt(value.chainId),
|
|
60
60
|
]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Channel.js","sourceRoot":"","sources":["../../tempo/Channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAA;AAEzD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AACvC,OAAO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,IAAI,CAAC,SAAS,CACnB,aAAa,CAAC,MAAM,CAAC,mBAAmB,EAAE;QACxC,UAAU,CAAC,KAAK;QAChB,UAAU,CAAC,KAAK;QAChB,UAAU,CAAC,QAAQ;QACnB,UAAU,CAAC,KAAK;QAChB,UAAU,CAAC,IAAI;QACf,UAAU,CAAC,gBAAgB;QAC3B,UAAU,CAAC,iBAAiB;QAC5B,OAAO;QACP,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;KACtB,CAAC,CACH,CAAA;AACH,CAAC;AAcD;;;;;;;;;;;;;;;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"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as Address from '../core/Address.js';
|
|
2
|
+
import * as TokenId from './TokenId.js';
|
|
3
|
+
const zeroAddress = '0x0000000000000000000000000000000000000000';
|
|
4
|
+
/**
|
|
5
|
+
* Instantiates a TIP-20 channel reserve descriptor.
|
|
6
|
+
*
|
|
7
|
+
* Accepts a TIP-20 token ID or address, and defaults `operator` and
|
|
8
|
+
* `authorizedSigner` to the zero address.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts twoslash
|
|
12
|
+
* import { ChannelDescriptor } from 'ox/tempo'
|
|
13
|
+
*
|
|
14
|
+
* const descriptor = ChannelDescriptor.from({
|
|
15
|
+
* expiringNonceHash: '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
16
|
+
* payee: '0x2222222222222222222222222222222222222222',
|
|
17
|
+
* payer: '0x1111111111111111111111111111111111111111',
|
|
18
|
+
* salt: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
19
|
+
* token: 1n,
|
|
20
|
+
* })
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param value - The descriptor input.
|
|
24
|
+
* @returns The normalized channel descriptor.
|
|
25
|
+
*/
|
|
26
|
+
export function from(value) {
|
|
27
|
+
const { authorizedSigner = zeroAddress, expiringNonceHash, operator = zeroAddress, payee, payer, salt, token, } = value;
|
|
28
|
+
return {
|
|
29
|
+
authorizedSigner: resolveAddress(authorizedSigner),
|
|
30
|
+
expiringNonceHash,
|
|
31
|
+
operator: resolveAddress(operator),
|
|
32
|
+
payee: resolveAddress(payee),
|
|
33
|
+
payer: resolveAddress(payer),
|
|
34
|
+
salt,
|
|
35
|
+
token: typeof token === 'string'
|
|
36
|
+
? resolveAddress(token)
|
|
37
|
+
: TokenId.toAddress(token),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function resolveAddress(address) {
|
|
41
|
+
return Address.from(address);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=ChannelDescriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChannelDescriptor.js","sourceRoot":"","sources":["../../tempo/ChannelDescriptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAG7C,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC,MAAM,WAAW,GACf,4CAA+E,CAAA;AAgCjF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,IAAI,CAAC,KAAiB;IACpC,MAAM,EACJ,gBAAgB,GAAG,WAAW,EAC9B,iBAAiB,EACjB,QAAQ,GAAG,WAAW,EACtB,KAAK,EACL,KAAK,EACL,IAAI,EACJ,KAAK,GACN,GAAG,KAAK,CAAA;IAET,OAAO;QACL,gBAAgB,EAAE,cAAc,CAAC,gBAAgB,CAAC;QAClD,iBAAiB;QACjB,QAAQ,EAAE,cAAc,CAAC,QAAQ,CAAC;QAClC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC;QAC5B,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC;QAC5B,IAAI;QACJ,KAAK,EACH,OAAO,KAAK,KAAK,QAAQ;YACvB,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC;YACvB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC;KAC/B,CAAA;AACH,CAAC;AA6BD,SAAS,cAAc,CAAC,OAAwB;IAC9C,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AAC9B,CAAC"}
|
package/_esm/tempo/index.js
CHANGED
|
@@ -57,6 +57,28 @@ export * as AuthorizationTempo from './AuthorizationTempo.js';
|
|
|
57
57
|
* @category Reference
|
|
58
58
|
*/
|
|
59
59
|
export * as Channel from './Channel.js';
|
|
60
|
+
/**
|
|
61
|
+
* TIP-20 channel reserve descriptor utilities.
|
|
62
|
+
*
|
|
63
|
+
* Channel descriptors are emitted by `Channel.open` and then reused to settle,
|
|
64
|
+
* top up, close, request close, withdraw, or compute the channel ID.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts twoslash
|
|
68
|
+
* import { ChannelDescriptor } from 'ox/tempo'
|
|
69
|
+
*
|
|
70
|
+
* const descriptor = ChannelDescriptor.from({
|
|
71
|
+
* expiringNonceHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
72
|
+
* payee: '0x2222222222222222222222222222222222222222',
|
|
73
|
+
* payer: '0x1111111111111111111111111111111111111111',
|
|
74
|
+
* salt: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
75
|
+
* token: 1n,
|
|
76
|
+
* })
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @category Reference
|
|
80
|
+
*/
|
|
81
|
+
export * as ChannelDescriptor from './ChannelDescriptor.js';
|
|
60
82
|
/**
|
|
61
83
|
* Tempo key authorization utilities for provisioning and signing access keys.
|
|
62
84
|
*
|
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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;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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AAoB,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,8 +1,7 @@
|
|
|
1
1
|
import * as AbiParameters from '../core/AbiParameters.js';
|
|
2
2
|
import * as Hash from '../core/Hash.js';
|
|
3
3
|
import * as Hex from '../core/Hex.js';
|
|
4
|
-
import * as
|
|
5
|
-
import * as TokenId from './TokenId.js';
|
|
4
|
+
import * as ChannelDescriptor from './ChannelDescriptor.js';
|
|
6
5
|
/**
|
|
7
6
|
* TIP-20 channel reserve precompile address.
|
|
8
7
|
*/
|
|
@@ -18,22 +17,7 @@ export declare const voucherTypehash: `0x${string}`;
|
|
|
18
17
|
/**
|
|
19
18
|
* TIP-20 channel descriptor.
|
|
20
19
|
*/
|
|
21
|
-
export type Descriptor =
|
|
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;
|
|
32
|
-
/** Optional signer for vouchers. Zero means `payer` signs. */
|
|
33
|
-
authorizedSigner: TempoAddress.Address;
|
|
34
|
-
/** Transaction-derived hash assigned when the channel was opened. */
|
|
35
|
-
expiringNonceHash: Hex.Hex;
|
|
36
|
-
};
|
|
20
|
+
export type Descriptor = ChannelDescriptor.ChannelDescriptor;
|
|
37
21
|
/**
|
|
38
22
|
* Computes the canonical TIP-20 channel id for a descriptor.
|
|
39
23
|
*
|
|
@@ -61,11 +45,11 @@ export type Descriptor = {
|
|
|
61
45
|
*/
|
|
62
46
|
export declare function computeId(value: computeId.Value): Hex.Hex;
|
|
63
47
|
export declare namespace computeId {
|
|
64
|
-
type Value =
|
|
48
|
+
type Value = ChannelDescriptor.from.Value & {
|
|
65
49
|
/** Chain id used by the channel reserve precompile. */
|
|
66
50
|
chainId: number | bigint;
|
|
67
51
|
};
|
|
68
|
-
type ErrorType = AbiParameters.encode.ErrorType |
|
|
52
|
+
type ErrorType = AbiParameters.encode.ErrorType | ChannelDescriptor.from.ErrorType | Hash.keccak256.ErrorType;
|
|
69
53
|
}
|
|
70
54
|
/**
|
|
71
55
|
* 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;AAEzD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"Channel.d.ts","sourceRoot":"","sources":["../../tempo/Channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAA;AAEzD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA;AAkB3D;;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,UAAU,GAAG,iBAAiB,CAAC,iBAAiB,CAA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,GACzB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAA;CAC7B"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as Address from '../core/Address.js';
|
|
2
|
+
import type * as Errors from '../core/Errors.js';
|
|
3
|
+
import type * as Hex from '../core/Hex.js';
|
|
4
|
+
import * as TokenId from './TokenId.js';
|
|
5
|
+
/**
|
|
6
|
+
* TIP-20 channel reserve descriptor.
|
|
7
|
+
*
|
|
8
|
+
* Descriptors identify a channel without reading chain state. They are emitted
|
|
9
|
+
* by `open` and reused by `settle`, `topUp`, `close`, `requestClose`, and
|
|
10
|
+
* `withdraw`.
|
|
11
|
+
*/
|
|
12
|
+
export type ChannelDescriptor<addressType = Address.Address, tokenType = TokenId.TokenIdOrAddress<addressType>> = {
|
|
13
|
+
/** Account that funded the channel and receives refunds. */
|
|
14
|
+
payer: addressType;
|
|
15
|
+
/** Account that receives settled voucher payments. */
|
|
16
|
+
payee: addressType;
|
|
17
|
+
/** Optional relayer allowed to submit `settle` for the payee. */
|
|
18
|
+
operator: addressType;
|
|
19
|
+
/** TIP-20 token address held by the channel. */
|
|
20
|
+
token: tokenType;
|
|
21
|
+
/** User-supplied salt to distinguish otherwise identical channels. */
|
|
22
|
+
salt: Hex.Hex;
|
|
23
|
+
/** Optional signer for vouchers. Zero means `payer` signs. */
|
|
24
|
+
authorizedSigner: addressType;
|
|
25
|
+
/** Transaction-derived hash assigned when the channel was opened. */
|
|
26
|
+
expiringNonceHash: Hex.Hex;
|
|
27
|
+
};
|
|
28
|
+
/** Hex-address-normalized {@link ox#ChannelDescriptor.ChannelDescriptor}. */
|
|
29
|
+
export type Resolved = ChannelDescriptor<Address.Address, Address.Address>;
|
|
30
|
+
/**
|
|
31
|
+
* Instantiates a TIP-20 channel reserve descriptor.
|
|
32
|
+
*
|
|
33
|
+
* Accepts a TIP-20 token ID or address, and defaults `operator` and
|
|
34
|
+
* `authorizedSigner` to the zero address.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts twoslash
|
|
38
|
+
* import { ChannelDescriptor } from 'ox/tempo'
|
|
39
|
+
*
|
|
40
|
+
* const descriptor = ChannelDescriptor.from({
|
|
41
|
+
* expiringNonceHash: '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
42
|
+
* payee: '0x2222222222222222222222222222222222222222',
|
|
43
|
+
* payer: '0x1111111111111111111111111111111111111111',
|
|
44
|
+
* salt: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
45
|
+
* token: 1n,
|
|
46
|
+
* })
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @param value - The descriptor input.
|
|
50
|
+
* @returns The normalized channel descriptor.
|
|
51
|
+
*/
|
|
52
|
+
export declare function from(value: from.Value): from.ReturnType;
|
|
53
|
+
export declare namespace from {
|
|
54
|
+
type Value = {
|
|
55
|
+
/** Account that funded the channel and receives refunds. */
|
|
56
|
+
payer: Address.Address;
|
|
57
|
+
/** Account that receives settled voucher payments. */
|
|
58
|
+
payee: Address.Address;
|
|
59
|
+
/** Optional relayer allowed to submit `settle` for the payee. */
|
|
60
|
+
operator?: Address.Address | undefined;
|
|
61
|
+
/** TIP-20 token address or ID held by the channel. */
|
|
62
|
+
token: TokenId.TokenIdOrAddress<Address.Address>;
|
|
63
|
+
/** User-supplied salt to distinguish otherwise identical channels. */
|
|
64
|
+
salt: Hex.Hex;
|
|
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
|
+
};
|
|
70
|
+
type ReturnType = Resolved;
|
|
71
|
+
type ErrorType = Address.from.ErrorType | Hex.concat.ErrorType | Hex.fromNumber.ErrorType | Errors.GlobalErrorType;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=ChannelDescriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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C,EAAE,OAAO,CAAC,OAAO,GAAG,SAAS,CAAA;QACtC,sDAAsD;QACtD,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAChD,sEAAsE;QACtE,IAAI,EAAE,GAAG,CAAC,GAAG,CAAA;QACb,8DAA8D;QAC9D,gBAAgB,CAAC,EAAE,OAAO,CAAC,OAAO,GAAG,SAAS,CAAA;QAC9C,qEAAqE;QACrE,iBAAiB,EAAE,GAAG,CAAC,GAAG,CAAA;KAC3B,CAAA;IAED,KAAK,UAAU,GAAG,QAAQ,CAAA;IAE1B,KAAK,SAAS,GACV,OAAO,CAAC,IAAI,CAAC,SAAS,GACtB,GAAG,CAAC,MAAM,CAAC,SAAS,GACpB,GAAG,CAAC,UAAU,CAAC,SAAS,GACxB,MAAM,CAAC,eAAe,CAAA;CAC3B"}
|
package/_types/tempo/index.d.ts
CHANGED
|
@@ -59,6 +59,28 @@ export * as AuthorizationTempo from './AuthorizationTempo.js';
|
|
|
59
59
|
* @category Reference
|
|
60
60
|
*/
|
|
61
61
|
export * as Channel from './Channel.js';
|
|
62
|
+
/**
|
|
63
|
+
* TIP-20 channel reserve descriptor utilities.
|
|
64
|
+
*
|
|
65
|
+
* Channel descriptors are emitted by `Channel.open` and then reused to settle,
|
|
66
|
+
* top up, close, request close, withdraw, or compute the channel ID.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts twoslash
|
|
70
|
+
* import { ChannelDescriptor } from 'ox/tempo'
|
|
71
|
+
*
|
|
72
|
+
* const descriptor = ChannelDescriptor.from({
|
|
73
|
+
* expiringNonceHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
74
|
+
* payee: '0x2222222222222222222222222222222222222222',
|
|
75
|
+
* payer: '0x1111111111111111111111111111111111111111',
|
|
76
|
+
* salt: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
77
|
+
* token: 1n,
|
|
78
|
+
* })
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @category Reference
|
|
82
|
+
*/
|
|
83
|
+
export * as ChannelDescriptor from './ChannelDescriptor.js';
|
|
62
84
|
/**
|
|
63
85
|
* Tempo key authorization utilities for provisioning and signing access keys.
|
|
64
86
|
*
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;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;;;;;;;;;;;;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ACH,OAAO,KAAK,qBAAqB,MAAM,4BAA4B,CAAA"}
|
package/_types/version.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ox",
|
|
3
3
|
"description": "Ethereum Standard Library",
|
|
4
|
-
"version": "0.14.
|
|
4
|
+
"version": "0.14.24",
|
|
5
5
|
"main": "./_cjs/index.js",
|
|
6
6
|
"module": "./_esm/index.js",
|
|
7
7
|
"types": "./_types/index.d.ts",
|
|
@@ -509,6 +509,11 @@
|
|
|
509
509
|
"import": "./_esm/tempo/Channel.js",
|
|
510
510
|
"default": "./_cjs/tempo/Channel.js"
|
|
511
511
|
},
|
|
512
|
+
"./tempo/ChannelDescriptor": {
|
|
513
|
+
"types": "./_types/tempo/ChannelDescriptor.d.ts",
|
|
514
|
+
"import": "./_esm/tempo/ChannelDescriptor.js",
|
|
515
|
+
"default": "./_cjs/tempo/ChannelDescriptor.js"
|
|
516
|
+
},
|
|
512
517
|
"./tempo/KeyAuthorization": {
|
|
513
518
|
"types": "./_types/tempo/KeyAuthorization.d.ts",
|
|
514
519
|
"import": "./_esm/tempo/KeyAuthorization.js",
|
package/tempo/Channel.test.ts
CHANGED
|
@@ -48,12 +48,11 @@ describe('computeId', () => {
|
|
|
48
48
|
)
|
|
49
49
|
})
|
|
50
50
|
|
|
51
|
-
test('address
|
|
51
|
+
test('token address input', () => {
|
|
52
52
|
expect(
|
|
53
53
|
Channel.computeId({
|
|
54
54
|
...descriptor,
|
|
55
|
-
|
|
56
|
-
token: 'tempox0x20c0000000000000000000000000000000000001',
|
|
55
|
+
token: '0x20c0000000000000000000000000000000000001',
|
|
57
56
|
}),
|
|
58
57
|
).toBe(Channel.computeId(descriptor))
|
|
59
58
|
})
|
package/tempo/Channel.ts
CHANGED
|
@@ -2,8 +2,7 @@ import * as AbiParameters from '../core/AbiParameters.js'
|
|
|
2
2
|
import type * as Address from '../core/Address.js'
|
|
3
3
|
import * as Hash from '../core/Hash.js'
|
|
4
4
|
import * as Hex from '../core/Hex.js'
|
|
5
|
-
import * as
|
|
6
|
-
import * as TokenId from './TokenId.js'
|
|
5
|
+
import * as ChannelDescriptor from './ChannelDescriptor.js'
|
|
7
6
|
|
|
8
7
|
const channelIdParameters = AbiParameters.from(
|
|
9
8
|
'address, address, address, address, bytes32, address, bytes32, address, uint256',
|
|
@@ -42,22 +41,7 @@ export const voucherTypehash = Hash.keccak256(
|
|
|
42
41
|
/**
|
|
43
42
|
* TIP-20 channel descriptor.
|
|
44
43
|
*/
|
|
45
|
-
export type Descriptor =
|
|
46
|
-
/** Account that funded the channel and receives refunds. */
|
|
47
|
-
payer: TempoAddress.Address
|
|
48
|
-
/** Account that receives settled voucher payments. */
|
|
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
|
|
56
|
-
/** Optional signer for vouchers. Zero means `payer` signs. */
|
|
57
|
-
authorizedSigner: TempoAddress.Address
|
|
58
|
-
/** Transaction-derived hash assigned when the channel was opened. */
|
|
59
|
-
expiringNonceHash: Hex.Hex
|
|
60
|
-
}
|
|
44
|
+
export type Descriptor = ChannelDescriptor.ChannelDescriptor
|
|
61
45
|
|
|
62
46
|
/**
|
|
63
47
|
* Computes the canonical TIP-20 channel id for a descriptor.
|
|
@@ -85,15 +69,16 @@ export type Descriptor = {
|
|
|
85
69
|
* @returns The channel id.
|
|
86
70
|
*/
|
|
87
71
|
export function computeId(value: computeId.Value): Hex.Hex {
|
|
72
|
+
const descriptor = ChannelDescriptor.from(value)
|
|
88
73
|
return Hash.keccak256(
|
|
89
74
|
AbiParameters.encode(channelIdParameters, [
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
75
|
+
descriptor.payer,
|
|
76
|
+
descriptor.payee,
|
|
77
|
+
descriptor.operator,
|
|
78
|
+
descriptor.token,
|
|
79
|
+
descriptor.salt,
|
|
80
|
+
descriptor.authorizedSigner,
|
|
81
|
+
descriptor.expiringNonceHash,
|
|
97
82
|
address,
|
|
98
83
|
BigInt(value.chainId),
|
|
99
84
|
]),
|
|
@@ -101,15 +86,15 @@ export function computeId(value: computeId.Value): Hex.Hex {
|
|
|
101
86
|
}
|
|
102
87
|
|
|
103
88
|
export declare namespace computeId {
|
|
104
|
-
type Value =
|
|
89
|
+
type Value = ChannelDescriptor.from.Value & {
|
|
105
90
|
/** Chain id used by the channel reserve precompile. */
|
|
106
91
|
chainId: number | bigint
|
|
107
92
|
}
|
|
108
93
|
|
|
109
94
|
type ErrorType =
|
|
110
95
|
| AbiParameters.encode.ErrorType
|
|
96
|
+
| ChannelDescriptor.from.ErrorType
|
|
111
97
|
| Hash.keccak256.ErrorType
|
|
112
|
-
| TempoAddress.parse.ErrorType
|
|
113
98
|
}
|
|
114
99
|
|
|
115
100
|
/**
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { Address } from 'ox'
|
|
2
|
+
import { ChannelDescriptor } from 'ox/tempo'
|
|
3
|
+
import { describe, expect, test } from 'vitest'
|
|
4
|
+
|
|
5
|
+
describe('from', () => {
|
|
6
|
+
test('default', () => {
|
|
7
|
+
expect(
|
|
8
|
+
ChannelDescriptor.from({
|
|
9
|
+
authorizedSigner: '0x3333333333333333333333333333333333333333',
|
|
10
|
+
expiringNonceHash:
|
|
11
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
12
|
+
operator: '0x4444444444444444444444444444444444444444',
|
|
13
|
+
payee: '0x2222222222222222222222222222222222222222',
|
|
14
|
+
payer: '0x1111111111111111111111111111111111111111',
|
|
15
|
+
salt: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
16
|
+
token: 1n,
|
|
17
|
+
}),
|
|
18
|
+
).toMatchInlineSnapshot(`
|
|
19
|
+
{
|
|
20
|
+
"authorizedSigner": "0x3333333333333333333333333333333333333333",
|
|
21
|
+
"expiringNonceHash": "0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
22
|
+
"operator": "0x4444444444444444444444444444444444444444",
|
|
23
|
+
"payee": "0x2222222222222222222222222222222222222222",
|
|
24
|
+
"payer": "0x1111111111111111111111111111111111111111",
|
|
25
|
+
"salt": "0x0000000000000000000000000000000000000000000000000000000000000001",
|
|
26
|
+
"token": "0x20c0000000000000000000000000000000000001",
|
|
27
|
+
}
|
|
28
|
+
`)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
test('default values', () => {
|
|
32
|
+
expect(
|
|
33
|
+
ChannelDescriptor.from({
|
|
34
|
+
expiringNonceHash:
|
|
35
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
36
|
+
payee: '0x2222222222222222222222222222222222222222',
|
|
37
|
+
payer: '0x1111111111111111111111111111111111111111',
|
|
38
|
+
salt: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
39
|
+
token: 1n,
|
|
40
|
+
}),
|
|
41
|
+
).toMatchInlineSnapshot(`
|
|
42
|
+
{
|
|
43
|
+
"authorizedSigner": "0x0000000000000000000000000000000000000000",
|
|
44
|
+
"expiringNonceHash": "0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
45
|
+
"operator": "0x0000000000000000000000000000000000000000",
|
|
46
|
+
"payee": "0x2222222222222222222222222222222222222222",
|
|
47
|
+
"payer": "0x1111111111111111111111111111111111111111",
|
|
48
|
+
"salt": "0x0000000000000000000000000000000000000000000000000000000000000001",
|
|
49
|
+
"token": "0x20c0000000000000000000000000000000000001",
|
|
50
|
+
}
|
|
51
|
+
`)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
test('token address input', () => {
|
|
55
|
+
expect(
|
|
56
|
+
ChannelDescriptor.from({
|
|
57
|
+
authorizedSigner: '0x3333333333333333333333333333333333333333',
|
|
58
|
+
expiringNonceHash:
|
|
59
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
60
|
+
operator: '0x4444444444444444444444444444444444444444',
|
|
61
|
+
payee: '0x2222222222222222222222222222222222222222',
|
|
62
|
+
payer: '0x1111111111111111111111111111111111111111',
|
|
63
|
+
salt: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
64
|
+
token: '0x20c0000000000000000000000000000000000001',
|
|
65
|
+
}),
|
|
66
|
+
).toMatchInlineSnapshot(`
|
|
67
|
+
{
|
|
68
|
+
"authorizedSigner": "0x3333333333333333333333333333333333333333",
|
|
69
|
+
"expiringNonceHash": "0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
70
|
+
"operator": "0x4444444444444444444444444444444444444444",
|
|
71
|
+
"payee": "0x2222222222222222222222222222222222222222",
|
|
72
|
+
"payer": "0x1111111111111111111111111111111111111111",
|
|
73
|
+
"salt": "0x0000000000000000000000000000000000000000000000000000000000000001",
|
|
74
|
+
"token": "0x20c0000000000000000000000000000000000001",
|
|
75
|
+
}
|
|
76
|
+
`)
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
test('return type', () => {
|
|
80
|
+
const descriptor = ChannelDescriptor.from({
|
|
81
|
+
expiringNonceHash:
|
|
82
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
83
|
+
payee: '0x2222222222222222222222222222222222222222',
|
|
84
|
+
payer: '0x1111111111111111111111111111111111111111',
|
|
85
|
+
salt: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
86
|
+
token: 1n,
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
descriptor satisfies ChannelDescriptor.Resolved
|
|
90
|
+
descriptor.payer satisfies Address.Address
|
|
91
|
+
descriptor.token satisfies Address.Address
|
|
92
|
+
})
|
|
93
|
+
})
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import * as Address from '../core/Address.js'
|
|
2
|
+
import type * as Errors from '../core/Errors.js'
|
|
3
|
+
import type * as Hex from '../core/Hex.js'
|
|
4
|
+
import * as TokenId from './TokenId.js'
|
|
5
|
+
|
|
6
|
+
const zeroAddress =
|
|
7
|
+
'0x0000000000000000000000000000000000000000' as const satisfies Address.Address
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* TIP-20 channel reserve descriptor.
|
|
11
|
+
*
|
|
12
|
+
* Descriptors identify a channel without reading chain state. They are emitted
|
|
13
|
+
* by `open` and reused by `settle`, `topUp`, `close`, `requestClose`, and
|
|
14
|
+
* `withdraw`.
|
|
15
|
+
*/
|
|
16
|
+
export type ChannelDescriptor<
|
|
17
|
+
addressType = Address.Address,
|
|
18
|
+
tokenType = TokenId.TokenIdOrAddress<addressType>,
|
|
19
|
+
> = {
|
|
20
|
+
/** Account that funded the channel and receives refunds. */
|
|
21
|
+
payer: addressType
|
|
22
|
+
/** Account that receives settled voucher payments. */
|
|
23
|
+
payee: addressType
|
|
24
|
+
/** Optional relayer allowed to submit `settle` for the payee. */
|
|
25
|
+
operator: addressType
|
|
26
|
+
/** TIP-20 token address held by the channel. */
|
|
27
|
+
token: tokenType
|
|
28
|
+
/** User-supplied salt to distinguish otherwise identical channels. */
|
|
29
|
+
salt: Hex.Hex
|
|
30
|
+
/** Optional signer for vouchers. Zero means `payer` signs. */
|
|
31
|
+
authorizedSigner: addressType
|
|
32
|
+
/** Transaction-derived hash assigned when the channel was opened. */
|
|
33
|
+
expiringNonceHash: Hex.Hex
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Hex-address-normalized {@link ox#ChannelDescriptor.ChannelDescriptor}. */
|
|
37
|
+
export type Resolved = ChannelDescriptor<Address.Address, Address.Address>
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Instantiates a TIP-20 channel reserve descriptor.
|
|
41
|
+
*
|
|
42
|
+
* Accepts a TIP-20 token ID or address, and defaults `operator` and
|
|
43
|
+
* `authorizedSigner` to the zero address.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts twoslash
|
|
47
|
+
* import { ChannelDescriptor } from 'ox/tempo'
|
|
48
|
+
*
|
|
49
|
+
* const descriptor = ChannelDescriptor.from({
|
|
50
|
+
* expiringNonceHash: '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
51
|
+
* payee: '0x2222222222222222222222222222222222222222',
|
|
52
|
+
* payer: '0x1111111111111111111111111111111111111111',
|
|
53
|
+
* salt: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
54
|
+
* token: 1n,
|
|
55
|
+
* })
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @param value - The descriptor input.
|
|
59
|
+
* @returns The normalized channel descriptor.
|
|
60
|
+
*/
|
|
61
|
+
export function from(value: from.Value): from.ReturnType {
|
|
62
|
+
const {
|
|
63
|
+
authorizedSigner = zeroAddress,
|
|
64
|
+
expiringNonceHash,
|
|
65
|
+
operator = zeroAddress,
|
|
66
|
+
payee,
|
|
67
|
+
payer,
|
|
68
|
+
salt,
|
|
69
|
+
token,
|
|
70
|
+
} = value
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
authorizedSigner: resolveAddress(authorizedSigner),
|
|
74
|
+
expiringNonceHash,
|
|
75
|
+
operator: resolveAddress(operator),
|
|
76
|
+
payee: resolveAddress(payee),
|
|
77
|
+
payer: resolveAddress(payer),
|
|
78
|
+
salt,
|
|
79
|
+
token:
|
|
80
|
+
typeof token === 'string'
|
|
81
|
+
? resolveAddress(token)
|
|
82
|
+
: TokenId.toAddress(token),
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export declare namespace from {
|
|
87
|
+
type Value = {
|
|
88
|
+
/** Account that funded the channel and receives refunds. */
|
|
89
|
+
payer: Address.Address
|
|
90
|
+
/** Account that receives settled voucher payments. */
|
|
91
|
+
payee: Address.Address
|
|
92
|
+
/** Optional relayer allowed to submit `settle` for the payee. */
|
|
93
|
+
operator?: Address.Address | undefined
|
|
94
|
+
/** TIP-20 token address or ID held by the channel. */
|
|
95
|
+
token: TokenId.TokenIdOrAddress<Address.Address>
|
|
96
|
+
/** User-supplied salt to distinguish otherwise identical channels. */
|
|
97
|
+
salt: Hex.Hex
|
|
98
|
+
/** Optional signer for vouchers. Zero means `payer` signs. */
|
|
99
|
+
authorizedSigner?: Address.Address | undefined
|
|
100
|
+
/** Transaction-derived hash assigned when the channel was opened. */
|
|
101
|
+
expiringNonceHash: Hex.Hex
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
type ReturnType = Resolved
|
|
105
|
+
|
|
106
|
+
type ErrorType =
|
|
107
|
+
| Address.from.ErrorType
|
|
108
|
+
| Hex.concat.ErrorType
|
|
109
|
+
| Hex.fromNumber.ErrorType
|
|
110
|
+
| Errors.GlobalErrorType
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function resolveAddress(address: Address.Address): Address.Address {
|
|
114
|
+
return Address.from(address)
|
|
115
|
+
}
|
package/tempo/index.ts
CHANGED
|
@@ -61,6 +61,28 @@ export * as AuthorizationTempo from './AuthorizationTempo.js'
|
|
|
61
61
|
* @category Reference
|
|
62
62
|
*/
|
|
63
63
|
export * as Channel from './Channel.js'
|
|
64
|
+
/**
|
|
65
|
+
* TIP-20 channel reserve descriptor utilities.
|
|
66
|
+
*
|
|
67
|
+
* Channel descriptors are emitted by `Channel.open` and then reused to settle,
|
|
68
|
+
* top up, close, request close, withdraw, or compute the channel ID.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts twoslash
|
|
72
|
+
* import { ChannelDescriptor } from 'ox/tempo'
|
|
73
|
+
*
|
|
74
|
+
* const descriptor = ChannelDescriptor.from({
|
|
75
|
+
* expiringNonceHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
76
|
+
* payee: '0x2222222222222222222222222222222222222222',
|
|
77
|
+
* payer: '0x1111111111111111111111111111111111111111',
|
|
78
|
+
* salt: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
79
|
+
* token: 1n,
|
|
80
|
+
* })
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @category Reference
|
|
84
|
+
*/
|
|
85
|
+
export * as ChannelDescriptor from './ChannelDescriptor.js'
|
|
64
86
|
/**
|
|
65
87
|
* Tempo key authorization utilities for provisioning and signing access keys.
|
|
66
88
|
*
|
package/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
export const version = '0.14.
|
|
2
|
+
export const version = '0.14.24'
|