ox 0.9.7 → 0.9.8
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/erc7821/Calls.js +39 -0
- package/_cjs/erc7821/Calls.js.map +1 -0
- package/_cjs/erc7821/Execute.js +75 -0
- package/_cjs/erc7821/Execute.js.map +1 -0
- package/_cjs/erc7821/index.js +6 -0
- package/_cjs/erc7821/index.js.map +1 -0
- package/_cjs/index.docs.js +1 -0
- package/_cjs/index.docs.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/erc7821/Calls.js +101 -0
- package/_esm/erc7821/Calls.js.map +1 -0
- package/_esm/erc7821/Execute.js +151 -0
- package/_esm/erc7821/Execute.js.map +1 -0
- package/_esm/erc7821/index.js +69 -0
- package/_esm/erc7821/index.js.map +1 -0
- package/_esm/index.docs.js +1 -0
- package/_esm/index.docs.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/erc7821/Calls.d.ts +102 -0
- package/_types/erc7821/Calls.d.ts.map +1 -0
- package/_types/erc7821/Execute.d.ts +126 -0
- package/_types/erc7821/Execute.d.ts.map +1 -0
- package/_types/erc7821/index.d.ts +71 -0
- package/_types/erc7821/index.d.ts.map +1 -0
- package/_types/index.docs.d.ts +1 -0
- package/_types/index.docs.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/erc7821/Calls/package.json +6 -0
- package/erc7821/Calls.ts +148 -0
- package/erc7821/Execute/package.json +6 -0
- package/erc7821/Execute.ts +197 -0
- package/erc7821/index.ts +73 -0
- package/erc7821/package.json +6 -0
- package/index.docs.ts +1 -0
- package/package.json +16 -1
- package/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# ox
|
|
2
2
|
|
|
3
|
+
## 0.9.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#119](https://github.com/wevm/ox/pull/119) [`447e386`](https://github.com/wevm/ox/commit/447e386a50fe514cf2abd472bace0a934d068358) Thanks [@jxom](https://github.com/jxom)! - Added [ERC-7821](https://eips.ethereum.org/EIPS/eip-7821) modules.
|
|
8
|
+
|
|
3
9
|
## 0.9.7
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encode = encode;
|
|
4
|
+
exports.getAbiParameters = getAbiParameters;
|
|
5
|
+
exports.decode = decode;
|
|
6
|
+
const AbiParameters = require("../core/AbiParameters.js");
|
|
7
|
+
function encode(calls, options = {}) {
|
|
8
|
+
const { opData } = options;
|
|
9
|
+
return AbiParameters.encode(getAbiParameters({ opData: !!opData }), [
|
|
10
|
+
calls.map((call) => ({
|
|
11
|
+
target: call.to,
|
|
12
|
+
value: call.value ?? 0n,
|
|
13
|
+
data: call.data ?? '0x',
|
|
14
|
+
})),
|
|
15
|
+
...(opData ? [opData] : []),
|
|
16
|
+
]);
|
|
17
|
+
}
|
|
18
|
+
function getAbiParameters(options = {}) {
|
|
19
|
+
const { opData } = options;
|
|
20
|
+
return AbiParameters.from([
|
|
21
|
+
'struct Call { address target; uint256 value; bytes data; }',
|
|
22
|
+
'Call[] calls',
|
|
23
|
+
...(opData ? ['bytes opData'] : []),
|
|
24
|
+
]);
|
|
25
|
+
}
|
|
26
|
+
function decode(data, options = {}) {
|
|
27
|
+
const { opData: withOpData = false } = options;
|
|
28
|
+
const decoded = AbiParameters.decode(getAbiParameters({ opData: withOpData }), data);
|
|
29
|
+
const [encodedCalls, opData] = decoded;
|
|
30
|
+
const calls = encodedCalls.map((call) => ({
|
|
31
|
+
to: call.target,
|
|
32
|
+
value: call.value,
|
|
33
|
+
data: call.data,
|
|
34
|
+
}));
|
|
35
|
+
return withOpData
|
|
36
|
+
? { calls, opData: opData === '0x' ? undefined : opData }
|
|
37
|
+
: { calls };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E,UAAU,EAAE,CAAC,EACxC,IAAI,CACiB,CAAA;IACvB,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,OAG9B,CAAA;IAED,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACxC,EAAE,EAAE,IAAI,CAAC,MAAM;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,CAAC,CAAC,CAAA;IAEH,OAAO,UAAU;QACf,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,EAAE;QACzD,CAAC,CAAC,EAAE,KAAK,EAAE,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mode = exports.abiFunction = void 0;
|
|
4
|
+
exports.decodeData = decodeData;
|
|
5
|
+
exports.decodeBatchOfBatchesData = decodeBatchOfBatchesData;
|
|
6
|
+
exports.encodeBatchOfBatchesData = encodeBatchOfBatchesData;
|
|
7
|
+
exports.encodeData = encodeData;
|
|
8
|
+
const AbiFunction = require("../core/AbiFunction.js");
|
|
9
|
+
const index_js_1 = require("../index.js");
|
|
10
|
+
const Calls = require("./Calls.js");
|
|
11
|
+
exports.abiFunction = {
|
|
12
|
+
type: 'function',
|
|
13
|
+
name: 'execute',
|
|
14
|
+
inputs: [
|
|
15
|
+
{
|
|
16
|
+
name: 'mode',
|
|
17
|
+
type: 'bytes32',
|
|
18
|
+
internalType: 'bytes32',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'executionData',
|
|
22
|
+
type: 'bytes',
|
|
23
|
+
internalType: 'bytes',
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
outputs: [],
|
|
27
|
+
stateMutability: 'payable',
|
|
28
|
+
};
|
|
29
|
+
exports.mode = {
|
|
30
|
+
default: '0x0100000000000000000000000000000000000000000000000000000000000000',
|
|
31
|
+
opData: '0x0100000000007821000100000000000000000000000000000000000000000000',
|
|
32
|
+
batchOfBatches: '0x0100000000007821000200000000000000000000000000000000000000000000',
|
|
33
|
+
};
|
|
34
|
+
function decodeData(data) {
|
|
35
|
+
const [m, executionData] = AbiFunction.decodeData(exports.abiFunction, data);
|
|
36
|
+
return Calls.decode(executionData, { opData: m !== exports.mode.default });
|
|
37
|
+
}
|
|
38
|
+
function decodeBatchOfBatchesData(data) {
|
|
39
|
+
const [, executionData] = AbiFunction.decodeData(exports.abiFunction, data);
|
|
40
|
+
const [encodedBatches] = index_js_1.AbiParameters.decode(index_js_1.AbiParameters.from('bytes[]'), executionData);
|
|
41
|
+
return encodedBatches.map((encodedBatch) => {
|
|
42
|
+
try {
|
|
43
|
+
const decoded = Calls.decode(encodedBatch, { opData: true });
|
|
44
|
+
if (decoded.opData) {
|
|
45
|
+
return {
|
|
46
|
+
calls: decoded.calls,
|
|
47
|
+
opData: decoded.opData,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return { calls: decoded.calls };
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
const decoded = Calls.decode(encodedBatch, { opData: false });
|
|
54
|
+
return { calls: decoded.calls };
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function encodeBatchOfBatchesData(batches) {
|
|
59
|
+
const b = index_js_1.AbiParameters.encode(index_js_1.AbiParameters.from('bytes[]'), [
|
|
60
|
+
batches.map((b) => {
|
|
61
|
+
const batch = b;
|
|
62
|
+
return Calls.encode(batch.calls, {
|
|
63
|
+
opData: batch.opData,
|
|
64
|
+
});
|
|
65
|
+
}),
|
|
66
|
+
]);
|
|
67
|
+
return AbiFunction.encodeData(exports.abiFunction, [exports.mode.batchOfBatches, b]);
|
|
68
|
+
}
|
|
69
|
+
function encodeData(calls, options = {}) {
|
|
70
|
+
const { opData } = options;
|
|
71
|
+
const c = Calls.encode(calls, { opData });
|
|
72
|
+
const m = opData ? exports.mode.opData : exports.mode.default;
|
|
73
|
+
return AbiFunction.encodeData(exports.abiFunction, [m, c]);
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=Execute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Execute.js","sourceRoot":"","sources":["../../erc7821/Execute.ts"],"names":[],"mappings":";;;AAmDA,gCAMC;AAsBD,4DA+BC;AAwCD,4DAUC;AAsBD,gCAQC;AA9LD,sDAAqD;AAErD,0CAA2C;AAC3C,oCAAmC;AAStB,QAAA,WAAW,GAAG;IACzB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,SAAS;IACf,MAAM,EAAE;QACN;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,SAAS;YACf,YAAY,EAAE,SAAS;SACxB;QACD;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,OAAO;YACb,YAAY,EAAE,OAAO;SACtB;KACF;IACD,OAAO,EAAE,EAAE;IACX,eAAe,EAAE,SAAS;CACO,CAAA;AAEtB,QAAA,IAAI,GAAG;IAClB,OAAO,EAAE,oEAAoE;IAC7E,MAAM,EAAE,oEAAoE;IAC5E,cAAc,EACZ,oEAAoE;CAC9D,CAAA;AAeV,SAAgB,UAAU,CAAC,IAAa;IACtC,MAAM,CAAC,CAAC,EAAE,aAAa,CAAC,GAAG,WAAW,CAAC,UAAU,CAAC,mBAAW,EAAE,IAAI,CAGlE,CAAA;IACD,OAAO,KAAK,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,CAAC,KAAK,YAAI,CAAC,OAAO,EAAE,CAAC,CAAA;AACpE,CAAC;AAsBD,SAAgB,wBAAwB,CACtC,IAAa;IAEb,MAAM,CAAC,EAAE,aAAa,CAAC,GAAG,WAAW,CAAC,UAAU,CAAC,mBAAW,EAAE,IA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AAC,CAAC,CAAA;AACtE,CAAC;AAsBD,SAAgB,UAAU,CACxB,KAAsB,EACtB,UAA8B,EAAE;IAEhC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;IAC1B,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;IACzC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,YAAI,CAAC,MAAM,CAAC,CAAC,CAAC,YAAI,CAAC,OAAO,CAAA;IAC7C,OAAO,WAAW,CAAC,UAAU,CAAC,mBAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AACpD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../erc7821/index.ts"],"names":[],"mappings":";;;AAqCA,sCAAmC;AAmCnC,0CAAuC"}
|
package/_cjs/index.docs.js
CHANGED
|
@@ -4,5 +4,6 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
tslib_1.__exportStar(require("./index.js"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./erc4337/index.js"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./erc6492/index.js"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./erc7821/index.js"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./erc8010/index.js"), exports);
|
|
8
9
|
//# sourceMappingURL=index.docs.js.map
|
package/_cjs/index.docs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.docs.js","sourceRoot":"","sources":["../index.docs.ts"],"names":[],"mappings":";;;AAGA,qDAA0B;AAC1B,6DAAkC;AAClC,6DAAkC;AAClC,6DAAkC"}
|
|
1
|
+
{"version":3,"file":"index.docs.js","sourceRoot":"","sources":["../index.docs.ts"],"names":[],"mappings":";;;AAGA,qDAA0B;AAC1B,6DAAkC;AAClC,6DAAkC;AAClC,6DAAkC;AAClC,6DAAkC"}
|
package/_cjs/version.js
CHANGED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import * as AbiParameters from '../core/AbiParameters.js';
|
|
2
|
+
/**
|
|
3
|
+
* Encodes a set of ERC-7821 calls.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts twoslash
|
|
7
|
+
* import { Calls } from 'ox/erc7821'
|
|
8
|
+
*
|
|
9
|
+
* const calls = Calls.encode([
|
|
10
|
+
* {
|
|
11
|
+
* data: '0xdeadbeef',
|
|
12
|
+
* to: '0xcafebabecafebabecafebabecafebabecafebabe',
|
|
13
|
+
* value: 1n,
|
|
14
|
+
* },
|
|
15
|
+
* {
|
|
16
|
+
* data: '0xcafebabe',
|
|
17
|
+
* to: '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
|
|
18
|
+
* value: 2n,
|
|
19
|
+
* },
|
|
20
|
+
* ])
|
|
21
|
+
* // @log: '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000120000000000000000000000000cafebabecafebabecafebabecafebabecafebabe0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000deadbeef000000000000000000000000deadbeefdeadbeefdeadbeefdeadbeefdeadbeef0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cafebabe'
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @param calls - Calls to encode.
|
|
25
|
+
* @param options - Options for the encoding.
|
|
26
|
+
* @returns The encoded calls.
|
|
27
|
+
*/
|
|
28
|
+
export function encode(calls, options = {}) {
|
|
29
|
+
const { opData } = options;
|
|
30
|
+
return AbiParameters.encode(getAbiParameters({ opData: !!opData }), [
|
|
31
|
+
calls.map((call) => ({
|
|
32
|
+
target: call.to,
|
|
33
|
+
value: call.value ?? 0n,
|
|
34
|
+
data: call.data ?? '0x',
|
|
35
|
+
})),
|
|
36
|
+
...(opData ? [opData] : []),
|
|
37
|
+
]);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Gets the ABI parameters for the ERC-7821 calls.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts twoslash
|
|
44
|
+
* import { Calls } from 'ox/erc7821'
|
|
45
|
+
*
|
|
46
|
+
* const abiParameters = Calls.getAbiParameters({ opData: true })
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @param options - Options.
|
|
50
|
+
* @returns The ABI parameters.
|
|
51
|
+
*/
|
|
52
|
+
export function getAbiParameters(options = {}) {
|
|
53
|
+
const { opData } = options;
|
|
54
|
+
return AbiParameters.from([
|
|
55
|
+
'struct Call { address target; uint256 value; bytes data; }',
|
|
56
|
+
'Call[] calls',
|
|
57
|
+
...(opData ? ['bytes opData'] : []),
|
|
58
|
+
]);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Decodes a set of ERC-7821 calls from encoded data.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts twoslash
|
|
65
|
+
* import { Calls } from 'ox/erc7821'
|
|
66
|
+
*
|
|
67
|
+
* const data = Calls.decode('0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000cafebabecafebabecafebabecafebabecafebabe000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000004deadbeef00000000000000000000000000000000000000000000000000000000000000000000000000000000deadbeefdeadbeefdeadbeefdeadbeefdeadbeef000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000004cafebabe00000000000000000000000000000000000000000000000000000000')
|
|
68
|
+
* // @log: {
|
|
69
|
+
* // @log: calls: [
|
|
70
|
+
* // @log: {
|
|
71
|
+
* // @log: data: '0xdeadbeef',
|
|
72
|
+
* // @log: to: '0xcafebabecafebabecafebabecafebabecafebabe',
|
|
73
|
+
* // @log: value: 1n,
|
|
74
|
+
* // @log: },
|
|
75
|
+
* // @log: {
|
|
76
|
+
* // @log: data: '0xcafebabe',
|
|
77
|
+
* // @log: to: '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
|
|
78
|
+
* // @log: value: 2n,
|
|
79
|
+
* // @log: },
|
|
80
|
+
* // @log: ]
|
|
81
|
+
* // @log: }
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @param data - The encoded calls data.
|
|
85
|
+
* @param options - Options for decoding.
|
|
86
|
+
* @returns The decoded calls and optional opData.
|
|
87
|
+
*/
|
|
88
|
+
export function decode(data, options = {}) {
|
|
89
|
+
const { opData: withOpData = false } = options;
|
|
90
|
+
const decoded = AbiParameters.decode(getAbiParameters({ opData: withOpData }), data);
|
|
91
|
+
const [encodedCalls, opData] = decoded;
|
|
92
|
+
const calls = encodedCalls.map((call) => ({
|
|
93
|
+
to: call.target,
|
|
94
|
+
value: call.value,
|
|
95
|
+
data: call.data,
|
|
96
|
+
}));
|
|
97
|
+
return withOpData
|
|
98
|
+
? { calls, opData: opData === '0x' ? undefined : opData }
|
|
99
|
+
: { calls };
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=Calls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Calls.js","sourceRoot":"","sources":["../../erc7821/Calls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAA;AAUzD;;;;;;;;;;;;;;;;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K,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACxC,EAAE,EAAE,IAAI,CAAC,MAAM;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,CAAC,CAAC,CAAA;IAEH,OAAO,UAAU;QACf,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,EAAE;QACzD,CAAC,CAAC,EAAE,KAAK,EAAE,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import * as AbiFunction from '../core/AbiFunction.js';
|
|
2
|
+
import { AbiParameters } from '../index.js';
|
|
3
|
+
import * as Calls from './Calls.js';
|
|
4
|
+
export const abiFunction = {
|
|
5
|
+
type: 'function',
|
|
6
|
+
name: 'execute',
|
|
7
|
+
inputs: [
|
|
8
|
+
{
|
|
9
|
+
name: 'mode',
|
|
10
|
+
type: 'bytes32',
|
|
11
|
+
internalType: 'bytes32',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'executionData',
|
|
15
|
+
type: 'bytes',
|
|
16
|
+
internalType: 'bytes',
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
outputs: [],
|
|
20
|
+
stateMutability: 'payable',
|
|
21
|
+
};
|
|
22
|
+
export const mode = {
|
|
23
|
+
default: '0x0100000000000000000000000000000000000000000000000000000000000000',
|
|
24
|
+
opData: '0x0100000000007821000100000000000000000000000000000000000000000000',
|
|
25
|
+
batchOfBatches: '0x0100000000007821000200000000000000000000000000000000000000000000',
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Decodes calls from ERC-7821 `execute` function data.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts twoslash
|
|
32
|
+
* import { Execute } from 'ox/erc7821'
|
|
33
|
+
*
|
|
34
|
+
* const { calls } = Execute.decodeData('0x...')
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @param data - The encoded data.
|
|
38
|
+
* @returns The decoded calls and optional opData.
|
|
39
|
+
*/
|
|
40
|
+
export function decodeData(data) {
|
|
41
|
+
const [m, executionData] = AbiFunction.decodeData(abiFunction, data);
|
|
42
|
+
return Calls.decode(executionData, { opData: m !== mode.default });
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Decodes batches from ERC-7821 `execute` function data in "batch of batches" mode.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts twoslash
|
|
49
|
+
* import { Execute } from 'ox/erc7821'
|
|
50
|
+
*
|
|
51
|
+
* const batches = Execute.decodeBatchOfBatchesData('0x...')
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @param data - The encoded data.
|
|
55
|
+
* @returns The decoded batches.
|
|
56
|
+
*/
|
|
57
|
+
export function decodeBatchOfBatchesData(data) {
|
|
58
|
+
const [, executionData] = AbiFunction.decodeData(abiFunction, data);
|
|
59
|
+
const [encodedBatches] = AbiParameters.decode(AbiParameters.from('bytes[]'), executionData);
|
|
60
|
+
return encodedBatches.map((encodedBatch) => {
|
|
61
|
+
// Try decoding with opData first
|
|
62
|
+
try {
|
|
63
|
+
const decoded = Calls.decode(encodedBatch, { opData: true });
|
|
64
|
+
if (decoded.opData) {
|
|
65
|
+
return {
|
|
66
|
+
calls: decoded.calls,
|
|
67
|
+
opData: decoded.opData,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
// If opData is undefined, return without it
|
|
71
|
+
return { calls: decoded.calls };
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// If decoding with opData fails, decode without it
|
|
75
|
+
const decoded = Calls.decode(encodedBatch, { opData: false });
|
|
76
|
+
return { calls: decoded.calls };
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Encodes calls for the ERC-7821 `execute` function with "batch of batches" mode.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts twoslash
|
|
85
|
+
* import { Execute } from 'ox/erc7821'
|
|
86
|
+
*
|
|
87
|
+
* const data = Execute.encodeBatchOfBatchesData([
|
|
88
|
+
* {
|
|
89
|
+
* calls: [
|
|
90
|
+
* {
|
|
91
|
+
* data: '0xcafebabe',
|
|
92
|
+
* to: '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
|
|
93
|
+
* value: 1n,
|
|
94
|
+
* }
|
|
95
|
+
* ]
|
|
96
|
+
* },
|
|
97
|
+
* {
|
|
98
|
+
* calls: [
|
|
99
|
+
* {
|
|
100
|
+
* data: '0xdeadbeef',
|
|
101
|
+
* to: '0xcafebabecafebabecafebabecafebabecafebabe',
|
|
102
|
+
* value: 2n,
|
|
103
|
+
* }
|
|
104
|
+
* ],
|
|
105
|
+
* opData: '0xcafebabe',
|
|
106
|
+
* }
|
|
107
|
+
* ])
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @param calls - The calls to encode.
|
|
111
|
+
* @param options - The options.
|
|
112
|
+
* @returns The encoded data.
|
|
113
|
+
*/
|
|
114
|
+
export function encodeBatchOfBatchesData(batches) {
|
|
115
|
+
const b = AbiParameters.encode(AbiParameters.from('bytes[]'), [
|
|
116
|
+
batches.map((b) => {
|
|
117
|
+
const batch = b;
|
|
118
|
+
return Calls.encode(batch.calls, {
|
|
119
|
+
opData: batch.opData,
|
|
120
|
+
});
|
|
121
|
+
}),
|
|
122
|
+
]);
|
|
123
|
+
return AbiFunction.encodeData(abiFunction, [mode.batchOfBatches, b]);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Encodes calls for the ERC-7821 `execute` function.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts twoslash
|
|
130
|
+
* import { Execute } from 'ox/erc7821'
|
|
131
|
+
*
|
|
132
|
+
* const data = Execute.encodeData([
|
|
133
|
+
* {
|
|
134
|
+
* data: '0xcafebabe',
|
|
135
|
+
* to: '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
|
|
136
|
+
* value: 1n,
|
|
137
|
+
* }
|
|
138
|
+
* ])
|
|
139
|
+
* ```
|
|
140
|
+
*
|
|
141
|
+
* @param calls - The calls to encode.
|
|
142
|
+
* @param options - The options.
|
|
143
|
+
* @returns The encoded data.
|
|
144
|
+
*/
|
|
145
|
+
export function encodeData(calls, options = {}) {
|
|
146
|
+
const { opData } = options;
|
|
147
|
+
const c = Calls.encode(calls, { opData });
|
|
148
|
+
const m = opData ? mode.opData : mode.default;
|
|
149
|
+
return AbiFunction.encodeData(abiFunction, [m, c]);
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=Execute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Execute.js","sourceRoot":"","sources":["../../erc7821/Execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,wBAAwB,CAAA;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AASnC,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,SAAS;IACf,MAAM,EAAE;QACN;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,SAAS;YACf,YAAY,EAAE,SAAS;SACxB;QACD;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,OAAO;YACb,YAAY,EAAE,OAAO;SACtB;KACF;IACD,OAAO,EAAE,EAAE;IACX,eAAe,EAAE,SAAS;CACO,CAAA;AAEnC,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,OAAO,EAAE,oEAAoE;IAC7E,MAAM,EAAE,oEAAoE;IAC5E,cAAc,EACZ,oEAAoE;CAC9D,CAAA;AAEV;;;;;;;;;;;;GAYG;AACH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;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAyB;IAChE,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;QAC5D,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YAChB,MAAM,KAAK,GAAG,CAAU,CAAA;YACxB,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE;gBAC/B,MAAM,EAAE,KAAK,CAAC,MAAM;aACrB,CAAC,CAAA;QACJ,CAAC,CAAC;KACH,CAAC,CAAA;IACF,OAAO,WAAW,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAA;AACtE,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,UAAU,CACxB,KAAsB,EACtB,UAA8B,EAAE;IAEhC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;IAC1B,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;IACzC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAA;IAC7C,OAAO,WAAW,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AACpD,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for encoding and decoding [ERC-7821](https://eips.ethereum.org/EIPS/eip-7821) calls.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ### Encoding calls
|
|
6
|
+
*
|
|
7
|
+
* Calls can be encoded using `Calls.encode`.
|
|
8
|
+
*
|
|
9
|
+
* ```ts twoslash
|
|
10
|
+
* import { Calls } from 'ox/erc7821'
|
|
11
|
+
*
|
|
12
|
+
* const calls = Calls.encode([
|
|
13
|
+
* {
|
|
14
|
+
* data: '0xcafebabe',
|
|
15
|
+
* to: '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
|
|
16
|
+
* value: 1n,
|
|
17
|
+
* }
|
|
18
|
+
* ])
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ### Decoding calls
|
|
23
|
+
*
|
|
24
|
+
* Calls can be decoded using `Calls.decode`.
|
|
25
|
+
*
|
|
26
|
+
* ```ts twoslash
|
|
27
|
+
* import { Calls } from 'ox/erc7821'
|
|
28
|
+
*
|
|
29
|
+
* const { calls } = Calls.decode('0x...')
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @category ERC-7821
|
|
33
|
+
*/
|
|
34
|
+
export * as Calls from './Calls.js';
|
|
35
|
+
/**
|
|
36
|
+
* Utility functions for encoding and decoding [ERC-7821](https://eips.ethereum.org/EIPS/eip-7821) `execute` function data.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ### Encoding `execute` Function Data
|
|
40
|
+
*
|
|
41
|
+
* The `execute` function data can be encoded using `Execute.encodeData`.
|
|
42
|
+
*
|
|
43
|
+
* ```ts twoslash
|
|
44
|
+
* import { Execute } from 'ox/erc7821'
|
|
45
|
+
*
|
|
46
|
+
* const data = Execute.encodeData([
|
|
47
|
+
* {
|
|
48
|
+
* data: '0xcafebabe',
|
|
49
|
+
* to: '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
|
|
50
|
+
* value: 1n,
|
|
51
|
+
* }
|
|
52
|
+
* ])
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ### Decoding `execute` Function Data
|
|
57
|
+
*
|
|
58
|
+
* The `execute` function data can be decoded using `Execute.decodeData`.
|
|
59
|
+
*
|
|
60
|
+
* ```ts twoslash
|
|
61
|
+
* import { Execute } from 'ox/erc7821'
|
|
62
|
+
*
|
|
63
|
+
* const { calls } = Execute.decodeData('0xe9ae5c53...')
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @category ERC-7821
|
|
67
|
+
*/
|
|
68
|
+
export * as Execute from './Execute.js';
|
|
69
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../erc7821/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA"}
|
package/_esm/index.docs.js
CHANGED
package/_esm/index.docs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.docs.js","sourceRoot":"","sources":["../index.docs.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,2FAA2F;AAC3F,gDAAgD;AAChD,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.docs.js","sourceRoot":"","sources":["../index.docs.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,2FAA2F;AAC3F,gDAAgD;AAChD,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA"}
|
package/_esm/version.js
CHANGED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type * as Address from '../core/Address.js';
|
|
2
|
+
import type * as Hex from '../core/Hex.js';
|
|
3
|
+
export type Call<bigintType = bigint> = {
|
|
4
|
+
data?: Hex.Hex | undefined;
|
|
5
|
+
to: Address.Address;
|
|
6
|
+
value?: bigintType | undefined;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Encodes a set of ERC-7821 calls.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts twoslash
|
|
13
|
+
* import { Calls } from 'ox/erc7821'
|
|
14
|
+
*
|
|
15
|
+
* const calls = Calls.encode([
|
|
16
|
+
* {
|
|
17
|
+
* data: '0xdeadbeef',
|
|
18
|
+
* to: '0xcafebabecafebabecafebabecafebabecafebabe',
|
|
19
|
+
* value: 1n,
|
|
20
|
+
* },
|
|
21
|
+
* {
|
|
22
|
+
* data: '0xcafebabe',
|
|
23
|
+
* to: '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
|
|
24
|
+
* value: 2n,
|
|
25
|
+
* },
|
|
26
|
+
* ])
|
|
27
|
+
* // @log: '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000120000000000000000000000000cafebabecafebabecafebabecafebabecafebabe0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000deadbeef000000000000000000000000deadbeefdeadbeefdeadbeefdeadbeefdeadbeef0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cafebabe'
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @param calls - Calls to encode.
|
|
31
|
+
* @param options - Options for the encoding.
|
|
32
|
+
* @returns The encoded calls.
|
|
33
|
+
*/
|
|
34
|
+
export declare function encode(calls: readonly Call[], options?: encode.Options): `0x${string}`;
|
|
35
|
+
export declare namespace encode {
|
|
36
|
+
type Options = {
|
|
37
|
+
/** Additional data to include for execution. */
|
|
38
|
+
opData?: Hex.Hex | undefined;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Gets the ABI parameters for the ERC-7821 calls.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts twoslash
|
|
46
|
+
* import { Calls } from 'ox/erc7821'
|
|
47
|
+
*
|
|
48
|
+
* const abiParameters = Calls.getAbiParameters({ opData: true })
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param options - Options.
|
|
52
|
+
* @returns The ABI parameters.
|
|
53
|
+
*/
|
|
54
|
+
export declare function getAbiParameters(options?: getAbiParameters.Options): readonly [{
|
|
55
|
+
readonly type: "Call[]";
|
|
56
|
+
readonly name: "calls";
|
|
57
|
+
}];
|
|
58
|
+
export declare namespace getAbiParameters {
|
|
59
|
+
type Options = {
|
|
60
|
+
opData?: boolean | undefined;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Decodes a set of ERC-7821 calls from encoded data.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts twoslash
|
|
68
|
+
* import { Calls } from 'ox/erc7821'
|
|
69
|
+
*
|
|
70
|
+
* const data = Calls.decode('0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000cafebabecafebabecafebabecafebabecafebabe000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000004deadbeef00000000000000000000000000000000000000000000000000000000000000000000000000000000deadbeefdeadbeefdeadbeefdeadbeefdeadbeef000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000004cafebabe00000000000000000000000000000000000000000000000000000000')
|
|
71
|
+
* // @log: {
|
|
72
|
+
* // @log: calls: [
|
|
73
|
+
* // @log: {
|
|
74
|
+
* // @log: data: '0xdeadbeef',
|
|
75
|
+
* // @log: to: '0xcafebabecafebabecafebabecafebabecafebabe',
|
|
76
|
+
* // @log: value: 1n,
|
|
77
|
+
* // @log: },
|
|
78
|
+
* // @log: {
|
|
79
|
+
* // @log: data: '0xcafebabe',
|
|
80
|
+
* // @log: to: '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
|
|
81
|
+
* // @log: value: 2n,
|
|
82
|
+
* // @log: },
|
|
83
|
+
* // @log: ]
|
|
84
|
+
* // @log: }
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @param data - The encoded calls data.
|
|
88
|
+
* @param options - Options for decoding.
|
|
89
|
+
* @returns The decoded calls and optional opData.
|
|
90
|
+
*/
|
|
91
|
+
export declare function decode(data: Hex.Hex, options?: decode.Options): decode.ReturnType;
|
|
92
|
+
export declare namespace decode {
|
|
93
|
+
type Options = {
|
|
94
|
+
/** Whether to decode opData if present. */
|
|
95
|
+
opData?: boolean | undefined;
|
|
96
|
+
};
|
|
97
|
+
type ReturnType = {
|
|
98
|
+
calls: Call[];
|
|
99
|
+
opData?: Hex.Hex | undefined;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=Calls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Calls.d.ts","sourceRoot":"","sources":["../../erc7821/Calls.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,KAAK,GAAG,MAAM,gBAAgB,CAAA;AAE1C,MAAM,MAAM,IAAI,CAAC,UAAU,GAAG,MAAM,IAAI;IACtC,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,SAAS,CAAA;IAC1B,EAAE,EAAE,OAAO,CAAC,OAAO,CAAA;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