@hiero-ledger/sdk 2.83.0-beta.1 → 2.83.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd.js +126 -46
- package/dist/umd.js.map +1 -1
- package/dist/umd.min.js +1 -1
- package/dist/umd.min.js.map +1 -1
- package/lib/EthereumTransactionDataEip1559.cjs +25 -8
- package/lib/EthereumTransactionDataEip1559.d.ts +20 -4
- package/lib/EthereumTransactionDataEip1559.js +1 -1
- package/lib/EthereumTransactionDataEip1559.js.map +1 -1
- package/lib/EthereumTransactionDataEip2930.cjs +25 -8
- package/lib/EthereumTransactionDataEip2930.d.ts +20 -4
- package/lib/EthereumTransactionDataEip2930.js +1 -1
- package/lib/EthereumTransactionDataEip2930.js.map +1 -1
- package/lib/EthereumTransactionDataEip7702.cjs +38 -26
- package/lib/EthereumTransactionDataEip7702.d.ts +29 -6
- package/lib/EthereumTransactionDataEip7702.js +1 -1
- package/lib/EthereumTransactionDataEip7702.js.map +1 -1
- package/lib/EthereumTransactionDataLegacy.cjs +2 -3
- package/lib/EthereumTransactionDataLegacy.js.map +1 -1
- package/lib/file/FileAppendTransaction.cjs +7 -0
- package/lib/file/FileAppendTransaction.d.ts +7 -0
- package/lib/file/FileAppendTransaction.js.map +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/src/EthereumTransactionDataEip1559.js +33 -8
- package/src/EthereumTransactionDataEip2930.js +33 -8
- package/src/EthereumTransactionDataEip7702.js +49 -27
- package/src/EthereumTransactionDataLegacy.js +3 -2
- package/src/file/FileAppendTransaction.js +7 -0
|
@@ -10,6 +10,16 @@ var _EthereumTransactionData = _interopRequireDefault(require("./EthereumTransac
|
|
|
10
10
|
var _Cache = _interopRequireDefault(require("./Cache.cjs"));
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {[Uint8Array, Uint8Array[]]} AccessListItem - [address, storageKeys[]]
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {object} AccessListItemJSON
|
|
19
|
+
* @property {string} address
|
|
20
|
+
* @property {string[]} storageKeys
|
|
21
|
+
*/
|
|
22
|
+
|
|
13
23
|
/**
|
|
14
24
|
* @typedef {object} EthereumTransactionDataEip1559JSON
|
|
15
25
|
* @property {string} chainId
|
|
@@ -20,7 +30,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
20
30
|
* @property {string} to
|
|
21
31
|
* @property {string} value
|
|
22
32
|
* @property {string} callData
|
|
23
|
-
* @property {
|
|
33
|
+
* @property {AccessListItemJSON[]} accessList
|
|
24
34
|
* @property {string} recId
|
|
25
35
|
* @property {string} r
|
|
26
36
|
* @property {string} s
|
|
@@ -38,7 +48,7 @@ class EthereumTransactionDataEip1559 extends _EthereumTransactionData.default {
|
|
|
38
48
|
* @param {Uint8Array} props.to
|
|
39
49
|
* @param {Uint8Array} props.value
|
|
40
50
|
* @param {Uint8Array} props.callData
|
|
41
|
-
* @param {
|
|
51
|
+
* @param {AccessListItem[]} props.accessList
|
|
42
52
|
* @param {Uint8Array} props.recId
|
|
43
53
|
* @param {Uint8Array} props.r
|
|
44
54
|
* @param {Uint8Array} props.s
|
|
@@ -66,9 +76,8 @@ class EthereumTransactionDataEip1559 extends _EthereumTransactionData.default {
|
|
|
66
76
|
if (bytes.length === 0) {
|
|
67
77
|
throw new Error("empty bytes");
|
|
68
78
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const decoded = /** @type {string[]} */(0, _ethers.decodeRlp)(bytes.subarray(1));
|
|
79
|
+
const decoded = /** @type {unknown[]} */
|
|
80
|
+
/** @type {unknown} */(0, _ethers.decodeRlp)(bytes.subarray(1));
|
|
72
81
|
if (!Array.isArray(decoded)) {
|
|
73
82
|
throw new Error("ethereum data is not a list");
|
|
74
83
|
}
|
|
@@ -86,8 +95,13 @@ class EthereumTransactionDataEip1559 extends _EthereumTransactionData.default {
|
|
|
86
95
|
to: hex.decode(/** @type {string} */decoded[5]),
|
|
87
96
|
value: hex.decode(/** @type {string} */decoded[6]),
|
|
88
97
|
callData: hex.decode(/** @type {string} */decoded[7]),
|
|
89
|
-
|
|
90
|
-
|
|
98
|
+
accessList: (/** @type {AccessListItem[]} */
|
|
99
|
+
/** @type {Array<[string, string[]]>} */(/** @type {unknown} */decoded[8]).map(item => {
|
|
100
|
+
if (!Array.isArray(item) || item.length !== 2) {
|
|
101
|
+
throw new Error("invalid access list entry: must be [address, storageKeys[]]");
|
|
102
|
+
}
|
|
103
|
+
return [hex.decode(item[0]), item[1].map(key => hex.decode(key))];
|
|
104
|
+
})),
|
|
91
105
|
recId: hex.decode(/** @type {string} */decoded[9]),
|
|
92
106
|
r: hex.decode(/** @type {string} */decoded[10]),
|
|
93
107
|
s: hex.decode(/** @type {string} */decoded[11])
|
|
@@ -122,7 +136,10 @@ class EthereumTransactionDataEip1559 extends _EthereumTransactionData.default {
|
|
|
122
136
|
to: hex.encode(this.to),
|
|
123
137
|
value: hex.encode(this.value),
|
|
124
138
|
callData: hex.encode(this.callData),
|
|
125
|
-
accessList: this.accessList.map(
|
|
139
|
+
accessList: this.accessList.map(([address, storageKeys]) => ({
|
|
140
|
+
address: hex.encode(address),
|
|
141
|
+
storageKeys: storageKeys.map(key => hex.encode(key))
|
|
142
|
+
})),
|
|
126
143
|
recId: hex.encode(this.recId),
|
|
127
144
|
r: hex.encode(this.r),
|
|
128
145
|
s: hex.encode(this.s)
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {[Uint8Array, Uint8Array[]]} AccessListItem - [address, storageKeys[]]
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {object} AccessListItemJSON
|
|
6
|
+
* @property {string} address
|
|
7
|
+
* @property {string[]} storageKeys
|
|
8
|
+
*/
|
|
1
9
|
/**
|
|
2
10
|
* @typedef {object} EthereumTransactionDataEip1559JSON
|
|
3
11
|
* @property {string} chainId
|
|
@@ -8,7 +16,7 @@
|
|
|
8
16
|
* @property {string} to
|
|
9
17
|
* @property {string} value
|
|
10
18
|
* @property {string} callData
|
|
11
|
-
* @property {
|
|
19
|
+
* @property {AccessListItemJSON[]} accessList
|
|
12
20
|
* @property {string} recId
|
|
13
21
|
* @property {string} r
|
|
14
22
|
* @property {string} s
|
|
@@ -25,7 +33,7 @@ export default class EthereumTransactionDataEip1559 extends EthereumTransactionD
|
|
|
25
33
|
* @param {Uint8Array} props.to
|
|
26
34
|
* @param {Uint8Array} props.value
|
|
27
35
|
* @param {Uint8Array} props.callData
|
|
28
|
-
* @param {
|
|
36
|
+
* @param {AccessListItem[]} props.accessList
|
|
29
37
|
* @param {Uint8Array} props.recId
|
|
30
38
|
* @param {Uint8Array} props.r
|
|
31
39
|
* @param {Uint8Array} props.s
|
|
@@ -38,7 +46,7 @@ export default class EthereumTransactionDataEip1559 extends EthereumTransactionD
|
|
|
38
46
|
gasLimit: Uint8Array<ArrayBufferLike>;
|
|
39
47
|
to: Uint8Array<ArrayBufferLike>;
|
|
40
48
|
value: Uint8Array<ArrayBufferLike>;
|
|
41
|
-
accessList:
|
|
49
|
+
accessList: AccessListItem[];
|
|
42
50
|
recId: Uint8Array<ArrayBufferLike>;
|
|
43
51
|
r: Uint8Array<ArrayBufferLike>;
|
|
44
52
|
s: Uint8Array<ArrayBufferLike>;
|
|
@@ -47,6 +55,14 @@ export default class EthereumTransactionDataEip1559 extends EthereumTransactionD
|
|
|
47
55
|
*/
|
|
48
56
|
toJSON(): EthereumTransactionDataEip1559JSON;
|
|
49
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* - [address, storageKeys[]]
|
|
60
|
+
*/
|
|
61
|
+
export type AccessListItem = [Uint8Array, Uint8Array[]];
|
|
62
|
+
export type AccessListItemJSON = {
|
|
63
|
+
address: string;
|
|
64
|
+
storageKeys: string[];
|
|
65
|
+
};
|
|
50
66
|
export type EthereumTransactionDataEip1559JSON = {
|
|
51
67
|
chainId: string;
|
|
52
68
|
nonce: string;
|
|
@@ -56,7 +72,7 @@ export type EthereumTransactionDataEip1559JSON = {
|
|
|
56
72
|
to: string;
|
|
57
73
|
value: string;
|
|
58
74
|
callData: string;
|
|
59
|
-
accessList:
|
|
75
|
+
accessList: AccessListItemJSON[];
|
|
60
76
|
recId: string;
|
|
61
77
|
r: string;
|
|
62
78
|
s: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{decodeRlp as t,encodeRlp as s}from"ethers";import{decode as i,encode as a}from"./encoding/hex.js";import r from"./EthereumTransactionData.js";import e from"./Cache.js";class h extends r{constructor(t){super(t),this.chainId=t.chainId,this.nonce=t.nonce,this.maxPriorityGas=t.maxPriorityGas,this.maxGas=t.maxGas,this.gasLimit=t.gasLimit,this.to=t.to,this.value=t.value,this.accessList=t.accessList,this.recId=t.recId,this.r=t.r,this.s=t.s}static fromBytes(s){if(0===s.length)throw new Error("empty bytes");const a=t(s.subarray(1));if(!Array.isArray(a))throw new Error("ethereum data is not a list");if(12!=a.length)throw new Error("invalid ethereum transaction data");return new h({chainId:i(a[0]),nonce:i(a[1]),maxPriorityGas:i(a[2]),maxGas:i(a[3]),gasLimit:i(a[4]),to:i(a[5]),value:i(a[6]),callData:i(a[7]),accessList:a[8].map(t=>i(t)),recId:i(a[9]),r:i(a[10]),s:i(a[11])})}toBytes(){const t=s([this.chainId,this.nonce,this.maxPriorityGas,this.maxGas,this.gasLimit,this.to,this.value,this.callData,this.accessList,this.recId,this.r,this.s]);return i("02"+t.substring(2))}toString(){return JSON.stringify(this.toJSON(),null,2)}toJSON(){return{chainId:a(this.chainId),nonce:a(this.nonce),maxPriorityGas:a(this.maxPriorityGas),maxGas:a(this.maxGas),gasLimit:a(this.gasLimit),to:a(this.to),value:a(this.value),callData:a(this.callData),accessList:this.accessList.map(t=>a(t)),recId:a(this.recId),r:a(this.r),s:a(this.s)}}}e.setEthereumTransactionDataEip1559FromBytes(t=>h.fromBytes(t));export{h as default};
|
|
1
|
+
import{decodeRlp as t,encodeRlp as s}from"ethers";import{decode as i,encode as a}from"./encoding/hex.js";import r from"./EthereumTransactionData.js";import e from"./Cache.js";class h extends r{constructor(t){super(t),this.chainId=t.chainId,this.nonce=t.nonce,this.maxPriorityGas=t.maxPriorityGas,this.maxGas=t.maxGas,this.gasLimit=t.gasLimit,this.to=t.to,this.value=t.value,this.accessList=t.accessList,this.recId=t.recId,this.r=t.r,this.s=t.s}static fromBytes(s){if(0===s.length)throw new Error("empty bytes");const a=t(s.subarray(1));if(!Array.isArray(a))throw new Error("ethereum data is not a list");if(12!=a.length)throw new Error("invalid ethereum transaction data");return new h({chainId:i(a[0]),nonce:i(a[1]),maxPriorityGas:i(a[2]),maxGas:i(a[3]),gasLimit:i(a[4]),to:i(a[5]),value:i(a[6]),callData:i(a[7]),accessList:a[8].map(t=>{if(!Array.isArray(t)||2!==t.length)throw new Error("invalid access list entry: must be [address, storageKeys[]]");return[i(t[0]),t[1].map(t=>i(t))]}),recId:i(a[9]),r:i(a[10]),s:i(a[11])})}toBytes(){const t=s([this.chainId,this.nonce,this.maxPriorityGas,this.maxGas,this.gasLimit,this.to,this.value,this.callData,this.accessList,this.recId,this.r,this.s]);return i("02"+t.substring(2))}toString(){return JSON.stringify(this.toJSON(),null,2)}toJSON(){return{chainId:a(this.chainId),nonce:a(this.nonce),maxPriorityGas:a(this.maxPriorityGas),maxGas:a(this.maxGas),gasLimit:a(this.gasLimit),to:a(this.to),value:a(this.value),callData:a(this.callData),accessList:this.accessList.map(([t,s])=>({address:a(t),storageKeys:s.map(t=>a(t))})),recId:a(this.recId),r:a(this.r),s:a(this.s)}}}e.setEthereumTransactionDataEip1559FromBytes(t=>h.fromBytes(t));export{h as default};
|
|
2
2
|
//# sourceMappingURL=EthereumTransactionDataEip1559.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumTransactionDataEip1559.js","sources":["../src/EthereumTransactionDataEip1559.js"],"sourcesContent":["import { decodeRlp, encodeRlp } from \"ethers\";\nimport * as hex from \"./encoding/hex.js\";\nimport EthereumTransactionData from \"./EthereumTransactionData.js\";\nimport CACHE from \"./Cache.js\";\n\n/**\n * @typedef {object} EthereumTransactionDataEip1559JSON\n * @property {string} chainId\n * @property {string} nonce\n * @property {string} maxPriorityGas\n * @property {string} maxGas\n * @property {string} gasLimit\n * @property {string} to\n * @property {string} value\n * @property {string} callData\n * @property {
|
|
1
|
+
{"version":3,"file":"EthereumTransactionDataEip1559.js","sources":["../src/EthereumTransactionDataEip1559.js"],"sourcesContent":["import { decodeRlp, encodeRlp } from \"ethers\";\nimport * as hex from \"./encoding/hex.js\";\nimport EthereumTransactionData from \"./EthereumTransactionData.js\";\nimport CACHE from \"./Cache.js\";\n\n/**\n * @typedef {[Uint8Array, Uint8Array[]]} AccessListItem - [address, storageKeys[]]\n */\n\n/**\n * @typedef {object} AccessListItemJSON\n * @property {string} address\n * @property {string[]} storageKeys\n */\n\n/**\n * @typedef {object} EthereumTransactionDataEip1559JSON\n * @property {string} chainId\n * @property {string} nonce\n * @property {string} maxPriorityGas\n * @property {string} maxGas\n * @property {string} gasLimit\n * @property {string} to\n * @property {string} value\n * @property {string} callData\n * @property {AccessListItemJSON[]} accessList\n * @property {string} recId\n * @property {string} r\n * @property {string} s\n */\n\nexport default class EthereumTransactionDataEip1559 extends EthereumTransactionData {\n /**\n * @private\n * @param {object} props\n * @param {Uint8Array} props.chainId\n * @param {Uint8Array} props.nonce\n * @param {Uint8Array} props.maxPriorityGas\n * @param {Uint8Array} props.maxGas\n * @param {Uint8Array} props.gasLimit\n * @param {Uint8Array} props.to\n * @param {Uint8Array} props.value\n * @param {Uint8Array} props.callData\n * @param {AccessListItem[]} props.accessList\n * @param {Uint8Array} props.recId\n * @param {Uint8Array} props.r\n * @param {Uint8Array} props.s\n */\n constructor(props) {\n super(props);\n\n this.chainId = props.chainId;\n this.nonce = props.nonce;\n this.maxPriorityGas = props.maxPriorityGas;\n this.maxGas = props.maxGas;\n this.gasLimit = props.gasLimit;\n this.to = props.to;\n this.value = props.value;\n this.accessList = props.accessList;\n this.recId = props.recId;\n this.r = props.r;\n this.s = props.s;\n }\n\n /**\n * @param {Uint8Array} bytes\n * @returns {EthereumTransactionData}\n */\n static fromBytes(bytes) {\n if (bytes.length === 0) {\n throw new Error(\"empty bytes\");\n }\n\n const decoded = /** @type {unknown[]} */ (\n /** @type {unknown} */ (decodeRlp(bytes.subarray(1)))\n );\n\n if (!Array.isArray(decoded)) {\n throw new Error(\"ethereum data is not a list\");\n }\n\n if (decoded.length != 12) {\n throw new Error(\"invalid ethereum transaction data\");\n }\n\n // TODO\n return new EthereumTransactionDataEip1559({\n chainId: hex.decode(/** @type {string} */ (decoded[0])),\n nonce: hex.decode(/** @type {string} */ (decoded[1])),\n maxPriorityGas: hex.decode(/** @type {string} */ (decoded[2])),\n maxGas: hex.decode(/** @type {string} */ (decoded[3])),\n gasLimit: hex.decode(/** @type {string} */ (decoded[4])),\n to: hex.decode(/** @type {string} */ (decoded[5])),\n value: hex.decode(/** @type {string} */ (decoded[6])),\n callData: hex.decode(/** @type {string} */ (decoded[7])),\n accessList: /** @type {AccessListItem[]} */ (\n /** @type {Array<[string, string[]]>} */ (\n /** @type {unknown} */ (decoded[8])\n ).map((item) => {\n if (!Array.isArray(item) || item.length !== 2) {\n throw new Error(\n \"invalid access list entry: must be [address, storageKeys[]]\",\n );\n }\n return [\n hex.decode(item[0]),\n item[1].map((key) => hex.decode(key)),\n ];\n })\n ),\n recId: hex.decode(/** @type {string} */ (decoded[9])),\n r: hex.decode(/** @type {string} */ (decoded[10])),\n s: hex.decode(/** @type {string} */ (decoded[11])),\n });\n }\n\n /**\n * @returns {Uint8Array}\n */\n toBytes() {\n const encoded = encodeRlp([\n this.chainId,\n this.nonce,\n this.maxPriorityGas,\n this.maxGas,\n this.gasLimit,\n this.to,\n this.value,\n this.callData,\n this.accessList,\n this.recId,\n this.r,\n this.s,\n ]);\n return hex.decode(\"02\" + encoded.substring(2));\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return JSON.stringify(this.toJSON(), null, 2);\n }\n\n /**\n * @returns {EthereumTransactionDataEip1559JSON}\n */\n toJSON() {\n return {\n chainId: hex.encode(this.chainId),\n nonce: hex.encode(this.nonce),\n maxPriorityGas: hex.encode(this.maxPriorityGas),\n maxGas: hex.encode(this.maxGas),\n gasLimit: hex.encode(this.gasLimit),\n to: hex.encode(this.to),\n value: hex.encode(this.value),\n callData: hex.encode(this.callData),\n accessList: this.accessList.map(([address, storageKeys]) => ({\n address: hex.encode(address),\n storageKeys: storageKeys.map((key) => hex.encode(key)),\n })),\n recId: hex.encode(this.recId),\n r: hex.encode(this.r),\n s: hex.encode(this.s),\n };\n }\n}\n\nCACHE.setEthereumTransactionDataEip1559FromBytes((bytes) =>\n EthereumTransactionDataEip1559.fromBytes(bytes),\n);\n"],"names":["EthereumTransactionDataEip1559","EthereumTransactionData","constructor","props","super","this","chainId","nonce","maxPriorityGas","maxGas","gasLimit","to","value","accessList","recId","r","s","fromBytes","bytes","length","Error","decoded","decodeRlp","subarray","Array","isArray","hex.decode","callData","map","item","key","toBytes","encoded","encodeRlp","substring","toString","JSON","stringify","toJSON","hex.encode","address","storageKeys","CACHE","setEthereumTransactionDataEip1559FromBytes"],"mappings":"+KA+Be,MAAMA,UAAuCC,EAiBxD,WAAAC,CAAYC,GACRC,MAAMD,GAENE,KAAKC,QAAUH,EAAMG,QACrBD,KAAKE,MAAQJ,EAAMI,MACnBF,KAAKG,eAAiBL,EAAMK,eAC5BH,KAAKI,OAASN,EAAMM,OACpBJ,KAAKK,SAAWP,EAAMO,SACtBL,KAAKM,GAAKR,EAAMQ,GAChBN,KAAKO,MAAQT,EAAMS,MACnBP,KAAKQ,WAAaV,EAAMU,WACxBR,KAAKS,MAAQX,EAAMW,MACnBT,KAAKU,EAAIZ,EAAMY,EACfV,KAAKW,EAAIb,EAAMa,CACnB,CAMA,gBAAOC,CAAUC,GACb,GAAqB,IAAjBA,EAAMC,OACN,MAAM,IAAIC,MAAM,eAGpB,MAAMC,EACsBC,EAAUJ,EAAMK,SAAS,IAGrD,IAAKC,MAAMC,QAAQJ,GACf,MAAM,IAAID,MAAM,+BAGpB,GAAsB,IAAlBC,EAAQF,OACR,MAAM,IAAIC,MAAM,qCAIpB,OAAO,IAAIpB,EAA+B,CACtCM,QAASoB,EAAkCL,EAAQ,IACnDd,MAAOmB,EAAkCL,EAAQ,IACjDb,eAAgBkB,EAAkCL,EAAQ,IAC1DZ,OAAQiB,EAAkCL,EAAQ,IAClDX,SAAUgB,EAAkCL,EAAQ,IACpDV,GAAIe,EAAkCL,EAAQ,IAC9CT,MAAOc,EAAkCL,EAAQ,IACjDM,SAAUD,EAAkCL,EAAQ,IACpDR,WAEgCQ,EAAQ,GAClCO,IAAKC,IACH,IAAKL,MAAMC,QAAQI,IAAyB,IAAhBA,EAAKV,OAC7B,MAAM,IAAIC,MACN,+DAGR,MAAO,CACHM,EAAWG,EAAK,IAChBA,EAAK,GAAGD,IAAKE,GAAQJ,EAAWI,OAI5ChB,MAAOY,EAAkCL,EAAQ,IACjDN,EAAGW,EAAkCL,EAAQ,KAC7CL,EAAGU,EAAkCL,EAAQ,MAErD,CAKA,OAAAU,GACI,MAAMC,EAAUC,EAAU,CACtB5B,KAAKC,QACLD,KAAKE,MACLF,KAAKG,eACLH,KAAKI,OACLJ,KAAKK,SACLL,KAAKM,GACLN,KAAKO,MACLP,KAAKsB,SACLtB,KAAKQ,WACLR,KAAKS,MACLT,KAAKU,EACLV,KAAKW,IAET,OAAOU,EAAW,KAAOM,EAAQE,UAAU,GAC/C,CAKA,QAAAC,GACI,OAAOC,KAAKC,UAAUhC,KAAKiC,SAAU,KAAM,EAC/C,CAKA,MAAAA,GACI,MAAO,CACHhC,QAASiC,EAAWlC,KAAKC,SACzBC,MAAOgC,EAAWlC,KAAKE,OACvBC,eAAgB+B,EAAWlC,KAAKG,gBAChCC,OAAQ8B,EAAWlC,KAAKI,QACxBC,SAAU6B,EAAWlC,KAAKK,UAC1BC,GAAI4B,EAAWlC,KAAKM,IACpBC,MAAO2B,EAAWlC,KAAKO,OACvBe,SAAUY,EAAWlC,KAAKsB,UAC1Bd,WAAYR,KAAKQ,WAAWe,IAAI,EAAEY,EAASC,MAAY,CACnDD,QAASD,EAAWC,GACpBC,YAAaA,EAAYb,IAAKE,GAAQS,EAAWT,OAErDhB,MAAOyB,EAAWlC,KAAKS,OACvBC,EAAGwB,EAAWlC,KAAKU,GACnBC,EAAGuB,EAAWlC,KAAKW,GAE3B,EAGJ0B,EAAMC,2CAA4CzB,GAC9ClB,EAA+BiB,UAAUC"}
|
|
@@ -10,6 +10,16 @@ var _EthereumTransactionData = _interopRequireDefault(require("./EthereumTransac
|
|
|
10
10
|
var _Cache = _interopRequireDefault(require("./Cache.cjs"));
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {[Uint8Array, Uint8Array[]]} AccessListItem - [address, storageKeys[]]
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {object} AccessListItemJSON
|
|
19
|
+
* @property {string} address
|
|
20
|
+
* @property {string[]} storageKeys
|
|
21
|
+
*/
|
|
22
|
+
|
|
13
23
|
/**
|
|
14
24
|
* @typedef {object} EthereumTransactionDataEip2930JSON
|
|
15
25
|
* @property {string} chainId
|
|
@@ -19,7 +29,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
19
29
|
* @property {string} to
|
|
20
30
|
* @property {string} value
|
|
21
31
|
* @property {string} callData
|
|
22
|
-
* @property {
|
|
32
|
+
* @property {AccessListItemJSON[]} accessList
|
|
23
33
|
* @property {string} recId
|
|
24
34
|
* @property {string} r
|
|
25
35
|
* @property {string} s
|
|
@@ -36,7 +46,7 @@ class EthereumTransactionDataEip2930 extends _EthereumTransactionData.default {
|
|
|
36
46
|
* @param {Uint8Array} props.to
|
|
37
47
|
* @param {Uint8Array} props.value
|
|
38
48
|
* @param {Uint8Array} props.callData
|
|
39
|
-
* @param {
|
|
49
|
+
* @param {AccessListItem[]} props.accessList
|
|
40
50
|
* @param {Uint8Array} props.recId
|
|
41
51
|
* @param {Uint8Array} props.r
|
|
42
52
|
* @param {Uint8Array} props.s
|
|
@@ -63,9 +73,8 @@ class EthereumTransactionDataEip2930 extends _EthereumTransactionData.default {
|
|
|
63
73
|
if (bytes.length === 0) {
|
|
64
74
|
throw new Error("empty bytes");
|
|
65
75
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const decoded = /** @type {string[]} */(0, _ethers.decodeRlp)(bytes.subarray(1));
|
|
76
|
+
const decoded = /** @type {unknown[]} */
|
|
77
|
+
/** @type {unknown} */(0, _ethers.decodeRlp)(bytes.subarray(1));
|
|
69
78
|
if (!Array.isArray(decoded)) {
|
|
70
79
|
throw new Error("ethereum data is not a list");
|
|
71
80
|
}
|
|
@@ -82,8 +91,13 @@ class EthereumTransactionDataEip2930 extends _EthereumTransactionData.default {
|
|
|
82
91
|
to: hex.decode(/** @type {string} */decoded[4]),
|
|
83
92
|
value: hex.decode(/** @type {string} */decoded[5]),
|
|
84
93
|
callData: hex.decode(/** @type {string} */decoded[6]),
|
|
85
|
-
|
|
86
|
-
|
|
94
|
+
accessList: (/** @type {AccessListItem[]} */
|
|
95
|
+
/** @type {Array<[string, string[]]>} */(/** @type {unknown} */decoded[7]).map(item => {
|
|
96
|
+
if (!Array.isArray(item) || item.length !== 2) {
|
|
97
|
+
throw new Error("invalid access list entry: must be [address, storageKeys[]]");
|
|
98
|
+
}
|
|
99
|
+
return [hex.decode(item[0]), item[1].map(key => hex.decode(key))];
|
|
100
|
+
})),
|
|
87
101
|
recId: hex.decode(/** @type {string} */decoded[8]),
|
|
88
102
|
r: hex.decode(/** @type {string} */decoded[9]),
|
|
89
103
|
s: hex.decode(/** @type {string} */decoded[10])
|
|
@@ -117,7 +131,10 @@ class EthereumTransactionDataEip2930 extends _EthereumTransactionData.default {
|
|
|
117
131
|
to: hex.encode(this.to),
|
|
118
132
|
value: hex.encode(this.value),
|
|
119
133
|
callData: hex.encode(this.callData),
|
|
120
|
-
accessList: this.accessList.map(
|
|
134
|
+
accessList: this.accessList.map(([address, storageKeys]) => ({
|
|
135
|
+
address: hex.encode(address),
|
|
136
|
+
storageKeys: storageKeys.map(key => hex.encode(key))
|
|
137
|
+
})),
|
|
121
138
|
recId: hex.encode(this.recId),
|
|
122
139
|
r: hex.encode(this.r),
|
|
123
140
|
s: hex.encode(this.s)
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {[Uint8Array, Uint8Array[]]} AccessListItem - [address, storageKeys[]]
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {object} AccessListItemJSON
|
|
6
|
+
* @property {string} address
|
|
7
|
+
* @property {string[]} storageKeys
|
|
8
|
+
*/
|
|
1
9
|
/**
|
|
2
10
|
* @typedef {object} EthereumTransactionDataEip2930JSON
|
|
3
11
|
* @property {string} chainId
|
|
@@ -7,7 +15,7 @@
|
|
|
7
15
|
* @property {string} to
|
|
8
16
|
* @property {string} value
|
|
9
17
|
* @property {string} callData
|
|
10
|
-
* @property {
|
|
18
|
+
* @property {AccessListItemJSON[]} accessList
|
|
11
19
|
* @property {string} recId
|
|
12
20
|
* @property {string} r
|
|
13
21
|
* @property {string} s
|
|
@@ -23,7 +31,7 @@ export default class EthereumTransactionDataEip2930 extends EthereumTransactionD
|
|
|
23
31
|
* @param {Uint8Array} props.to
|
|
24
32
|
* @param {Uint8Array} props.value
|
|
25
33
|
* @param {Uint8Array} props.callData
|
|
26
|
-
* @param {
|
|
34
|
+
* @param {AccessListItem[]} props.accessList
|
|
27
35
|
* @param {Uint8Array} props.recId
|
|
28
36
|
* @param {Uint8Array} props.r
|
|
29
37
|
* @param {Uint8Array} props.s
|
|
@@ -35,7 +43,7 @@ export default class EthereumTransactionDataEip2930 extends EthereumTransactionD
|
|
|
35
43
|
gasLimit: Uint8Array<ArrayBufferLike>;
|
|
36
44
|
to: Uint8Array<ArrayBufferLike>;
|
|
37
45
|
value: Uint8Array<ArrayBufferLike>;
|
|
38
|
-
accessList:
|
|
46
|
+
accessList: AccessListItem[];
|
|
39
47
|
recId: Uint8Array<ArrayBufferLike>;
|
|
40
48
|
r: Uint8Array<ArrayBufferLike>;
|
|
41
49
|
s: Uint8Array<ArrayBufferLike>;
|
|
@@ -44,6 +52,14 @@ export default class EthereumTransactionDataEip2930 extends EthereumTransactionD
|
|
|
44
52
|
*/
|
|
45
53
|
toJSON(): EthereumTransactionDataEip2930JSON;
|
|
46
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* - [address, storageKeys[]]
|
|
57
|
+
*/
|
|
58
|
+
export type AccessListItem = [Uint8Array, Uint8Array[]];
|
|
59
|
+
export type AccessListItemJSON = {
|
|
60
|
+
address: string;
|
|
61
|
+
storageKeys: string[];
|
|
62
|
+
};
|
|
47
63
|
export type EthereumTransactionDataEip2930JSON = {
|
|
48
64
|
chainId: string;
|
|
49
65
|
nonce: string;
|
|
@@ -52,7 +68,7 @@ export type EthereumTransactionDataEip2930JSON = {
|
|
|
52
68
|
to: string;
|
|
53
69
|
value: string;
|
|
54
70
|
callData: string;
|
|
55
|
-
accessList:
|
|
71
|
+
accessList: AccessListItemJSON[];
|
|
56
72
|
recId: string;
|
|
57
73
|
r: string;
|
|
58
74
|
s: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{decodeRlp as t,encodeRlp as s}from"ethers";import{decode as i,encode as r}from"./encoding/hex.js";import a from"./EthereumTransactionData.js";import e from"./Cache.js";class c extends a{constructor(t){super(t),this.chainId=t.chainId,this.nonce=t.nonce,this.gasPrice=t.gasPrice,this.gasLimit=t.gasLimit,this.to=t.to,this.value=t.value,this.accessList=t.accessList,this.recId=t.recId,this.r=t.r,this.s=t.s}static fromBytes(s){if(0===s.length)throw new Error("empty bytes");const r=t(s.subarray(1));if(!Array.isArray(r))throw new Error("ethereum data is not a list");if(11!==r.length)throw new Error("invalid ethereum transaction data");return new c({chainId:i(r[0]),nonce:i(r[1]),gasPrice:i(r[2]),gasLimit:i(r[3]),to:i(r[4]),value:i(r[5]),callData:i(r[6]),accessList:r[7].map(t=>i(t)),recId:i(r[8]),r:i(r[9]),s:i(r[10])})}toBytes(){const t=s([this.chainId,this.nonce,this.gasPrice,this.gasLimit,this.to,this.value,this.callData,this.accessList,this.recId,this.r,this.s]);return i("01"+t.substring(2))}toString(){return JSON.stringify(this.toJSON(),null,2)}toJSON(){return{chainId:r(this.chainId),nonce:r(this.nonce),gasPrice:r(this.gasPrice),gasLimit:r(this.gasLimit),to:r(this.to),value:r(this.value),callData:r(this.callData),accessList:this.accessList.map(t=>r(t)),recId:r(this.recId),r:r(this.r),s:r(this.s)}}}e.setEthereumTransactionDataEip2930FromBytes(t=>c.fromBytes(t));export{c as default};
|
|
1
|
+
import{decodeRlp as t,encodeRlp as s}from"ethers";import{decode as i,encode as r}from"./encoding/hex.js";import a from"./EthereumTransactionData.js";import e from"./Cache.js";class c extends a{constructor(t){super(t),this.chainId=t.chainId,this.nonce=t.nonce,this.gasPrice=t.gasPrice,this.gasLimit=t.gasLimit,this.to=t.to,this.value=t.value,this.accessList=t.accessList,this.recId=t.recId,this.r=t.r,this.s=t.s}static fromBytes(s){if(0===s.length)throw new Error("empty bytes");const r=t(s.subarray(1));if(!Array.isArray(r))throw new Error("ethereum data is not a list");if(11!==r.length)throw new Error("invalid ethereum transaction data");return new c({chainId:i(r[0]),nonce:i(r[1]),gasPrice:i(r[2]),gasLimit:i(r[3]),to:i(r[4]),value:i(r[5]),callData:i(r[6]),accessList:r[7].map(t=>{if(!Array.isArray(t)||2!==t.length)throw new Error("invalid access list entry: must be [address, storageKeys[]]");return[i(t[0]),t[1].map(t=>i(t))]}),recId:i(r[8]),r:i(r[9]),s:i(r[10])})}toBytes(){const t=s([this.chainId,this.nonce,this.gasPrice,this.gasLimit,this.to,this.value,this.callData,this.accessList,this.recId,this.r,this.s]);return i("01"+t.substring(2))}toString(){return JSON.stringify(this.toJSON(),null,2)}toJSON(){return{chainId:r(this.chainId),nonce:r(this.nonce),gasPrice:r(this.gasPrice),gasLimit:r(this.gasLimit),to:r(this.to),value:r(this.value),callData:r(this.callData),accessList:this.accessList.map(([t,s])=>({address:r(t),storageKeys:s.map(t=>r(t))})),recId:r(this.recId),r:r(this.r),s:r(this.s)}}}e.setEthereumTransactionDataEip2930FromBytes(t=>c.fromBytes(t));export{c as default};
|
|
2
2
|
//# sourceMappingURL=EthereumTransactionDataEip2930.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumTransactionDataEip2930.js","sources":["../src/EthereumTransactionDataEip2930.js"],"sourcesContent":["import { decodeRlp, encodeRlp } from \"ethers\";\nimport * as hex from \"./encoding/hex.js\";\nimport EthereumTransactionData from \"./EthereumTransactionData.js\";\nimport CACHE from \"./Cache.js\";\n\n/**\n * @typedef {object} EthereumTransactionDataEip2930JSON\n * @property {string} chainId\n * @property {string} nonce\n * @property {string} gasPrice\n * @property {string} gasLimit\n * @property {string} to\n * @property {string} value\n * @property {string} callData\n * @property {
|
|
1
|
+
{"version":3,"file":"EthereumTransactionDataEip2930.js","sources":["../src/EthereumTransactionDataEip2930.js"],"sourcesContent":["import { decodeRlp, encodeRlp } from \"ethers\";\nimport * as hex from \"./encoding/hex.js\";\nimport EthereumTransactionData from \"./EthereumTransactionData.js\";\nimport CACHE from \"./Cache.js\";\n\n/**\n * @typedef {[Uint8Array, Uint8Array[]]} AccessListItem - [address, storageKeys[]]\n */\n\n/**\n * @typedef {object} AccessListItemJSON\n * @property {string} address\n * @property {string[]} storageKeys\n */\n\n/**\n * @typedef {object} EthereumTransactionDataEip2930JSON\n * @property {string} chainId\n * @property {string} nonce\n * @property {string} gasPrice\n * @property {string} gasLimit\n * @property {string} to\n * @property {string} value\n * @property {string} callData\n * @property {AccessListItemJSON[]} accessList\n * @property {string} recId\n * @property {string} r\n * @property {string} s\n */\n\nexport default class EthereumTransactionDataEip2930 extends EthereumTransactionData {\n /**\n * @private\n * @param {object} props\n * @param {Uint8Array} props.chainId\n * @param {Uint8Array} props.nonce\n * @param {Uint8Array} props.gasPrice\n * @param {Uint8Array} props.gasLimit\n * @param {Uint8Array} props.to\n * @param {Uint8Array} props.value\n * @param {Uint8Array} props.callData\n * @param {AccessListItem[]} props.accessList\n * @param {Uint8Array} props.recId\n * @param {Uint8Array} props.r\n * @param {Uint8Array} props.s\n */\n constructor(props) {\n super(props);\n\n this.chainId = props.chainId;\n this.nonce = props.nonce;\n this.gasPrice = props.gasPrice;\n this.gasLimit = props.gasLimit;\n this.to = props.to;\n this.value = props.value;\n this.accessList = props.accessList;\n this.recId = props.recId;\n this.r = props.r;\n this.s = props.s;\n }\n\n /**\n * @param {Uint8Array} bytes\n * @returns {EthereumTransactionData}\n */\n static fromBytes(bytes) {\n if (bytes.length === 0) {\n throw new Error(\"empty bytes\");\n }\n\n const decoded = /** @type {unknown[]} */ (\n /** @type {unknown} */ (decodeRlp(bytes.subarray(1)))\n );\n\n if (!Array.isArray(decoded)) {\n throw new Error(\"ethereum data is not a list\");\n }\n\n if (decoded.length !== 11) {\n throw new Error(\"invalid ethereum transaction data\");\n }\n\n // TODO\n return new EthereumTransactionDataEip2930({\n chainId: hex.decode(/** @type {string} */ (decoded[0])),\n nonce: hex.decode(/** @type {string} */ (decoded[1])),\n gasPrice: hex.decode(/** @type {string} */ (decoded[2])),\n gasLimit: hex.decode(/** @type {string} */ (decoded[3])),\n to: hex.decode(/** @type {string} */ (decoded[4])),\n value: hex.decode(/** @type {string} */ (decoded[5])),\n callData: hex.decode(/** @type {string} */ (decoded[6])),\n accessList: /** @type {AccessListItem[]} */ (\n /** @type {Array<[string, string[]]>} */ (\n /** @type {unknown} */ (decoded[7])\n ).map((item) => {\n if (!Array.isArray(item) || item.length !== 2) {\n throw new Error(\n \"invalid access list entry: must be [address, storageKeys[]]\",\n );\n }\n return [\n hex.decode(item[0]),\n item[1].map((key) => hex.decode(key)),\n ];\n })\n ),\n recId: hex.decode(/** @type {string} */ (decoded[8])),\n r: hex.decode(/** @type {string} */ (decoded[9])),\n s: hex.decode(/** @type {string} */ (decoded[10])),\n });\n }\n\n /**\n * @returns {Uint8Array}\n */\n toBytes() {\n const encoded = encodeRlp([\n this.chainId,\n this.nonce,\n this.gasPrice,\n this.gasLimit,\n this.to,\n this.value,\n this.callData,\n this.accessList,\n this.recId,\n this.r,\n this.s,\n ]);\n return hex.decode(\"01\" + encoded.substring(2));\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return JSON.stringify(this.toJSON(), null, 2);\n }\n\n /**\n * @returns {EthereumTransactionDataEip2930JSON}\n */\n toJSON() {\n return {\n chainId: hex.encode(this.chainId),\n nonce: hex.encode(this.nonce),\n gasPrice: hex.encode(this.gasPrice),\n gasLimit: hex.encode(this.gasLimit),\n to: hex.encode(this.to),\n value: hex.encode(this.value),\n callData: hex.encode(this.callData),\n accessList: this.accessList.map(([address, storageKeys]) => ({\n address: hex.encode(address),\n storageKeys: storageKeys.map((key) => hex.encode(key)),\n })),\n recId: hex.encode(this.recId),\n r: hex.encode(this.r),\n s: hex.encode(this.s),\n };\n }\n}\n\nCACHE.setEthereumTransactionDataEip2930FromBytes((bytes) =>\n EthereumTransactionDataEip2930.fromBytes(bytes),\n);\n"],"names":["EthereumTransactionDataEip2930","EthereumTransactionData","constructor","props","super","this","chainId","nonce","gasPrice","gasLimit","to","value","accessList","recId","r","s","fromBytes","bytes","length","Error","decoded","decodeRlp","subarray","Array","isArray","hex.decode","callData","map","item","key","toBytes","encoded","encodeRlp","substring","toString","JSON","stringify","toJSON","hex.encode","address","storageKeys","CACHE","setEthereumTransactionDataEip2930FromBytes"],"mappings":"+KA8Be,MAAMA,UAAuCC,EAgBxD,WAAAC,CAAYC,GACRC,MAAMD,GAENE,KAAKC,QAAUH,EAAMG,QACrBD,KAAKE,MAAQJ,EAAMI,MACnBF,KAAKG,SAAWL,EAAMK,SACtBH,KAAKI,SAAWN,EAAMM,SACtBJ,KAAKK,GAAKP,EAAMO,GAChBL,KAAKM,MAAQR,EAAMQ,MACnBN,KAAKO,WAAaT,EAAMS,WACxBP,KAAKQ,MAAQV,EAAMU,MACnBR,KAAKS,EAAIX,EAAMW,EACfT,KAAKU,EAAIZ,EAAMY,CACnB,CAMA,gBAAOC,CAAUC,GACb,GAAqB,IAAjBA,EAAMC,OACN,MAAM,IAAIC,MAAM,eAGpB,MAAMC,EACsBC,EAAUJ,EAAMK,SAAS,IAGrD,IAAKC,MAAMC,QAAQJ,GACf,MAAM,IAAID,MAAM,+BAGpB,GAAuB,KAAnBC,EAAQF,OACR,MAAM,IAAIC,MAAM,qCAIpB,OAAO,IAAInB,EAA+B,CACtCM,QAASmB,EAAkCL,EAAQ,IACnDb,MAAOkB,EAAkCL,EAAQ,IACjDZ,SAAUiB,EAAkCL,EAAQ,IACpDX,SAAUgB,EAAkCL,EAAQ,IACpDV,GAAIe,EAAkCL,EAAQ,IAC9CT,MAAOc,EAAkCL,EAAQ,IACjDM,SAAUD,EAAkCL,EAAQ,IACpDR,WAEgCQ,EAAQ,GAClCO,IAAKC,IACH,IAAKL,MAAMC,QAAQI,IAAyB,IAAhBA,EAAKV,OAC7B,MAAM,IAAIC,MACN,+DAGR,MAAO,CACHM,EAAWG,EAAK,IAChBA,EAAK,GAAGD,IAAKE,GAAQJ,EAAWI,OAI5ChB,MAAOY,EAAkCL,EAAQ,IACjDN,EAAGW,EAAkCL,EAAQ,IAC7CL,EAAGU,EAAkCL,EAAQ,MAErD,CAKA,OAAAU,GACI,MAAMC,EAAUC,EAAU,CACtB3B,KAAKC,QACLD,KAAKE,MACLF,KAAKG,SACLH,KAAKI,SACLJ,KAAKK,GACLL,KAAKM,MACLN,KAAKqB,SACLrB,KAAKO,WACLP,KAAKQ,MACLR,KAAKS,EACLT,KAAKU,IAET,OAAOU,EAAW,KAAOM,EAAQE,UAAU,GAC/C,CAKA,QAAAC,GACI,OAAOC,KAAKC,UAAU/B,KAAKgC,SAAU,KAAM,EAC/C,CAKA,MAAAA,GACI,MAAO,CACH/B,QAASgC,EAAWjC,KAAKC,SACzBC,MAAO+B,EAAWjC,KAAKE,OACvBC,SAAU8B,EAAWjC,KAAKG,UAC1BC,SAAU6B,EAAWjC,KAAKI,UAC1BC,GAAI4B,EAAWjC,KAAKK,IACpBC,MAAO2B,EAAWjC,KAAKM,OACvBe,SAAUY,EAAWjC,KAAKqB,UAC1Bd,WAAYP,KAAKO,WAAWe,IAAI,EAAEY,EAASC,MAAY,CACnDD,QAASD,EAAWC,GACpBC,YAAaA,EAAYb,IAAKE,GAAQS,EAAWT,OAErDhB,MAAOyB,EAAWjC,KAAKQ,OACvBC,EAAGwB,EAAWjC,KAAKS,GACnBC,EAAGuB,EAAWjC,KAAKU,GAE3B,EAGJ0B,EAAMC,2CAA4CzB,GAC9CjB,EAA+BgB,UAAUC"}
|
|
@@ -10,6 +10,20 @@ var _EthereumTransactionData = _interopRequireDefault(require("./EthereumTransac
|
|
|
10
10
|
var _Cache = _interopRequireDefault(require("./Cache.cjs"));
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {[Uint8Array, Uint8Array[]]} AccessListItem - [address, storageKeys[]]
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {[Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array]} AuthorizationItem - [chainId, contractAddress, nonce, yParity, r, s]
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {object} AccessListItemJSON
|
|
23
|
+
* @property {string} address
|
|
24
|
+
* @property {string[]} storageKeys
|
|
25
|
+
*/
|
|
26
|
+
|
|
13
27
|
/**
|
|
14
28
|
* @typedef {object} EthereumTransactionDataEip7702JSON
|
|
15
29
|
* @property {string} chainId
|
|
@@ -21,7 +35,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
21
35
|
* @property {string} value
|
|
22
36
|
* @property {string} callData
|
|
23
37
|
* @property {Array<[string, string, string, string, string, string]>} authorizationList - Array of [chainId, contractAddress, nonce, yParity, r, s] tuples
|
|
24
|
-
* @property {
|
|
38
|
+
* @property {AccessListItemJSON[]} accessList
|
|
25
39
|
* @property {string} recId
|
|
26
40
|
* @property {string} r
|
|
27
41
|
* @property {string} s
|
|
@@ -39,8 +53,8 @@ class EthereumTransactionDataEip7702 extends _EthereumTransactionData.default {
|
|
|
39
53
|
* @param {Uint8Array} props.to
|
|
40
54
|
* @param {Uint8Array} props.value
|
|
41
55
|
* @param {Uint8Array} props.callData
|
|
42
|
-
* @param {
|
|
43
|
-
* @param {
|
|
56
|
+
* @param {AuthorizationItem[]} props.authorizationList - Array of [chainId, contractAddress, nonce, yParity, r, s] tuples
|
|
57
|
+
* @param {AccessListItem[]} props.accessList
|
|
44
58
|
* @param {Uint8Array} props.recId
|
|
45
59
|
* @param {Uint8Array} props.r
|
|
46
60
|
* @param {Uint8Array} props.s
|
|
@@ -70,9 +84,8 @@ class EthereumTransactionDataEip7702 extends _EthereumTransactionData.default {
|
|
|
70
84
|
if (bytes.length === 0) {
|
|
71
85
|
throw new Error("empty bytes");
|
|
72
86
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const decoded = /** @type {string[]} */(0, _ethers.decodeRlp)(bytes.subarray(1));
|
|
87
|
+
const decoded = /** @type {unknown[]} */
|
|
88
|
+
/** @type {unknown} */(0, _ethers.decodeRlp)(bytes.subarray(1));
|
|
76
89
|
if (!Array.isArray(decoded)) {
|
|
77
90
|
throw new Error("ethereum data is not a list");
|
|
78
91
|
}
|
|
@@ -85,30 +98,22 @@ class EthereumTransactionDataEip7702 extends _EthereumTransactionData.default {
|
|
|
85
98
|
if (!Array.isArray(decoded[9])) {
|
|
86
99
|
throw new Error("authorization list must be an array");
|
|
87
100
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const authorizationList = /** @type {string[]} */decoded[9].map(authTuple => {
|
|
101
|
+
const authorizationList = /** @type {AuthorizationItem[]} */
|
|
102
|
+
/** @type {Array<[string, string, string, string, string, string]>} */(/** @type {unknown} */decoded[9]).map(authTuple => {
|
|
91
103
|
if (!Array.isArray(authTuple) || authTuple.length !== 6) {
|
|
92
104
|
throw new Error("invalid authorization list entry: must be [chainId, contractAddress, nonce, yParity, r, s]");
|
|
93
105
|
}
|
|
94
|
-
return [
|
|
95
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
96
|
-
hex.decode(/** @type {string} */authTuple[0]),
|
|
106
|
+
return [hex.decode(authTuple[0]),
|
|
97
107
|
// chainId
|
|
98
|
-
|
|
99
|
-
hex.decode(/** @type {string} */authTuple[1]),
|
|
108
|
+
hex.decode(authTuple[1]),
|
|
100
109
|
// contractAddress (20 bytes)
|
|
101
|
-
|
|
102
|
-
hex.decode(/** @type {string} */authTuple[2]),
|
|
110
|
+
hex.decode(authTuple[2]),
|
|
103
111
|
// nonce
|
|
104
|
-
|
|
105
|
-
hex.decode(/** @type {string} */authTuple[3]),
|
|
112
|
+
hex.decode(authTuple[3]),
|
|
106
113
|
// yParity (0 or 1)
|
|
107
|
-
|
|
108
|
-
hex.decode(/** @type {string} */authTuple[4]),
|
|
114
|
+
hex.decode(authTuple[4]),
|
|
109
115
|
// r (32 bytes)
|
|
110
|
-
//
|
|
111
|
-
hex.decode(/** @type {string} */authTuple[5]) // s (32 bytes)
|
|
116
|
+
hex.decode(authTuple[5]) // s (32 bytes)
|
|
112
117
|
];
|
|
113
118
|
});
|
|
114
119
|
return new EthereumTransactionDataEip7702({
|
|
@@ -120,9 +125,13 @@ class EthereumTransactionDataEip7702 extends _EthereumTransactionData.default {
|
|
|
120
125
|
to: hex.decode(/** @type {string} */decoded[5]),
|
|
121
126
|
value: hex.decode(/** @type {string} */decoded[6]),
|
|
122
127
|
callData: hex.decode(/** @type {string} */decoded[7]),
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
128
|
+
accessList: (/** @type {AccessListItem[]} */
|
|
129
|
+
/** @type {Array<[string, string[]]>} */(/** @type {unknown} */decoded[8]).map(item => {
|
|
130
|
+
if (!Array.isArray(item) || item.length !== 2) {
|
|
131
|
+
throw new Error("invalid access list entry: must be [address, storageKeys[]]");
|
|
132
|
+
}
|
|
133
|
+
return [hex.decode(item[0]), item[1].map(key => hex.decode(key))];
|
|
134
|
+
})),
|
|
126
135
|
authorizationList: authorizationList,
|
|
127
136
|
recId: hex.decode(/** @type {string} */decoded[10]),
|
|
128
137
|
r: hex.decode(/** @type {string} */decoded[11]),
|
|
@@ -159,7 +168,10 @@ class EthereumTransactionDataEip7702 extends _EthereumTransactionData.default {
|
|
|
159
168
|
value: hex.encode(this.value),
|
|
160
169
|
callData: hex.encode(this.callData),
|
|
161
170
|
authorizationList: this.authorizationList.map(([chainId, contractAddress, nonce, yParity, r, s]) => [hex.encode(chainId), hex.encode(contractAddress), hex.encode(nonce), hex.encode(yParity), hex.encode(r), hex.encode(s)]),
|
|
162
|
-
accessList: this.accessList.map(
|
|
171
|
+
accessList: this.accessList.map(([address, storageKeys]) => ({
|
|
172
|
+
address: hex.encode(address),
|
|
173
|
+
storageKeys: storageKeys.map(key => hex.encode(key))
|
|
174
|
+
})),
|
|
163
175
|
recId: hex.encode(this.recId),
|
|
164
176
|
r: hex.encode(this.r),
|
|
165
177
|
s: hex.encode(this.s)
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {[Uint8Array, Uint8Array[]]} AccessListItem - [address, storageKeys[]]
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {[Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array]} AuthorizationItem - [chainId, contractAddress, nonce, yParity, r, s]
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {object} AccessListItemJSON
|
|
9
|
+
* @property {string} address
|
|
10
|
+
* @property {string[]} storageKeys
|
|
11
|
+
*/
|
|
1
12
|
/**
|
|
2
13
|
* @typedef {object} EthereumTransactionDataEip7702JSON
|
|
3
14
|
* @property {string} chainId
|
|
@@ -9,7 +20,7 @@
|
|
|
9
20
|
* @property {string} value
|
|
10
21
|
* @property {string} callData
|
|
11
22
|
* @property {Array<[string, string, string, string, string, string]>} authorizationList - Array of [chainId, contractAddress, nonce, yParity, r, s] tuples
|
|
12
|
-
* @property {
|
|
23
|
+
* @property {AccessListItemJSON[]} accessList
|
|
13
24
|
* @property {string} recId
|
|
14
25
|
* @property {string} r
|
|
15
26
|
* @property {string} s
|
|
@@ -26,8 +37,8 @@ export default class EthereumTransactionDataEip7702 extends EthereumTransactionD
|
|
|
26
37
|
* @param {Uint8Array} props.to
|
|
27
38
|
* @param {Uint8Array} props.value
|
|
28
39
|
* @param {Uint8Array} props.callData
|
|
29
|
-
* @param {
|
|
30
|
-
* @param {
|
|
40
|
+
* @param {AuthorizationItem[]} props.authorizationList - Array of [chainId, contractAddress, nonce, yParity, r, s] tuples
|
|
41
|
+
* @param {AccessListItem[]} props.accessList
|
|
31
42
|
* @param {Uint8Array} props.recId
|
|
32
43
|
* @param {Uint8Array} props.r
|
|
33
44
|
* @param {Uint8Array} props.s
|
|
@@ -40,8 +51,8 @@ export default class EthereumTransactionDataEip7702 extends EthereumTransactionD
|
|
|
40
51
|
gasLimit: Uint8Array<ArrayBufferLike>;
|
|
41
52
|
to: Uint8Array<ArrayBufferLike>;
|
|
42
53
|
value: Uint8Array<ArrayBufferLike>;
|
|
43
|
-
authorizationList: [
|
|
44
|
-
accessList:
|
|
54
|
+
authorizationList: AuthorizationItem[];
|
|
55
|
+
accessList: AccessListItem[];
|
|
45
56
|
recId: Uint8Array<ArrayBufferLike>;
|
|
46
57
|
r: Uint8Array<ArrayBufferLike>;
|
|
47
58
|
s: Uint8Array<ArrayBufferLike>;
|
|
@@ -50,6 +61,18 @@ export default class EthereumTransactionDataEip7702 extends EthereumTransactionD
|
|
|
50
61
|
*/
|
|
51
62
|
toJSON(): EthereumTransactionDataEip7702JSON;
|
|
52
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* - [address, storageKeys[]]
|
|
66
|
+
*/
|
|
67
|
+
export type AccessListItem = [Uint8Array, Uint8Array[]];
|
|
68
|
+
/**
|
|
69
|
+
* - [chainId, contractAddress, nonce, yParity, r, s]
|
|
70
|
+
*/
|
|
71
|
+
export type AuthorizationItem = [Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array];
|
|
72
|
+
export type AccessListItemJSON = {
|
|
73
|
+
address: string;
|
|
74
|
+
storageKeys: string[];
|
|
75
|
+
};
|
|
53
76
|
export type EthereumTransactionDataEip7702JSON = {
|
|
54
77
|
chainId: string;
|
|
55
78
|
nonce: string;
|
|
@@ -63,7 +86,7 @@ export type EthereumTransactionDataEip7702JSON = {
|
|
|
63
86
|
* - Array of [chainId, contractAddress, nonce, yParity, r, s] tuples
|
|
64
87
|
*/
|
|
65
88
|
authorizationList: Array<[string, string, string, string, string, string]>;
|
|
66
|
-
accessList:
|
|
89
|
+
accessList: AccessListItemJSON[];
|
|
67
90
|
recId: string;
|
|
68
91
|
r: string;
|
|
69
92
|
s: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{decodeRlp as t,encodeRlp as
|
|
1
|
+
import{decodeRlp as t,encodeRlp as s}from"ethers";import{decode as i,encode as a}from"./encoding/hex.js";import r from"./EthereumTransactionData.js";import e from"./Cache.js";class o extends r{constructor(t){super(t),this.chainId=t.chainId,this.nonce=t.nonce,this.maxPriorityGas=t.maxPriorityGas,this.maxGas=t.maxGas,this.gasLimit=t.gasLimit,this.to=t.to,this.value=t.value,this.callData=t.callData,this.authorizationList=t.authorizationList,this.accessList=t.accessList,this.recId=t.recId,this.r=t.r,this.s=t.s}static fromBytes(s){if(0===s.length)throw new Error("empty bytes");const a=t(s.subarray(1));if(!Array.isArray(a))throw new Error("ethereum data is not a list");if(13!==a.length)throw new Error("invalid ethereum transaction data");if(!Array.isArray(a[9]))throw new Error("authorization list must be an array");const r=a[9].map(t=>{if(!Array.isArray(t)||6!==t.length)throw new Error("invalid authorization list entry: must be [chainId, contractAddress, nonce, yParity, r, s]");return[i(t[0]),i(t[1]),i(t[2]),i(t[3]),i(t[4]),i(t[5])]});return new o({chainId:i(a[0]),nonce:i(a[1]),maxPriorityGas:i(a[2]),maxGas:i(a[3]),gasLimit:i(a[4]),to:i(a[5]),value:i(a[6]),callData:i(a[7]),accessList:a[8].map(t=>{if(!Array.isArray(t)||2!==t.length)throw new Error("invalid access list entry: must be [address, storageKeys[]]");return[i(t[0]),t[1].map(t=>i(t))]}),authorizationList:r,recId:i(a[10]),r:i(a[11]),s:i(a[12])})}toBytes(){const t=s([this.chainId,this.nonce,this.maxPriorityGas,this.maxGas,this.gasLimit,this.to,this.value,this.callData,this.accessList,this.authorizationList,this.recId,this.r,this.s]);return i("04"+t.substring(2))}toString(){return JSON.stringify(this.toJSON(),null,2)}toJSON(){return{chainId:a(this.chainId),nonce:a(this.nonce),maxPriorityGas:a(this.maxPriorityGas),maxGas:a(this.maxGas),gasLimit:a(this.gasLimit),to:a(this.to),value:a(this.value),callData:a(this.callData),authorizationList:this.authorizationList.map(([t,s,i,r,e,o])=>[a(t),a(s),a(i),a(r),a(e),a(o)]),accessList:this.accessList.map(([t,s])=>({address:a(t),storageKeys:s.map(t=>a(t))})),recId:a(this.recId),r:a(this.r),s:a(this.s)}}}e.setEthereumTransactionDataEip7702FromBytes(t=>o.fromBytes(t));export{o as default};
|
|
2
2
|
//# sourceMappingURL=EthereumTransactionDataEip7702.js.map
|