viem 0.0.0-main.20231105T204204 → 0.0.0-main.20231105T204445
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/_cjs/chains/celo/formatters.js +3 -18
- package/_cjs/chains/celo/formatters.js.map +1 -1
- package/_cjs/chains/celo/serializers.js +19 -37
- package/_cjs/chains/celo/serializers.js.map +1 -1
- package/_cjs/chains/celo/utils.js +46 -0
- package/_cjs/chains/celo/utils.js.map +1 -0
- package/_cjs/errors/version.js +1 -1
- package/_esm/chains/celo/formatters.js +3 -18
- package/_esm/chains/celo/formatters.js.map +1 -1
- package/_esm/chains/celo/serializers.js +18 -43
- package/_esm/chains/celo/serializers.js.map +1 -1
- package/_esm/chains/celo/utils.js +41 -0
- package/_esm/chains/celo/utils.js.map +1 -0
- package/_esm/errors/version.js +1 -1
- package/_types/chains/celo/formatters.d.ts.map +1 -1
- package/_types/chains/celo/serializers.d.ts +3 -2
- package/_types/chains/celo/serializers.d.ts.map +1 -1
- package/_types/chains/celo/types.d.ts +10 -5
- package/_types/chains/celo/types.d.ts.map +1 -1
- package/_types/chains/celo/utils.d.ts +7 -0
- package/_types/chains/celo/utils.d.ts.map +1 -0
- package/_types/errors/version.d.ts +1 -1
- package/chains/celo/formatters.ts +3 -18
- package/chains/celo/serializers.ts +22 -58
- package/chains/celo/types.ts +11 -5
- package/chains/celo/utils.ts +72 -0
- package/errors/version.ts +1 -1
- package/package.json +1 -1
@@ -7,22 +7,7 @@ const block_js_1 = require("../../utils/formatters/block.js");
|
|
7
7
|
const transaction_js_1 = require("../../utils/formatters/transaction.js");
|
8
8
|
const transactionReceipt_js_1 = require("../../utils/formatters/transactionReceipt.js");
|
9
9
|
const transactionRequest_js_1 = require("../../utils/formatters/transactionRequest.js");
|
10
|
-
|
11
|
-
if (args.type === 'cip64')
|
12
|
-
return true;
|
13
|
-
if (args.type)
|
14
|
-
return false;
|
15
|
-
return ('feeCurrency' in args &&
|
16
|
-
args.gatewayFee === undefined &&
|
17
|
-
args.gatewayFeeRecipient === undefined);
|
18
|
-
}
|
19
|
-
function isTransactionRequestCIP42(args) {
|
20
|
-
if (args.type === 'cip42')
|
21
|
-
return true;
|
22
|
-
if (args.type)
|
23
|
-
return false;
|
24
|
-
return args.gatewayFee !== undefined || args.gatewayFeeRecipient !== undefined;
|
25
|
-
}
|
10
|
+
const utils_js_1 = require("./utils.js");
|
26
11
|
exports.formattersCelo = {
|
27
12
|
block: (0, block_js_1.defineBlock)({
|
28
13
|
exclude: ['difficulty', 'gasLimit', 'mixHash', 'nonce', 'uncles'],
|
@@ -73,7 +58,7 @@ exports.formattersCelo = {
|
|
73
58
|
}),
|
74
59
|
transactionRequest: (0, transactionRequest_js_1.defineTransactionRequest)({
|
75
60
|
format(args) {
|
76
|
-
if (
|
61
|
+
if ((0, utils_js_1.isCIP64)(args))
|
77
62
|
return {
|
78
63
|
type: '0x7b',
|
79
64
|
feeCurrency: args.feeCurrency,
|
@@ -85,7 +70,7 @@ exports.formattersCelo = {
|
|
85
70
|
: undefined,
|
86
71
|
gatewayFeeRecipient: args.gatewayFeeRecipient,
|
87
72
|
};
|
88
|
-
if (
|
73
|
+
if ((0, utils_js_1.isCIP42)(args))
|
89
74
|
request.type = '0x7c';
|
90
75
|
return request;
|
91
76
|
},
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../../chains/celo/formatters.ts"],"names":[],"mappings":";;;AAGA,gEAA6D;AAC7D,4DAA2D;AAC3D,8DAA6D;AAC7D,0EAG8C;AAC9C,wFAAuF;AACvF,wFAAuF;
|
1
|
+
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../../chains/celo/formatters.ts"],"names":[],"mappings":";;;AAGA,gEAA6D;AAC7D,4DAA2D;AAC3D,8DAA6D;AAC7D,0EAG8C;AAC9C,wFAAuF;AACvF,wFAAuF;AAUvF,yCAA6C;AAEhC,QAAA,cAAc,GAAG;IAC5B,KAAK,E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AAgB,IAAA,gDAAwB,EAAC;QACzD,MAAM,CACJ,IAAwC;YAExC,OAAO;gBACL,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,wBAAW,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI;gBACjE,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;aAC9C,CAAA;QACH,CAAC;KACF,CAAC;IAEF,kBAAkB,EAAgB,IAAA,gDAAwB,EAAC;QACzD,MAAM,CAAC,IAA4B;YACjC,IAAI,IAAA,kBAAO,EAAC,IAAI,CAAC;gBACf,OAAO;oBACL,IAAI,EAAE,MAAM;oBACZ,WAAW,EAAE,IAAI,CAAC,WAAW;iBACD,CAAA;YAEhC,MAAM,OAAO,GAAG;gBACd,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,UAAU,EACR,OAAO,IAAI,CAAC,UAAU,KAAK,WAAW;oBACpC,CAAC,CAAC,IAAA,sBAAW,EAAC,IAAI,CAAC,UAAU,CAAC;oBAC9B,CAAC,CAAC,SAAS;gBACf,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;aACjB,CAAA;YAE9B,IAAI,IAAA,kBAAO,EAAC,IAAI,CAAC;gBAAE,OAAO,CAAC,IAAI,GAAG,MAAM,CAAA;YAExC,OAAO,OAAO,CAAA;QAChB,CAAC;KACF,CAAC;CACgC,CAAA"}
|
@@ -12,11 +12,12 @@ const toHex_js_1 = require("../../utils/encoding/toHex.js");
|
|
12
12
|
const toRlp_js_1 = require("../../utils/encoding/toRlp.js");
|
13
13
|
const serializeAccessList_js_1 = require("../../utils/transaction/serializeAccessList.js");
|
14
14
|
const serializeTransaction_js_1 = require("../../utils/transaction/serializeTransaction.js");
|
15
|
+
const utils_js_1 = require("./utils.js");
|
15
16
|
const serializeTransactionCelo = (tx, signature) => {
|
16
|
-
if (isCIP64(tx)) {
|
17
|
+
if ((0, utils_js_1.isCIP64)(tx)) {
|
17
18
|
return serializeTransactionCIP64(tx, signature);
|
18
19
|
}
|
19
|
-
else if (isCIP42(tx)) {
|
20
|
+
else if ((0, utils_js_1.isCIP42)(tx)) {
|
20
21
|
return serializeTransactionCIP42(tx, signature);
|
21
22
|
}
|
22
23
|
else {
|
@@ -75,29 +76,7 @@ function serializeTransactionCIP64(transaction, signature) {
|
|
75
76
|
(0, toRlp_js_1.toRlp)(serializedTransaction),
|
76
77
|
]);
|
77
78
|
}
|
78
|
-
|
79
|
-
if (transaction.type === 'cip42')
|
80
|
-
return true;
|
81
|
-
if (transaction.type)
|
82
|
-
return false;
|
83
|
-
return ('maxFeePerGas' in transaction &&
|
84
|
-
'maxPriorityFeePerGas' in transaction &&
|
85
|
-
('feeCurrency' in transaction ||
|
86
|
-
'gatewayFee' in transaction ||
|
87
|
-
'gatewayFeeRecipient' in transaction));
|
88
|
-
}
|
89
|
-
function isCIP64(transaction) {
|
90
|
-
if (transaction.type === 'cip64')
|
91
|
-
return true;
|
92
|
-
if (transaction.type)
|
93
|
-
return false;
|
94
|
-
return ('maxFeePerGas' in transaction &&
|
95
|
-
'maxPriorityFeePerGas' in transaction &&
|
96
|
-
'feeCurrency' in transaction &&
|
97
|
-
!('gatewayFee' in transaction) &&
|
98
|
-
!('gatewayFeeRecipient' in transaction));
|
99
|
-
}
|
100
|
-
const MAX_MAX_FEE_PER_GAS = 115792089237316195423570985008687907853269984665640564039457584007913129639935n;
|
79
|
+
const MAX_MAX_FEE_PER_GAS = 2n ** 256n - 1n;
|
101
80
|
function assertTransactionCIP42(transaction) {
|
102
81
|
const { chainId, maxPriorityFeePerGas, gasPrice, maxFeePerGas, to, feeCurrency, gatewayFee, gatewayFeeRecipient, } = transaction;
|
103
82
|
if (chainId <= 0)
|
@@ -106,20 +85,23 @@ function assertTransactionCIP42(transaction) {
|
|
106
85
|
throw new address_js_1.InvalidAddressError({ address: to });
|
107
86
|
if (gasPrice)
|
108
87
|
throw new base_js_1.BaseError('`gasPrice` is not a valid CIP-42 Transaction attribute.');
|
109
|
-
if (maxFeePerGas && maxFeePerGas > MAX_MAX_FEE_PER_GAS)
|
88
|
+
if ((0, utils_js_1.isPresent)(maxFeePerGas) && maxFeePerGas > MAX_MAX_FEE_PER_GAS)
|
110
89
|
throw new node_js_1.FeeCapTooHighError({ maxFeePerGas });
|
111
|
-
if (maxPriorityFeePerGas &&
|
112
|
-
maxFeePerGas &&
|
90
|
+
if ((0, utils_js_1.isPresent)(maxPriorityFeePerGas) &&
|
91
|
+
(0, utils_js_1.isPresent)(maxFeePerGas) &&
|
113
92
|
maxPriorityFeePerGas > maxFeePerGas)
|
114
93
|
throw new node_js_1.TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas });
|
115
|
-
if ((gatewayFee &&
|
116
|
-
(gatewayFeeRecipient &&
|
94
|
+
if (((0, utils_js_1.isPresent)(gatewayFee) && (0, utils_js_1.isEmpty)(gatewayFeeRecipient)) ||
|
95
|
+
((0, utils_js_1.isPresent)(gatewayFeeRecipient) && (0, utils_js_1.isEmpty)(gatewayFee))) {
|
117
96
|
throw new base_js_1.BaseError('`gatewayFee` and `gatewayFeeRecipient` must be provided together.');
|
118
97
|
}
|
119
|
-
if (feeCurrency && !
|
98
|
+
if ((0, utils_js_1.isPresent)(feeCurrency) && !(0, isAddress_js_1.isAddress)(feeCurrency)) {
|
120
99
|
throw new base_js_1.BaseError('`feeCurrency` MUST be a token address for CIP-42 transactions.');
|
121
100
|
}
|
122
|
-
if (
|
101
|
+
if ((0, utils_js_1.isPresent)(gatewayFeeRecipient) && !(0, isAddress_js_1.isAddress)(gatewayFeeRecipient)) {
|
102
|
+
throw new address_js_1.InvalidAddressError(gatewayFeeRecipient);
|
103
|
+
}
|
104
|
+
if ((0, utils_js_1.isEmpty)(feeCurrency) && (0, utils_js_1.isEmpty)(gatewayFeeRecipient)) {
|
123
105
|
throw new base_js_1.BaseError('Either `feeCurrency` or `gatewayFeeRecipient` must be provided for CIP-42 transactions.');
|
124
106
|
}
|
125
107
|
}
|
@@ -132,16 +114,16 @@ function assertTransactionCIP64(transaction) {
|
|
132
114
|
throw new address_js_1.InvalidAddressError({ address: to });
|
133
115
|
if (gasPrice)
|
134
116
|
throw new base_js_1.BaseError('`gasPrice` is not a valid CIP-64 Transaction attribute.');
|
135
|
-
if (maxFeePerGas && maxFeePerGas > MAX_MAX_FEE_PER_GAS)
|
117
|
+
if ((0, utils_js_1.isPresent)(maxFeePerGas) && maxFeePerGas > MAX_MAX_FEE_PER_GAS)
|
136
118
|
throw new node_js_1.FeeCapTooHighError({ maxFeePerGas });
|
137
|
-
if (maxPriorityFeePerGas &&
|
138
|
-
maxFeePerGas &&
|
119
|
+
if ((0, utils_js_1.isPresent)(maxPriorityFeePerGas) &&
|
120
|
+
(0, utils_js_1.isPresent)(maxFeePerGas) &&
|
139
121
|
maxPriorityFeePerGas > maxFeePerGas)
|
140
122
|
throw new node_js_1.TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas });
|
141
|
-
if (feeCurrency && !feeCurrency?.startsWith('0x')) {
|
123
|
+
if ((0, utils_js_1.isPresent)(feeCurrency) && !feeCurrency?.startsWith('0x')) {
|
142
124
|
throw new base_js_1.BaseError('`feeCurrency` MUST be a token address for CIP-64 transactions.');
|
143
125
|
}
|
144
|
-
if (
|
126
|
+
if ((0, utils_js_1.isEmpty)(feeCurrency)) {
|
145
127
|
throw new base_js_1.BaseError('`feeCurrency` must be provided for CIP-64 transactions.');
|
146
128
|
}
|
147
129
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"serializers.js","sourceRoot":"","sources":["../../../chains/celo/serializers.ts"],"names":[],"mappings":";;;AAAA,wDAA6D;AAC7D,kDAAgD;AAChD,oDAA2D;AAC3D,kDAA8E;AAI9E,mEAA4D;AAC5D,0DAAsD;AACtD,sDAA+C;AAC/C,4DAAqD;AACrD,4DAAqD;AACrD,2FAAoF;AACpF,6FAGwD;
|
1
|
+
{"version":3,"file":"ser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AyC;IAEzC,MAAM,EACJ,OAAO,EACP,oBAAoB,EACpB,QAAQ,EACR,YAAY,EACZ,EAAE,EACF,WAAW,GACZ,GAAG,WAAW,CAAA;IAEf,IAAI,OAAO,IAAI,CAAC;QAAE,MAAM,IAAI,8BAAmB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;IAC5D,IAAI,EAAE,IAAI,CAAC,IAAA,wBAAS,EAAC,EAAE,CAAC;QAAE,MAAM,IAAI,gCAAmB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAA;IAExE,IAAI,QAAQ;QACV,MAAM,IAAI,mBAAS,CACjB,yDAAyD,CAC1D,CAAA;IAEH,IAAI,IAAA,oBAAS,EAAC,YAAY,CAAC,IAAI,YAAY,GAAG,mBAAmB;QAC/D,MAAM,IAAI,4BAAkB,CAAC,EAAE,YAAY,EAAE,CAAC,CAAA;IAChD,IACE,IAAA,oBAAS,EAAC,oBAAoB,CAAC;QAC/B,IAAA,oBAAS,EAAC,YAAY,CAAC;QACvB,oBAAoB,GAAG,YAAY;QAEnC,MAAM,IAAI,6BAAmB,CAAC,EAAE,YAAY,EAAE,oBAAoB,EAAE,CAAC,CAAA;IAEvE,IAAI,IAAA,oBAAS,EAAC,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE;QAC5D,MAAM,IAAI,mBAAS,CACjB,gEAAgE,CACjE,CAAA;KACF;IAED,IAAI,IAAA,kBAAO,EAAC,WAAW,CAAC,EAAE;QACxB,MAAM,IAAI,mBAAS,CACjB,yDAAyD,CAC1D,CAAA;KACF;AACH,CAAC;AAxCD,wDAwCC"}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.isCIP64 = exports.isCIP42 = exports.isEIP1559 = exports.isPresent = exports.isEmpty = void 0;
|
4
|
+
const trim_js_1 = require("../../utils/data/trim.js");
|
5
|
+
function isEmpty(value) {
|
6
|
+
return (value === 0 ||
|
7
|
+
value === 0n ||
|
8
|
+
value === undefined ||
|
9
|
+
value === null ||
|
10
|
+
value === '0' ||
|
11
|
+
value === '' ||
|
12
|
+
(typeof value === 'string' &&
|
13
|
+
((0, trim_js_1.trim)(value).toLowerCase() === '0x' ||
|
14
|
+
(0, trim_js_1.trim)(value).toLowerCase() === '0x00')));
|
15
|
+
}
|
16
|
+
exports.isEmpty = isEmpty;
|
17
|
+
function isPresent(value) {
|
18
|
+
return !isEmpty(value);
|
19
|
+
}
|
20
|
+
exports.isPresent = isPresent;
|
21
|
+
function isEIP1559(transaction) {
|
22
|
+
return (isPresent(transaction.maxFeePerGas) &&
|
23
|
+
isPresent(transaction.maxPriorityFeePerGas));
|
24
|
+
}
|
25
|
+
exports.isEIP1559 = isEIP1559;
|
26
|
+
function isCIP42(transaction) {
|
27
|
+
if (transaction.type === 'cip42') {
|
28
|
+
return true;
|
29
|
+
}
|
30
|
+
return (isEIP1559(transaction) &&
|
31
|
+
(isPresent(transaction.feeCurrency) ||
|
32
|
+
isPresent(transaction.gatewayFeeRecipient) ||
|
33
|
+
isPresent(transaction.gatewayFee)));
|
34
|
+
}
|
35
|
+
exports.isCIP42 = isCIP42;
|
36
|
+
function isCIP64(transaction) {
|
37
|
+
if (transaction.type === 'cip64') {
|
38
|
+
return true;
|
39
|
+
}
|
40
|
+
return (isEIP1559(transaction) &&
|
41
|
+
isPresent(transaction.feeCurrency) &&
|
42
|
+
isEmpty(transaction.gatewayFee) &&
|
43
|
+
isEmpty(transaction.gatewayFeeRecipient));
|
44
|
+
}
|
45
|
+
exports.isCIP64 = isCIP64;
|
46
|
+
//# sourceMappingURL=utils.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../chains/celo/utils.ts"],"names":[],"mappings":";;;AACA,sDAA+C;AAQ/C,SAAgB,OAAO,CACrB,KAA2C;IAE3C,OAAO,CACL,KAAK,KAAK,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C,CACzC,CAAA;AACH,CAAC;AAdD,0BAcC"}
|
package/_cjs/errors/version.js
CHANGED
@@ -5,22 +5,7 @@ import { defineBlock } from '../../utils/formatters/block.js';
|
|
5
5
|
import { defineTransaction, formatTransaction, } from '../../utils/formatters/transaction.js';
|
6
6
|
import { defineTransactionReceipt } from '../../utils/formatters/transactionReceipt.js';
|
7
7
|
import { defineTransactionRequest } from '../../utils/formatters/transactionRequest.js';
|
8
|
-
|
9
|
-
if (args.type === 'cip64')
|
10
|
-
return true;
|
11
|
-
if (args.type)
|
12
|
-
return false;
|
13
|
-
return ('feeCurrency' in args &&
|
14
|
-
args.gatewayFee === undefined &&
|
15
|
-
args.gatewayFeeRecipient === undefined);
|
16
|
-
}
|
17
|
-
function isTransactionRequestCIP42(args) {
|
18
|
-
if (args.type === 'cip42')
|
19
|
-
return true;
|
20
|
-
if (args.type)
|
21
|
-
return false;
|
22
|
-
return args.gatewayFee !== undefined || args.gatewayFeeRecipient !== undefined;
|
23
|
-
}
|
8
|
+
import { isCIP42, isCIP64 } from './utils.js';
|
24
9
|
export const formattersCelo = {
|
25
10
|
block: /*#__PURE__*/ defineBlock({
|
26
11
|
exclude: ['difficulty', 'gasLimit', 'mixHash', 'nonce', 'uncles'],
|
@@ -71,7 +56,7 @@ export const formattersCelo = {
|
|
71
56
|
}),
|
72
57
|
transactionRequest: /*#__PURE__*/ defineTransactionRequest({
|
73
58
|
format(args) {
|
74
|
-
if (
|
59
|
+
if (isCIP64(args))
|
75
60
|
return {
|
76
61
|
type: '0x7b',
|
77
62
|
feeCurrency: args.feeCurrency,
|
@@ -83,7 +68,7 @@ export const formattersCelo = {
|
|
83
68
|
: undefined,
|
84
69
|
gatewayFeeRecipient: args.gatewayFeeRecipient,
|
85
70
|
};
|
86
|
-
if (
|
71
|
+
if (isCIP42(args))
|
87
72
|
request.type = '0x7c';
|
88
73
|
return request;
|
89
74
|
},
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../../chains/celo/formatters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,MAAM,sBAAsB,CAAA;AAG3D,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAC7D,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAA;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAA;
|
1
|
+
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../../chains/celo/formatters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,MAAM,sBAAsB,CAAA;AAG3D,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAC7D,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAA;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAA;AAUvF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAE7C,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC;QAC/B,OAAO,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC;QACjE,MAAM,CACJ,IAEC;YAID,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE;gBAC1D,IAAI,OAAO,WAAW,KAAK,QAA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CAAA;QACH,CAAC;KACF,CAAC;IAEF,kBAAkB,EAAE,aAAa,CAAC,wBAAwB,CAAC;QACzD,MAAM,CAAC,IAA4B;YACjC,IAAI,OAAO,CAAC,IAAI,CAAC;gBACf,OAAO;oBACL,IAAI,EAAE,MAAM;oBACZ,WAAW,EAAE,IAAI,CAAC,WAAW;iBACD,CAAA;YAEhC,MAAM,OAAO,GAAG;gBACd,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,UAAU,EACR,OAAO,IAAI,CAAC,UAAU,KAAK,WAAW;oBACpC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC;oBAC9B,CAAC,CAAC,SAAS;gBACf,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;aACjB,CAAA;YAE9B,IAAI,OAAO,CAAC,IAAI,CAAC;gBAAE,OAAO,CAAC,IAAI,GAAG,MAAM,CAAA;YAExC,OAAO,OAAO,CAAA;QAChB,CAAC;KACF,CAAC;CACgC,CAAA"}
|
@@ -9,6 +9,7 @@ import { toHex } from '../../utils/encoding/toHex.js';
|
|
9
9
|
import { toRlp } from '../../utils/encoding/toRlp.js';
|
10
10
|
import { serializeAccessList } from '../../utils/transaction/serializeAccessList.js';
|
11
11
|
import { serializeTransaction, } from '../../utils/transaction/serializeTransaction.js';
|
12
|
+
import { isCIP42, isCIP64, isEmpty, isPresent } from './utils.js';
|
12
13
|
export const serializeTransactionCelo = (tx, signature) => {
|
13
14
|
if (isCIP64(tx)) {
|
14
15
|
return serializeTransactionCIP64(tx, signature);
|
@@ -76,37 +77,8 @@ function serializeTransactionCIP64(transaction, signature) {
|
|
76
77
|
toRlp(serializedTransaction),
|
77
78
|
]);
|
78
79
|
}
|
79
|
-
|
80
|
-
|
81
|
-
// process as CIP42 if any of these fields are present. realistically gatewayfee is not used but is part of spec
|
82
|
-
function isCIP42(transaction) {
|
83
|
-
if (transaction.type === 'cip42')
|
84
|
-
return true;
|
85
|
-
// if the type is defined as anything else, assume it is *not* cip42
|
86
|
-
if (transaction.type)
|
87
|
-
return false;
|
88
|
-
// if the type is undefined, check if the fields match the expectations for cip42
|
89
|
-
return ('maxFeePerGas' in transaction &&
|
90
|
-
'maxPriorityFeePerGas' in transaction &&
|
91
|
-
('feeCurrency' in transaction ||
|
92
|
-
'gatewayFee' in transaction ||
|
93
|
-
'gatewayFeeRecipient' in transaction));
|
94
|
-
}
|
95
|
-
function isCIP64(transaction) {
|
96
|
-
if (transaction.type === 'cip64')
|
97
|
-
return true;
|
98
|
-
// if the type is defined as anything else, assume it is *not* cip64
|
99
|
-
if (transaction.type)
|
100
|
-
return false;
|
101
|
-
// if the type is undefined, check if the fields match the expectations for cip64
|
102
|
-
return ('maxFeePerGas' in transaction &&
|
103
|
-
'maxPriorityFeePerGas' in transaction &&
|
104
|
-
'feeCurrency' in transaction &&
|
105
|
-
!('gatewayFee' in transaction) &&
|
106
|
-
!('gatewayFeeRecipient' in transaction));
|
107
|
-
}
|
108
|
-
// maxFeePerGas must be less than 2^256 - 1: however writing like that caused exceptions to be raised
|
109
|
-
const MAX_MAX_FEE_PER_GAS = 115792089237316195423570985008687907853269984665640564039457584007913129639935n;
|
80
|
+
// maxFeePerGas must be less than 2^256 - 1
|
81
|
+
const MAX_MAX_FEE_PER_GAS = 2n ** 256n - 1n;
|
110
82
|
export function assertTransactionCIP42(transaction) {
|
111
83
|
const { chainId, maxPriorityFeePerGas, gasPrice, maxFeePerGas, to, feeCurrency, gatewayFee, gatewayFeeRecipient, } = transaction;
|
112
84
|
if (chainId <= 0)
|
@@ -115,20 +87,23 @@ export function assertTransactionCIP42(transaction) {
|
|
115
87
|
throw new InvalidAddressError({ address: to });
|
116
88
|
if (gasPrice)
|
117
89
|
throw new BaseError('`gasPrice` is not a valid CIP-42 Transaction attribute.');
|
118
|
-
if (maxFeePerGas && maxFeePerGas > MAX_MAX_FEE_PER_GAS)
|
90
|
+
if (isPresent(maxFeePerGas) && maxFeePerGas > MAX_MAX_FEE_PER_GAS)
|
119
91
|
throw new FeeCapTooHighError({ maxFeePerGas });
|
120
|
-
if (maxPriorityFeePerGas &&
|
121
|
-
maxFeePerGas &&
|
92
|
+
if (isPresent(maxPriorityFeePerGas) &&
|
93
|
+
isPresent(maxFeePerGas) &&
|
122
94
|
maxPriorityFeePerGas > maxFeePerGas)
|
123
95
|
throw new TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas });
|
124
|
-
if ((gatewayFee &&
|
125
|
-
(gatewayFeeRecipient &&
|
96
|
+
if ((isPresent(gatewayFee) && isEmpty(gatewayFeeRecipient)) ||
|
97
|
+
(isPresent(gatewayFeeRecipient) && isEmpty(gatewayFee))) {
|
126
98
|
throw new BaseError('`gatewayFee` and `gatewayFeeRecipient` must be provided together.');
|
127
99
|
}
|
128
|
-
if (feeCurrency && !feeCurrency
|
100
|
+
if (isPresent(feeCurrency) && !isAddress(feeCurrency)) {
|
129
101
|
throw new BaseError('`feeCurrency` MUST be a token address for CIP-42 transactions.');
|
130
102
|
}
|
131
|
-
if (
|
103
|
+
if (isPresent(gatewayFeeRecipient) && !isAddress(gatewayFeeRecipient)) {
|
104
|
+
throw new InvalidAddressError(gatewayFeeRecipient);
|
105
|
+
}
|
106
|
+
if (isEmpty(feeCurrency) && isEmpty(gatewayFeeRecipient)) {
|
132
107
|
throw new BaseError('Either `feeCurrency` or `gatewayFeeRecipient` must be provided for CIP-42 transactions.');
|
133
108
|
}
|
134
109
|
}
|
@@ -140,16 +115,16 @@ export function assertTransactionCIP64(transaction) {
|
|
140
115
|
throw new InvalidAddressError({ address: to });
|
141
116
|
if (gasPrice)
|
142
117
|
throw new BaseError('`gasPrice` is not a valid CIP-64 Transaction attribute.');
|
143
|
-
if (maxFeePerGas && maxFeePerGas > MAX_MAX_FEE_PER_GAS)
|
118
|
+
if (isPresent(maxFeePerGas) && maxFeePerGas > MAX_MAX_FEE_PER_GAS)
|
144
119
|
throw new FeeCapTooHighError({ maxFeePerGas });
|
145
|
-
if (maxPriorityFeePerGas &&
|
146
|
-
maxFeePerGas &&
|
120
|
+
if (isPresent(maxPriorityFeePerGas) &&
|
121
|
+
isPresent(maxFeePerGas) &&
|
147
122
|
maxPriorityFeePerGas > maxFeePerGas)
|
148
123
|
throw new TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas });
|
149
|
-
if (feeCurrency && !feeCurrency?.startsWith('0x')) {
|
124
|
+
if (isPresent(feeCurrency) && !feeCurrency?.startsWith('0x')) {
|
150
125
|
throw new BaseError('`feeCurrency` MUST be a token address for CIP-64 transactions.');
|
151
126
|
}
|
152
|
-
if (
|
127
|
+
if (isEmpty(feeCurrency)) {
|
153
128
|
throw new BaseError('`feeCurrency` must be provided for CIP-64 transactions.');
|
154
129
|
}
|
155
130
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"serializers.js","sourceRoot":"","sources":["../../../chains/celo/serializers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAI9E,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAA;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAA;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAA;AACpF,OAAO,EAEL,oBAAoB,GACrB,MAAM,iDAAiD,CAAA;
|
1
|
+
{"version":3,"file":"serializers.js","sourceRoot":"","sources":["../../../chains/celo/serializers.ts"],"names":[],"mappings":"AAAA,O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export function isEmpty(value) {
|
3
|
+
return (value === 0 ||
|
4
|
+
value === 0n ||
|
5
|
+
value === undefined ||
|
6
|
+
value === null ||
|
7
|
+
value === '0' ||
|
8
|
+
value === '' ||
|
9
|
+
(typeof value === 'string' &&
|
10
|
+
(trim(value).toLowerCase() === '0x' ||
|
11
|
+
trim(value).toLowerCase() === '0x00')));
|
12
|
+
}
|
13
|
+
export function isPresent(value) {
|
14
|
+
return !isEmpty(value);
|
15
|
+
}
|
16
|
+
export function isEIP1559(transaction) {
|
17
|
+
return (isPresent(transaction.maxFeePerGas) &&
|
18
|
+
isPresent(transaction.maxPriorityFeePerGas));
|
19
|
+
}
|
20
|
+
// process as CIP42 if any of these fields are present. realistically gatewayfee is not used but is part of spec
|
21
|
+
export function isCIP42(transaction) {
|
22
|
+
// Enable end-user to force the tx to be considered as a cip42
|
23
|
+
if (transaction.type === 'cip42') {
|
24
|
+
return true;
|
25
|
+
}
|
26
|
+
return (isEIP1559(transaction) &&
|
27
|
+
(isPresent(transaction.feeCurrency) ||
|
28
|
+
isPresent(transaction.gatewayFeeRecipient) ||
|
29
|
+
isPresent(transaction.gatewayFee)));
|
30
|
+
}
|
31
|
+
export function isCIP64(transaction) {
|
32
|
+
// Enable end-user to force the tx to be considered as a cip64
|
33
|
+
if (transaction.type === 'cip64') {
|
34
|
+
return true;
|
35
|
+
}
|
36
|
+
return (isEIP1559(transaction) &&
|
37
|
+
isPresent(transaction.feeCurrency) &&
|
38
|
+
isEmpty(transaction.gatewayFee) &&
|
39
|
+
isEmpty(transaction.gatewayFeeRecipient));
|
40
|
+
}
|
41
|
+
//# sourceMappingURL=utils.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../chains/celo/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAQ/C,MAAM,UAAU,OAAO,CACrB,KAA2C;IAE3C,OAAO,CACL,KAAK,KAAK,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,CACzC,CAAA;AACH,CAAC"}
|
package/_esm/errors/version.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export const version = '0.0.0-main.
|
1
|
+
export const version = '0.0.0-main.20231105T204445';
|
2
2
|
//# sourceMappingURL=version.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../../../chains/celo/formatters.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAW/C,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,kCAAkC,EAElC,eAAe,EAEf,sBAAsB,EACvB,MAAM,YAAY,CAAA;
|
1
|
+
{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../../../chains/celo/formatters.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAW/C,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,kCAAkC,EAElC,eAAe,EAEf,sBAAsB,EACvB,MAAM,YAAY,CAAA;AAGnB,eAAO,MAAM,cAAc;;;;0BAKL,IAAI,EAAE,GAAG,kBAAkB,EAAE;;;;;;;;;;;;;;;;;;;;;0BAG/B,IAAI,EAAE,GAAG,eAAe,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuEV,CAAA"}
|
@@ -1,8 +1,9 @@
|
|
1
|
+
import type { TransactionSerializable } from '../../types/transaction.js';
|
1
2
|
import { type SerializeTransactionFn } from '../../utils/transaction/serializeTransaction.js';
|
2
3
|
import type { CeloTransactionSerializable, TransactionSerializableCIP42, TransactionSerializableCIP64, TransactionSerializedCIP42, TransactionSerializedCIP64 } from './types.js';
|
3
|
-
export declare const serializeTransactionCelo: SerializeTransactionFn<CeloTransactionSerializable>;
|
4
|
+
export declare const serializeTransactionCelo: SerializeTransactionFn<CeloTransactionSerializable | TransactionSerializable>;
|
4
5
|
export declare const serializersCelo: {
|
5
|
-
readonly transaction: SerializeTransactionFn<CeloTransactionSerializable>;
|
6
|
+
readonly transaction: SerializeTransactionFn<TransactionSerializable | CeloTransactionSerializable>;
|
6
7
|
};
|
7
8
|
export type SerializeTransactionCIP42ReturnType = TransactionSerializedCIP42;
|
8
9
|
export type SerializeTransactionCIP64ReturnType = TransactionSerializedCIP64;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"serializers.d.ts","sourceRoot":"","sources":["../../../chains/celo/serializers.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"serializers.d.ts","sourceRoot":"","sources":["../../../chains/celo/serializers.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AAOzE,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,iDAAiD,CAAA;AACxD,OAAO,KAAK,EACV,2BAA2B,EAC3B,4BAA4B,EAC5B,4BAA4B,EAC5B,0BAA0B,EAC1B,0BAA0B,EAC3B,MAAM,YAAY,CAAA;AAGnB,eAAO,MAAM,wBAAwB,EAAE,sBAAsB,CAC3D,2BAA2B,GAAG,uBAAuB,CAStD,CAAA;AAED,eAAO,MAAM,eAAe;;CAES,CAAA;AAKrC,MAAM,MAAM,mCAAmC,GAAG,0BAA0B,CAAA;AAC5E,MAAM,MAAM,mCAAmC,GAAG,0BAA0B,CAAA;AAsG5E,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,4BAA4B,QAqD1C;AAED,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,4BAA4B,QAuC1C"}
|
@@ -37,7 +37,7 @@ export type CeloTransactionReceiptOverrides = {
|
|
37
37
|
};
|
38
38
|
export type CeloTransactionReceipt = TransactionReceipt & CeloTransactionReceiptOverrides;
|
39
39
|
export type CeloTransactionRequest = TransactionRequest | TransactionRequestCIP42 | TransactionRequestCIP64;
|
40
|
-
export type CeloTransactionSerializable = TransactionSerializableCIP42 | TransactionSerializableCIP64 |
|
40
|
+
export type CeloTransactionSerializable = TransactionSerializableCIP42 | TransactionSerializableCIP64 | CeloTransactionSerializableBase;
|
41
41
|
export type CeloTransactionSerialized<TType extends CeloTransactionType = 'legacy'> = TransactionSerialized<TType> | TransactionSerializedCIP42 | TransactionSerializedCIP64;
|
42
42
|
export type CeloTransactionType = TransactionType | 'cip42' | 'cip64';
|
43
43
|
type RpcTransaction<TPending extends boolean = boolean> = RpcTransaction_<TPending> & {
|
@@ -110,22 +110,27 @@ export type TransactionRequestCIP64 = TransactionRequestBase & Partial<FeeValues
|
|
110
110
|
gatewayFeeRecipient?: undefined;
|
111
111
|
type?: 'cip64';
|
112
112
|
};
|
113
|
-
export type TransactionSerializableCIP42<TQuantity = bigint, TIndex = number> = TransactionSerializableBase<TQuantity, TIndex> & FeeValuesEIP1559<TQuantity
|
113
|
+
export type TransactionSerializableCIP42<TQuantity = bigint, TIndex = number> = TransactionSerializableBase<TQuantity, TIndex> & Partial<FeeValuesEIP1559<TQuantity>> & {
|
114
114
|
accessList?: AccessList;
|
115
|
-
gasPrice?: never;
|
116
115
|
feeCurrency?: Address;
|
117
116
|
gatewayFeeRecipient?: Address;
|
118
117
|
gatewayFee?: TQuantity;
|
119
118
|
chainId: number;
|
120
119
|
type?: 'cip42';
|
121
120
|
};
|
122
|
-
export type TransactionSerializableCIP64<TQuantity = bigint, TIndex = number> = TransactionSerializableBase<TQuantity, TIndex> & FeeValuesEIP1559<TQuantity
|
121
|
+
export type TransactionSerializableCIP64<TQuantity = bigint, TIndex = number> = TransactionSerializableBase<TQuantity, TIndex> & Partial<FeeValuesEIP1559<TQuantity>> & {
|
123
122
|
accessList?: AccessList;
|
124
|
-
gasPrice?: never;
|
125
123
|
feeCurrency?: Address;
|
124
|
+
gatewayFee?: undefined;
|
125
|
+
gatewayFeeRecipient?: undefined;
|
126
126
|
chainId: number;
|
127
127
|
type?: 'cip64';
|
128
128
|
};
|
129
|
+
export type CeloTransactionSerializableBase = TransactionSerializable & {
|
130
|
+
feeCurrency?: undefined;
|
131
|
+
gatewayFee?: undefined;
|
132
|
+
gatewayFeeRecipient?: undefined;
|
133
|
+
};
|
129
134
|
export type TransactionSerializedCIP42 = `0x7c${string}`;
|
130
135
|
export type TransactionSerializedCIP64 = `0x7b${string}`;
|
131
136
|
export {};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../chains/celo/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,KAAK,EACV,KAAK,EACL,QAAQ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C,gBAAgB,CAAC,SAAS,CAAC,CAAC,GAAG;IACrC,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,UAAU,CAAC,EAAE,SAAS,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,CAAA;AAEH,MAAM,MAAM,4BAA4B,CACtC,SAAS,GAAG,MAAM,EAClB,MAAM,GAAG,MAAM,IACb,2BAA2B,CAAC,SAAS,EAAE,MAAM,CAAC,GAChD,OAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,GAAG;IACrC,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,UAAU,CAAC,EAAE,SAAS,CAAA;IACtB,mBAAmB,CAAC,EAAE,SAAS,CAAA;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,CAAA;AAEH,MAAM,MAAM,+BAA+B,GAAG,uBAAuB,GAAG;IACtE,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB,UAAU,CAAC,EAAE,SAAS,CAAA;IACtB,mBAAmB,CAAC,EAAE,SAAS,CAAA;CAChC,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG,OAAO,MAAM,EAAE,CAAA;AACxD,MAAM,MAAM,0BAA0B,GAAG,OAAO,MAAM,EAAE,CAAA"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import type { CeloTransactionRequest, CeloTransactionSerializable, TransactionSerializableCIP42, TransactionSerializableCIP64 } from './types.js';
|
2
|
+
export declare function isEmpty(value: string | undefined | number | BigInt): value is undefined;
|
3
|
+
export declare function isPresent(value: string | undefined | number | BigInt): value is string | number | BigInt;
|
4
|
+
export declare function isEIP1559(transaction: CeloTransactionSerializable | CeloTransactionRequest): boolean;
|
5
|
+
export declare function isCIP42(transaction: CeloTransactionSerializable | CeloTransactionRequest): transaction is TransactionSerializableCIP42;
|
6
|
+
export declare function isCIP64(transaction: CeloTransactionSerializable | CeloTransactionRequest): transaction is TransactionSerializableCIP64;
|
7
|
+
//# sourceMappingURL=utils.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../chains/celo/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,sBAAsB,EACtB,2BAA2B,EAC3B,4BAA4B,EAC5B,4BAA4B,EAC7B,MAAM,YAAY,CAAA;AAEnB,wBAAgB,OAAO,CACrB,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAC1C,KAAK,IAAI,SAAS,CAYpB;AAED,wBAAgB,SAAS,CACvB,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAC1C,KAAK,IAAI,MAAM,GAAG,MAAM,GAAG,MAAM,CAEnC;AAED,wBAAgB,SAAS,CACvB,WAAW,EAAE,2BAA2B,GAAG,sBAAsB,GAChE,OAAO,CAKT;AAGD,wBAAgB,OAAO,CACrB,WAAW,EAAE,2BAA2B,GAAG,sBAAsB,GAChE,WAAW,IAAI,4BAA4B,CAY7C;AAED,wBAAgB,OAAO,CACrB,WAAW,EAAE,2BAA2B,GAAG,sBAAsB,GAChE,WAAW,IAAI,4BAA4B,CAY7C"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const version = "0.0.0-main.
|
1
|
+
export declare const version = "0.0.0-main.20231105T204445";
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
@@ -19,22 +19,7 @@ import type {
|
|
19
19
|
CeloTransactionReceiptOverrides,
|
20
20
|
CeloTransactionRequest,
|
21
21
|
} from './types.js'
|
22
|
-
|
23
|
-
function isTransactionRequestCIP64(args: CeloTransactionRequest): boolean {
|
24
|
-
if (args.type === 'cip64') return true
|
25
|
-
if (args.type) return false
|
26
|
-
return (
|
27
|
-
'feeCurrency' in args &&
|
28
|
-
args.gatewayFee === undefined &&
|
29
|
-
args.gatewayFeeRecipient === undefined
|
30
|
-
)
|
31
|
-
}
|
32
|
-
|
33
|
-
function isTransactionRequestCIP42(args: CeloTransactionRequest): boolean {
|
34
|
-
if (args.type === 'cip42') return true
|
35
|
-
if (args.type) return false
|
36
|
-
return args.gatewayFee !== undefined || args.gatewayFeeRecipient !== undefined
|
37
|
-
}
|
22
|
+
import { isCIP42, isCIP64 } from './utils.js'
|
38
23
|
|
39
24
|
export const formattersCelo = {
|
40
25
|
block: /*#__PURE__*/ defineBlock({
|
@@ -95,7 +80,7 @@ export const formattersCelo = {
|
|
95
80
|
|
96
81
|
transactionRequest: /*#__PURE__*/ defineTransactionRequest({
|
97
82
|
format(args: CeloTransactionRequest): CeloRpcTransactionRequest {
|
98
|
-
if (
|
83
|
+
if (isCIP64(args))
|
99
84
|
return {
|
100
85
|
type: '0x7b',
|
101
86
|
feeCurrency: args.feeCurrency,
|
@@ -110,7 +95,7 @@ export const formattersCelo = {
|
|
110
95
|
gatewayFeeRecipient: args.gatewayFeeRecipient,
|
111
96
|
} as CeloRpcTransactionRequest
|
112
97
|
|
113
|
-
if (
|
98
|
+
if (isCIP42(args)) request.type = '0x7c'
|
114
99
|
|
115
100
|
return request
|
116
101
|
},
|
@@ -22,20 +22,15 @@ import type {
|
|
22
22
|
TransactionSerializedCIP42,
|
23
23
|
TransactionSerializedCIP64,
|
24
24
|
} from './types.js'
|
25
|
+
import { isCIP42, isCIP64, isEmpty, isPresent } from './utils.js'
|
25
26
|
|
26
27
|
export const serializeTransactionCelo: SerializeTransactionFn<
|
27
|
-
CeloTransactionSerializable
|
28
|
+
CeloTransactionSerializable | TransactionSerializable
|
28
29
|
> = (tx, signature) => {
|
29
30
|
if (isCIP64(tx)) {
|
30
|
-
return serializeTransactionCIP64(
|
31
|
-
tx as TransactionSerializableCIP64,
|
32
|
-
signature,
|
33
|
-
)
|
31
|
+
return serializeTransactionCIP64(tx, signature)
|
34
32
|
} else if (isCIP42(tx)) {
|
35
|
-
return serializeTransactionCIP42(
|
36
|
-
tx as TransactionSerializableCIP42,
|
37
|
-
signature,
|
38
|
-
)
|
33
|
+
return serializeTransactionCIP42(tx, signature)
|
39
34
|
} else {
|
40
35
|
return serializeTransaction(tx as TransactionSerializable, signature)
|
41
36
|
}
|
@@ -148,43 +143,8 @@ function serializeTransactionCIP64(
|
|
148
143
|
]) as SerializeTransactionCIP64ReturnType
|
149
144
|
}
|
150
145
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
// process as CIP42 if any of these fields are present. realistically gatewayfee is not used but is part of spec
|
155
|
-
function isCIP42(transaction: CeloTransactionSerializable): boolean {
|
156
|
-
if (transaction.type === 'cip42') return true
|
157
|
-
// if the type is defined as anything else, assume it is *not* cip42
|
158
|
-
if (transaction.type) return false
|
159
|
-
|
160
|
-
// if the type is undefined, check if the fields match the expectations for cip42
|
161
|
-
return (
|
162
|
-
'maxFeePerGas' in transaction &&
|
163
|
-
'maxPriorityFeePerGas' in transaction &&
|
164
|
-
('feeCurrency' in transaction ||
|
165
|
-
'gatewayFee' in transaction ||
|
166
|
-
'gatewayFeeRecipient' in transaction)
|
167
|
-
)
|
168
|
-
}
|
169
|
-
|
170
|
-
function isCIP64(transaction: CeloTransactionSerializable): boolean {
|
171
|
-
if (transaction.type === 'cip64') return true
|
172
|
-
// if the type is defined as anything else, assume it is *not* cip64
|
173
|
-
if (transaction.type) return false
|
174
|
-
|
175
|
-
// if the type is undefined, check if the fields match the expectations for cip64
|
176
|
-
return (
|
177
|
-
'maxFeePerGas' in transaction &&
|
178
|
-
'maxPriorityFeePerGas' in transaction &&
|
179
|
-
'feeCurrency' in transaction &&
|
180
|
-
!('gatewayFee' in transaction) &&
|
181
|
-
!('gatewayFeeRecipient' in transaction)
|
182
|
-
)
|
183
|
-
}
|
184
|
-
|
185
|
-
// maxFeePerGas must be less than 2^256 - 1: however writing like that caused exceptions to be raised
|
186
|
-
const MAX_MAX_FEE_PER_GAS =
|
187
|
-
115792089237316195423570985008687907853269984665640564039457584007913129639935n
|
146
|
+
// maxFeePerGas must be less than 2^256 - 1
|
147
|
+
const MAX_MAX_FEE_PER_GAS = 2n ** 256n - 1n
|
188
148
|
|
189
149
|
export function assertTransactionCIP42(
|
190
150
|
transaction: TransactionSerializableCIP42,
|
@@ -206,32 +166,36 @@ export function assertTransactionCIP42(
|
|
206
166
|
'`gasPrice` is not a valid CIP-42 Transaction attribute.',
|
207
167
|
)
|
208
168
|
|
209
|
-
if (maxFeePerGas && maxFeePerGas > MAX_MAX_FEE_PER_GAS)
|
169
|
+
if (isPresent(maxFeePerGas) && maxFeePerGas > MAX_MAX_FEE_PER_GAS)
|
210
170
|
throw new FeeCapTooHighError({ maxFeePerGas })
|
211
171
|
|
212
172
|
if (
|
213
|
-
maxPriorityFeePerGas &&
|
214
|
-
maxFeePerGas &&
|
173
|
+
isPresent(maxPriorityFeePerGas) &&
|
174
|
+
isPresent(maxFeePerGas) &&
|
215
175
|
maxPriorityFeePerGas > maxFeePerGas
|
216
176
|
)
|
217
177
|
throw new TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas })
|
218
178
|
|
219
179
|
if (
|
220
|
-
(gatewayFee &&
|
221
|
-
(gatewayFeeRecipient &&
|
180
|
+
(isPresent(gatewayFee) && isEmpty(gatewayFeeRecipient)) ||
|
181
|
+
(isPresent(gatewayFeeRecipient) && isEmpty(gatewayFee))
|
222
182
|
) {
|
223
183
|
throw new BaseError(
|
224
184
|
'`gatewayFee` and `gatewayFeeRecipient` must be provided together.',
|
225
185
|
)
|
226
186
|
}
|
227
187
|
|
228
|
-
if (feeCurrency && !feeCurrency
|
188
|
+
if (isPresent(feeCurrency) && !isAddress(feeCurrency)) {
|
229
189
|
throw new BaseError(
|
230
190
|
'`feeCurrency` MUST be a token address for CIP-42 transactions.',
|
231
191
|
)
|
232
192
|
}
|
233
193
|
|
234
|
-
if (
|
194
|
+
if (isPresent(gatewayFeeRecipient) && !isAddress(gatewayFeeRecipient)) {
|
195
|
+
throw new InvalidAddressError(gatewayFeeRecipient)
|
196
|
+
}
|
197
|
+
|
198
|
+
if (isEmpty(feeCurrency) && isEmpty(gatewayFeeRecipient)) {
|
235
199
|
throw new BaseError(
|
236
200
|
'Either `feeCurrency` or `gatewayFeeRecipient` must be provided for CIP-42 transactions.',
|
237
201
|
)
|
@@ -258,22 +222,22 @@ export function assertTransactionCIP64(
|
|
258
222
|
'`gasPrice` is not a valid CIP-64 Transaction attribute.',
|
259
223
|
)
|
260
224
|
|
261
|
-
if (maxFeePerGas && maxFeePerGas > MAX_MAX_FEE_PER_GAS)
|
225
|
+
if (isPresent(maxFeePerGas) && maxFeePerGas > MAX_MAX_FEE_PER_GAS)
|
262
226
|
throw new FeeCapTooHighError({ maxFeePerGas })
|
263
227
|
if (
|
264
|
-
maxPriorityFeePerGas &&
|
265
|
-
maxFeePerGas &&
|
228
|
+
isPresent(maxPriorityFeePerGas) &&
|
229
|
+
isPresent(maxFeePerGas) &&
|
266
230
|
maxPriorityFeePerGas > maxFeePerGas
|
267
231
|
)
|
268
232
|
throw new TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas })
|
269
233
|
|
270
|
-
if (feeCurrency && !feeCurrency?.startsWith('0x')) {
|
234
|
+
if (isPresent(feeCurrency) && !feeCurrency?.startsWith('0x')) {
|
271
235
|
throw new BaseError(
|
272
236
|
'`feeCurrency` MUST be a token address for CIP-64 transactions.',
|
273
237
|
)
|
274
238
|
}
|
275
239
|
|
276
|
-
if (
|
240
|
+
if (isEmpty(feeCurrency)) {
|
277
241
|
throw new BaseError(
|
278
242
|
'`feeCurrency` must be provided for CIP-64 transactions.',
|
279
243
|
)
|
package/chains/celo/types.ts
CHANGED
@@ -111,7 +111,7 @@ export type CeloTransactionRequest =
|
|
111
111
|
export type CeloTransactionSerializable =
|
112
112
|
| TransactionSerializableCIP42
|
113
113
|
| TransactionSerializableCIP64
|
114
|
-
|
|
114
|
+
| CeloTransactionSerializableBase
|
115
115
|
|
116
116
|
export type CeloTransactionSerialized<
|
117
117
|
TType extends CeloTransactionType = 'legacy',
|
@@ -231,9 +231,8 @@ export type TransactionSerializableCIP42<
|
|
231
231
|
TQuantity = bigint,
|
232
232
|
TIndex = number,
|
233
233
|
> = TransactionSerializableBase<TQuantity, TIndex> &
|
234
|
-
FeeValuesEIP1559<TQuantity
|
234
|
+
Partial<FeeValuesEIP1559<TQuantity>> & {
|
235
235
|
accessList?: AccessList
|
236
|
-
gasPrice?: never
|
237
236
|
feeCurrency?: Address
|
238
237
|
gatewayFeeRecipient?: Address
|
239
238
|
gatewayFee?: TQuantity
|
@@ -245,13 +244,20 @@ export type TransactionSerializableCIP64<
|
|
245
244
|
TQuantity = bigint,
|
246
245
|
TIndex = number,
|
247
246
|
> = TransactionSerializableBase<TQuantity, TIndex> &
|
248
|
-
FeeValuesEIP1559<TQuantity
|
247
|
+
Partial<FeeValuesEIP1559<TQuantity>> & {
|
249
248
|
accessList?: AccessList
|
250
|
-
gasPrice?: never
|
251
249
|
feeCurrency?: Address
|
250
|
+
gatewayFee?: undefined
|
251
|
+
gatewayFeeRecipient?: undefined
|
252
252
|
chainId: number
|
253
253
|
type?: 'cip64'
|
254
254
|
}
|
255
255
|
|
256
|
+
export type CeloTransactionSerializableBase = TransactionSerializable & {
|
257
|
+
feeCurrency?: undefined
|
258
|
+
gatewayFee?: undefined
|
259
|
+
gatewayFeeRecipient?: undefined
|
260
|
+
}
|
261
|
+
|
256
262
|
export type TransactionSerializedCIP42 = `0x7c${string}`
|
257
263
|
export type TransactionSerializedCIP64 = `0x7b${string}`
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import type { Address } from 'abitype'
|
2
|
+
import { trim } from '../../utils/data/trim.js'
|
3
|
+
import type {
|
4
|
+
CeloTransactionRequest,
|
5
|
+
CeloTransactionSerializable,
|
6
|
+
TransactionSerializableCIP42,
|
7
|
+
TransactionSerializableCIP64,
|
8
|
+
} from './types.js'
|
9
|
+
|
10
|
+
export function isEmpty(
|
11
|
+
value: string | undefined | number | BigInt,
|
12
|
+
): value is undefined {
|
13
|
+
return (
|
14
|
+
value === 0 ||
|
15
|
+
value === 0n ||
|
16
|
+
value === undefined ||
|
17
|
+
value === null ||
|
18
|
+
value === '0' ||
|
19
|
+
value === '' ||
|
20
|
+
(typeof value === 'string' &&
|
21
|
+
(trim(value as Address).toLowerCase() === '0x' ||
|
22
|
+
trim(value as Address).toLowerCase() === '0x00'))
|
23
|
+
)
|
24
|
+
}
|
25
|
+
|
26
|
+
export function isPresent(
|
27
|
+
value: string | undefined | number | BigInt,
|
28
|
+
): value is string | number | BigInt {
|
29
|
+
return !isEmpty(value)
|
30
|
+
}
|
31
|
+
|
32
|
+
export function isEIP1559(
|
33
|
+
transaction: CeloTransactionSerializable | CeloTransactionRequest,
|
34
|
+
): boolean {
|
35
|
+
return (
|
36
|
+
isPresent(transaction.maxFeePerGas) &&
|
37
|
+
isPresent(transaction.maxPriorityFeePerGas)
|
38
|
+
)
|
39
|
+
}
|
40
|
+
|
41
|
+
// process as CIP42 if any of these fields are present. realistically gatewayfee is not used but is part of spec
|
42
|
+
export function isCIP42(
|
43
|
+
transaction: CeloTransactionSerializable | CeloTransactionRequest,
|
44
|
+
): transaction is TransactionSerializableCIP42 {
|
45
|
+
// Enable end-user to force the tx to be considered as a cip42
|
46
|
+
if (transaction.type === 'cip42') {
|
47
|
+
return true
|
48
|
+
}
|
49
|
+
|
50
|
+
return (
|
51
|
+
isEIP1559(transaction) &&
|
52
|
+
(isPresent(transaction.feeCurrency) ||
|
53
|
+
isPresent(transaction.gatewayFeeRecipient) ||
|
54
|
+
isPresent(transaction.gatewayFee))
|
55
|
+
)
|
56
|
+
}
|
57
|
+
|
58
|
+
export function isCIP64(
|
59
|
+
transaction: CeloTransactionSerializable | CeloTransactionRequest,
|
60
|
+
): transaction is TransactionSerializableCIP64 {
|
61
|
+
// Enable end-user to force the tx to be considered as a cip64
|
62
|
+
if (transaction.type === 'cip64') {
|
63
|
+
return true
|
64
|
+
}
|
65
|
+
|
66
|
+
return (
|
67
|
+
isEIP1559(transaction) &&
|
68
|
+
isPresent(transaction.feeCurrency) &&
|
69
|
+
isEmpty(transaction.gatewayFee) &&
|
70
|
+
isEmpty(transaction.gatewayFeeRecipient)
|
71
|
+
)
|
72
|
+
}
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '0.0.0-main.
|
1
|
+
export const version = '0.0.0-main.20231105T204445'
|
package/package.json
CHANGED