@bradthomasbrown/75bb14 1.0.1 → 2.0.0
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/75bb14.d.ts +6 -8
- package/dist/75bb14.d.ts.map +1 -1
- package/dist/75bb14.js +8 -68
- package/dist/concrete/dd2554.d.ts +179 -0
- package/dist/concrete/dd2554.d.ts.map +1 -0
- package/dist/concrete/dd2554.js +21 -0
- package/dist/concrete/e4e1df.d.ts +7 -21
- package/dist/concrete/e4e1df.d.ts.map +1 -1
- package/dist/concrete/e4e1df.js +19 -41
- package/dist/lib/sendLegacyTransaction.d.ts +4 -0
- package/dist/lib/sendLegacyTransaction.d.ts.map +1 -0
- package/dist/lib/sendLegacyTransaction.js +16 -0
- package/package.json +3 -2
package/dist/75bb14.d.ts
CHANGED
|
@@ -12,15 +12,13 @@ import { Node } from "@bradthomasbrown/ejra";
|
|
|
12
12
|
* @param _91_ - A synchronization barrier function that can be used to batch and execute the above promises, if the aforementioned functions don't already do so.
|
|
13
13
|
* @param _fe_ - A function that implements "waiting" for some transaction hash.
|
|
14
14
|
*/
|
|
15
|
-
declare function _75bb14_<
|
|
16
|
-
new (
|
|
17
|
-
entity: InstanceType<typeof EvmEntity>;
|
|
15
|
+
declare function _75bb14_<_54_, _b0_ extends Array<any>, _10_ extends Array<any>, _51_, _24_>(_8c_: (state: _54_, node: InstanceType<typeof Node>, entity: InstanceType<typeof EvmEntity>, ...args: _b0_) => _51_, _ff_: (state: _54_, node: InstanceType<typeof Node>, entity: InstanceType<typeof EvmEntity>, ...args: _10_) => _24_): {
|
|
16
|
+
new (state: _54_, node: InstanceType<typeof Node>, entity: InstanceType<typeof EvmEntity>): {
|
|
18
17
|
node: InstanceType<typeof Node>;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
send
|
|
22
|
-
|
|
23
|
-
wait(transactionHash: string, ...args: _b6_): Promise<R>;
|
|
18
|
+
entity: InstanceType<typeof EvmEntity>;
|
|
19
|
+
state: _54_;
|
|
20
|
+
send: (...args: _b0_) => _51_;
|
|
21
|
+
wait: (...args: _10_) => _24_;
|
|
24
22
|
};
|
|
25
23
|
};
|
|
26
24
|
export { _75bb14_ };
|
package/dist/75bb14.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"75bb14.d.ts","sourceRoot":"","sources":["../src/75bb14.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"75bb14.d.ts","sourceRoot":"","sources":["../src/75bb14.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAG7C;;;;;;;;;;;GAWG;AACH,iBAAS,QAAQ,CACb,IAAI,EACJ,IAAI,SAAS,KAAK,CAAC,GAAG,CAAC,EACvB,IAAI,SAAS,KAAK,CAAC,GAAG,CAAC,EACvB,IAAI,EACJ,IAAI,EAEJ,IAAI,EAAC,CAAC,KAAK,EAAC,IAAI,EAAE,IAAI,EAAC,YAAY,CAAC,OAAO,IAAI,CAAC,EAAE,MAAM,EAAC,YAAY,CAAC,OAAO,SAAS,CAAC,EAAE,GAAG,IAAI,EAAC,IAAI,KAAG,IAAI,EAC5G,IAAI,EAAC,CAAC,KAAK,EAAC,IAAI,EAAE,IAAI,EAAC,YAAY,CAAC,OAAO,IAAI,CAAC,EAAE,MAAM,EAAC,YAAY,CAAC,OAAO,SAAS,CAAC,EAAE,GAAG,IAAI,EAAC,IAAI,KAAG,IAAI;gBAUtF,IAAI,QAAO,YAAY,CAAC,OAAO,IAAI,CAAC,UAAS,YAAY,CAAC,OAAO,SAAS,CAAC;cANxF,YAAY,CAAC,OAAO,IAAI,CAAC;gBACvB,YAAY,CAAC,OAAO,SAAS,CAAC;eAC/B,IAAI;cACL,CAAC,GAAG,IAAI,EAAC,IAAI,KAAG,IAAI;cACpB,CAAC,GAAG,IAAI,EAAC,IAAI,KAAG,IAAI;;EAWhC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/75bb14.js
CHANGED
|
@@ -1,36 +1,8 @@
|
|
|
1
|
-
// <SCHIZO-NOTES feel-free-to-ignore>
|
|
2
|
-
// for testing, we want to make sure our balance is high enough for some set of transactions
|
|
3
|
-
// we need a chain id to make a transaction
|
|
4
|
-
// we need a gas estimate to set a gas limit for a legacy transaction
|
|
5
|
-
// we'll also need this for other transaction types
|
|
6
|
-
// we'll want the gas price
|
|
7
|
-
// we may need this or other information for other transaction types
|
|
8
|
-
// then we'll produce a signed transaction hex which can be sent via json rpc
|
|
9
|
-
// then we think we'll want some sort of a sync primitive in this sequence
|
|
10
|
-
// so maybe we want a "sync request handler"
|
|
11
|
-
// we're thinking GPU-style command queue stuff around here
|
|
12
|
-
// then we'll want to use some of the data from the sequence so far to build the next part of the sequence
|
|
13
|
-
// in GPU programming, i think we'd just have a memory block
|
|
14
|
-
// previous sequence block writes to the memory block
|
|
15
|
-
// later sequence block reads from the memory block
|
|
16
|
-
// maybe here we just have some typed object, loosely representing a struct
|
|
17
|
-
// we keep thinking that we want to write programs here
|
|
18
|
-
// opcodes
|
|
19
|
-
// but certain kinds of odd programs
|
|
20
|
-
// where opcodes may be asynchronous, then we have synchonization primitives or "barriers"
|
|
21
|
-
// so that we are effectively pipelining operations
|
|
22
|
-
// "machine" then will go through a sequence of opcodes until it hits a barrier then it will try to
|
|
23
|
-
// satisfy each opcode
|
|
24
|
-
// one such opcode may be "gasprice"
|
|
25
|
-
// one may be "sign EVM transaction (return hex)"
|
|
26
|
-
// one may be "sign EVM transaction given 'input' return hex"
|
|
27
|
-
// maybe we have an opcode "set gas price acquisition function"?
|
|
28
|
-
// maybe we have an opcode "update (to some satsifaction policy) gas price"?
|
|
29
|
-
// <SCHIZO-NOTES feel-free-to-ignore/>
|
|
30
1
|
import { encode } from "@bradthomasbrown/rlp";
|
|
31
2
|
import { keccak256 } from "@bradthomasbrown/keccak/keccak256";
|
|
32
3
|
import { EvmEntity } from "@bradthomasbrown/entity/evm";
|
|
33
4
|
import { Node } from "@bradthomasbrown/ejra";
|
|
5
|
+
import sendLegacyTransaction from "./lib/sendLegacyTransaction.js";
|
|
34
6
|
/**
|
|
35
7
|
* A function which returns a class that can wrap an EvmEntity (`@bradthomasbrown/entity/evm`) and a Node (`@bradthomasbrown/ejra`)
|
|
36
8
|
* to make interacting with an EVM chain under an identity more convenient.
|
|
@@ -43,51 +15,19 @@ import { Node } from "@bradthomasbrown/ejra";
|
|
|
43
15
|
* @param _91_ - A synchronization barrier function that can be used to batch and execute the above promises, if the aforementioned functions don't already do so.
|
|
44
16
|
* @param _fe_ - A function that implements "waiting" for some transaction hash.
|
|
45
17
|
*/
|
|
46
|
-
function _75bb14_(
|
|
18
|
+
function _75bb14_(_8c_, _ff_) {
|
|
47
19
|
return class _57461f_ {
|
|
48
|
-
entity;
|
|
49
20
|
node;
|
|
21
|
+
entity;
|
|
50
22
|
state;
|
|
51
|
-
|
|
23
|
+
send;
|
|
24
|
+
wait;
|
|
25
|
+
constructor(state, node, entity) {
|
|
52
26
|
this.entity = entity;
|
|
53
27
|
this.node = node;
|
|
54
28
|
this.state = state;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
_88_, // calldata/input/data/bytecode string
|
|
58
|
-
value = 0n) {
|
|
59
|
-
const _8d_ = _a6_(this); // return nonce promise
|
|
60
|
-
const _ba_ = _66_(this); // return gas price promise
|
|
61
|
-
const _39_ = _f6_(this, _e2_, _88_, value); // return gas limit promise
|
|
62
|
-
const to = _a9_(_e2_); // derive the final "to"
|
|
63
|
-
const input = _c5_(_88_); // derive the final "data"/"input"
|
|
64
|
-
const _cd_ = _e4_(this); // return chain id promise
|
|
65
|
-
_91_(); // synchronization barrier trigger function
|
|
66
|
-
const [nonce, gasPrice, gasLimit, chainId] = await Promise.all([_8d_, _ba_, _39_, _cd_]);
|
|
67
|
-
const rawTxArray = [nonce, gasPrice, gasLimit, to, value, input, chainId, 0n, 0n];
|
|
68
|
-
const rawTxEncoded = encode(rawTxArray);
|
|
69
|
-
const signature = this.entity.sign(rawTxEncoded);
|
|
70
|
-
const _7f_ = chainId * 2n + 35n + signature.v;
|
|
71
|
-
const signedTxArray = [...rawTxArray.slice(0, 6), _7f_, signature.r, signature.s];
|
|
72
|
-
const signedTxEncoded = encode(signedTxArray);
|
|
73
|
-
const signedTxHex = `0x${signedTxEncoded.toHex()}`;
|
|
74
|
-
const signedTxHash = `0x${keccak256(signedTxEncoded).toHex()}`;
|
|
75
|
-
const promise = this.node.sendRawTransaction(signedTxHex);
|
|
76
|
-
return [nonce, signedTxHash, promise];
|
|
77
|
-
}
|
|
78
|
-
async send(to, input, value = 0n) {
|
|
79
|
-
const [_nonce, signedTxHash, promise] = await this._78_(to, input, value);
|
|
80
|
-
return [signedTxHash, promise];
|
|
81
|
-
}
|
|
82
|
-
async deploy(input, value = 0n) {
|
|
83
|
-
const [nonce, signedTxHash, promise] = await this._78_(null, input, value);
|
|
84
|
-
const _09_ = encode([Uint8Array.fromHex(this.entity.address.slice(2)), nonce]);
|
|
85
|
-
const _c0_ = keccak256(_09_);
|
|
86
|
-
const contractAddress = `0x${_c0_.slice(12).toHex()}`;
|
|
87
|
-
return [contractAddress, signedTxHash, promise];
|
|
88
|
-
}
|
|
89
|
-
wait(transactionHash, ...args) {
|
|
90
|
-
return _fe_(this, transactionHash, ...args);
|
|
29
|
+
this.send = function send(...args) { return _8c_(state, node, entity, ...args); };
|
|
30
|
+
this.wait = function wait(...args) { return _ff_(state, node, entity, ...args); };
|
|
91
31
|
}
|
|
92
32
|
};
|
|
93
33
|
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
declare const _dd2554_: {
|
|
2
|
+
new (state: null, node: InstanceType<typeof import("@bradthomasbrown/ejra").Node>, entity: InstanceType<{
|
|
3
|
+
new (secret: bigint): {
|
|
4
|
+
_6e_: {
|
|
5
|
+
T: import("@bradthomasbrown/finite-domain").FiniteDomain;
|
|
6
|
+
_a7_: (M: Uint8Array) => bigint;
|
|
7
|
+
sign: (d: bigint, M: Uint8Array) => {
|
|
8
|
+
r: bigint;
|
|
9
|
+
s: bigint;
|
|
10
|
+
v: bigint;
|
|
11
|
+
};
|
|
12
|
+
recover: (S: {
|
|
13
|
+
r: bigint;
|
|
14
|
+
s: bigint;
|
|
15
|
+
v: bigint;
|
|
16
|
+
}, M: Uint8Array) => import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
17
|
+
verify(Q: import("@bradthomasbrown/finite-curve").FinitePoint, S: {
|
|
18
|
+
r: bigint;
|
|
19
|
+
s: bigint;
|
|
20
|
+
v: bigint;
|
|
21
|
+
}, M: Uint8Array): boolean;
|
|
22
|
+
};
|
|
23
|
+
secret: bigint;
|
|
24
|
+
sign: (M: Uint8Array) => {
|
|
25
|
+
r: bigint;
|
|
26
|
+
s: bigint;
|
|
27
|
+
v: bigint;
|
|
28
|
+
};
|
|
29
|
+
_public: undefined | import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
30
|
+
_publicHex: undefined | string;
|
|
31
|
+
_hexlen: undefined | number;
|
|
32
|
+
_address: string | undefined;
|
|
33
|
+
get public(): import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
34
|
+
get hashlen(): number;
|
|
35
|
+
get publicHex(): string;
|
|
36
|
+
get address(): string;
|
|
37
|
+
};
|
|
38
|
+
random(): {
|
|
39
|
+
_6e_: {
|
|
40
|
+
T: import("@bradthomasbrown/finite-domain").FiniteDomain;
|
|
41
|
+
_a7_: (M: Uint8Array) => bigint;
|
|
42
|
+
sign: (d: bigint, M: Uint8Array) => {
|
|
43
|
+
r: bigint;
|
|
44
|
+
s: bigint;
|
|
45
|
+
v: bigint;
|
|
46
|
+
};
|
|
47
|
+
recover: (S: {
|
|
48
|
+
r: bigint;
|
|
49
|
+
s: bigint;
|
|
50
|
+
v: bigint;
|
|
51
|
+
}, M: Uint8Array) => import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
52
|
+
verify(Q: import("@bradthomasbrown/finite-curve").FinitePoint, S: {
|
|
53
|
+
r: bigint;
|
|
54
|
+
s: bigint;
|
|
55
|
+
v: bigint;
|
|
56
|
+
}, M: Uint8Array): boolean;
|
|
57
|
+
};
|
|
58
|
+
secret: bigint;
|
|
59
|
+
sign: (M: Uint8Array) => {
|
|
60
|
+
r: bigint;
|
|
61
|
+
s: bigint;
|
|
62
|
+
v: bigint;
|
|
63
|
+
};
|
|
64
|
+
_public: undefined | import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
65
|
+
_publicHex: undefined | string;
|
|
66
|
+
_hexlen: undefined | number;
|
|
67
|
+
_address: string | undefined;
|
|
68
|
+
get public(): import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
69
|
+
get hashlen(): number;
|
|
70
|
+
get publicHex(): string;
|
|
71
|
+
get address(): string;
|
|
72
|
+
};
|
|
73
|
+
}>): {
|
|
74
|
+
node: InstanceType<typeof import("@bradthomasbrown/ejra").Node>;
|
|
75
|
+
entity: InstanceType<{
|
|
76
|
+
new (secret: bigint): {
|
|
77
|
+
_6e_: {
|
|
78
|
+
T: import("@bradthomasbrown/finite-domain").FiniteDomain;
|
|
79
|
+
_a7_: (M: Uint8Array) => bigint;
|
|
80
|
+
sign: (d: bigint, M: Uint8Array) => {
|
|
81
|
+
r: bigint;
|
|
82
|
+
s: bigint;
|
|
83
|
+
v: bigint;
|
|
84
|
+
};
|
|
85
|
+
recover: (S: {
|
|
86
|
+
r: bigint;
|
|
87
|
+
s: bigint;
|
|
88
|
+
v: bigint;
|
|
89
|
+
}, M: Uint8Array) => import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
90
|
+
verify(Q: import("@bradthomasbrown/finite-curve").FinitePoint, S: {
|
|
91
|
+
r: bigint;
|
|
92
|
+
s: bigint;
|
|
93
|
+
v: bigint;
|
|
94
|
+
}, M: Uint8Array): boolean;
|
|
95
|
+
};
|
|
96
|
+
secret: bigint;
|
|
97
|
+
sign: (M: Uint8Array) => {
|
|
98
|
+
r: bigint;
|
|
99
|
+
s: bigint;
|
|
100
|
+
v: bigint;
|
|
101
|
+
};
|
|
102
|
+
_public: undefined | import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
103
|
+
_publicHex: undefined | string;
|
|
104
|
+
_hexlen: undefined | number;
|
|
105
|
+
_address: string | undefined;
|
|
106
|
+
get public(): import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
107
|
+
get hashlen(): number;
|
|
108
|
+
get publicHex(): string;
|
|
109
|
+
get address(): string;
|
|
110
|
+
};
|
|
111
|
+
random(): {
|
|
112
|
+
_6e_: {
|
|
113
|
+
T: import("@bradthomasbrown/finite-domain").FiniteDomain;
|
|
114
|
+
_a7_: (M: Uint8Array) => bigint;
|
|
115
|
+
sign: (d: bigint, M: Uint8Array) => {
|
|
116
|
+
r: bigint;
|
|
117
|
+
s: bigint;
|
|
118
|
+
v: bigint;
|
|
119
|
+
};
|
|
120
|
+
recover: (S: {
|
|
121
|
+
r: bigint;
|
|
122
|
+
s: bigint;
|
|
123
|
+
v: bigint;
|
|
124
|
+
}, M: Uint8Array) => import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
125
|
+
verify(Q: import("@bradthomasbrown/finite-curve").FinitePoint, S: {
|
|
126
|
+
r: bigint;
|
|
127
|
+
s: bigint;
|
|
128
|
+
v: bigint;
|
|
129
|
+
}, M: Uint8Array): boolean;
|
|
130
|
+
};
|
|
131
|
+
secret: bigint;
|
|
132
|
+
sign: (M: Uint8Array) => {
|
|
133
|
+
r: bigint;
|
|
134
|
+
s: bigint;
|
|
135
|
+
v: bigint;
|
|
136
|
+
};
|
|
137
|
+
_public: undefined | import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
138
|
+
_publicHex: undefined | string;
|
|
139
|
+
_hexlen: undefined | number;
|
|
140
|
+
_address: string | undefined;
|
|
141
|
+
get public(): import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
142
|
+
get hashlen(): number;
|
|
143
|
+
get publicHex(): string;
|
|
144
|
+
get address(): string;
|
|
145
|
+
};
|
|
146
|
+
}>;
|
|
147
|
+
state: null;
|
|
148
|
+
send: (gasLimit: bigint, to: string | null, value: bigint, input: ArrayBuffer | null) => Promise<[string, Promise<string>]>;
|
|
149
|
+
wait: (transactionHash: string) => Promise<{
|
|
150
|
+
transactionHash: string;
|
|
151
|
+
transactionIndex: bigint;
|
|
152
|
+
blockHash: string;
|
|
153
|
+
blockNumber: bigint;
|
|
154
|
+
from: string;
|
|
155
|
+
to: string | null;
|
|
156
|
+
cumulativeGasUsed: bigint;
|
|
157
|
+
effectiveGasPrice: bigint;
|
|
158
|
+
gasUsed: bigint;
|
|
159
|
+
contractAddress: string | null;
|
|
160
|
+
logs: {
|
|
161
|
+
removed: boolean;
|
|
162
|
+
logIndex: bigint | null;
|
|
163
|
+
transactionIndex: bigint | null;
|
|
164
|
+
transactionHash: string | null;
|
|
165
|
+
blockHash: string | null;
|
|
166
|
+
blockNumber: bigint | null;
|
|
167
|
+
address: string;
|
|
168
|
+
data: string[];
|
|
169
|
+
topics: string[];
|
|
170
|
+
}[];
|
|
171
|
+
logsBloom: string;
|
|
172
|
+
type: number;
|
|
173
|
+
root: string | null;
|
|
174
|
+
status: number | null;
|
|
175
|
+
} | undefined>;
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
export { _dd2554_ };
|
|
179
|
+
//# sourceMappingURL=dd2554.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dd2554.d.ts","sourceRoot":"","sources":["../../src/concrete/dd2554.ts"],"names":[],"mappings":"AAkCA,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAuB,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { _75bb14_ } from "../75bb14.js";
|
|
2
|
+
import sendLegacyTransaction from "../lib/sendLegacyTransaction.js";
|
|
3
|
+
async function send(_state, node, entity, gasLimit, to, value, input) {
|
|
4
|
+
const nonce = await node.getTransactionCount(entity.address, "latest");
|
|
5
|
+
const gasPrice = await node.gasPrice();
|
|
6
|
+
const inputBytes = input === null ? new Uint8Array() : new Uint8Array(input);
|
|
7
|
+
const toBytes = to !== null ? Uint8Array.fromHex(to.slice(2)) : new Uint8Array();
|
|
8
|
+
const chainId = await node.chainId();
|
|
9
|
+
return sendLegacyTransaction(node, entity, nonce, gasPrice, gasLimit, toBytes, value, inputBytes, chainId);
|
|
10
|
+
}
|
|
11
|
+
async function wait(_state, node, _entity, transactionHash) {
|
|
12
|
+
let receipt;
|
|
13
|
+
for (let i = 0; i < 5; i++) {
|
|
14
|
+
receipt = await node.getTransactionReceipt(transactionHash);
|
|
15
|
+
if (receipt !== null)
|
|
16
|
+
return receipt;
|
|
17
|
+
await new Promise(r => setTimeout(r, 250));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const _dd2554_ = _75bb14_(send, wait);
|
|
21
|
+
export { _dd2554_ };
|
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
import type { Node } from "@bradthomasbrown/ejra";
|
|
2
|
-
/**
|
|
3
|
-
* A simple 75bb14 which will:
|
|
4
|
-
* - get the most recently available nonce from the node for each transaction
|
|
5
|
-
* - get the most recently available gas price from the node for each transaction
|
|
6
|
-
* - get the gas estimate from the node for each transaction
|
|
7
|
-
* - get the chain id from the node for each transaction
|
|
8
|
-
* without batching,
|
|
9
|
-
* and will perform a simple 5-attempt 250-ms delay poll for a transaction reciept from the node as a wait condition.
|
|
10
|
-
*
|
|
11
|
-
* "Good enough" for local development work, maybe.
|
|
12
|
-
*/
|
|
13
1
|
declare const _e4e1df_: {
|
|
14
|
-
new (entity: InstanceType<{
|
|
2
|
+
new (state: null, node: InstanceType<typeof import("@bradthomasbrown/ejra").Node>, entity: InstanceType<{
|
|
15
3
|
new (secret: bigint): {
|
|
16
4
|
_6e_: {
|
|
17
5
|
T: import("@bradthomasbrown/finite-domain").FiniteDomain;
|
|
@@ -82,7 +70,8 @@ declare const _e4e1df_: {
|
|
|
82
70
|
get publicHex(): string;
|
|
83
71
|
get address(): string;
|
|
84
72
|
};
|
|
85
|
-
}
|
|
73
|
+
}>): {
|
|
74
|
+
node: InstanceType<typeof import("@bradthomasbrown/ejra").Node>;
|
|
86
75
|
entity: InstanceType<{
|
|
87
76
|
new (secret: bigint): {
|
|
88
77
|
_6e_: {
|
|
@@ -155,12 +144,9 @@ declare const _e4e1df_: {
|
|
|
155
144
|
get address(): string;
|
|
156
145
|
};
|
|
157
146
|
}>;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
send(to: null | string, input: null | string, value?: bigint): Promise<[string, Promise<string>]>;
|
|
162
|
-
deploy(input: string, value?: bigint): Promise<[string, string, Promise<string>]>;
|
|
163
|
-
wait(transactionHash: string): Promise<{
|
|
147
|
+
state: null;
|
|
148
|
+
send: (to: string | null, value: bigint, input: ArrayBuffer | null) => Promise<[string, Promise<string>]>;
|
|
149
|
+
wait: (transactionHash: string) => Promise<{
|
|
164
150
|
transactionHash: string;
|
|
165
151
|
transactionIndex: bigint;
|
|
166
152
|
blockHash: string;
|
|
@@ -186,7 +172,7 @@ declare const _e4e1df_: {
|
|
|
186
172
|
type: number;
|
|
187
173
|
root: string | null;
|
|
188
174
|
status: number | null;
|
|
189
|
-
}>;
|
|
175
|
+
} | undefined>;
|
|
190
176
|
};
|
|
191
177
|
};
|
|
192
178
|
export { _e4e1df_ };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"e4e1df.d.ts","sourceRoot":"","sources":["../../src/concrete/e4e1df.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"e4e1df.d.ts","sourceRoot":"","sources":["../../src/concrete/e4e1df.ts"],"names":[],"mappings":"AAsCA,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAuB,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/concrete/e4e1df.js
CHANGED
|
@@ -1,50 +1,28 @@
|
|
|
1
1
|
import { _75bb14_ } from "../75bb14.js";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import sendLegacyTransaction from "../lib/sendLegacyTransaction.js";
|
|
3
|
+
async function send(_state, node, entity, to, value, input) {
|
|
4
|
+
const nonce = await node.getTransactionCount(entity.address, "latest");
|
|
5
|
+
const gasPrice = await node.gasPrice();
|
|
6
|
+
const inputBytes = input === null ? new Uint8Array() : new Uint8Array(input);
|
|
7
|
+
const inputHex = `0x${inputBytes.toHex()}`;
|
|
8
|
+
let _ca_ = { from: entity.address, value: `0x${value.toString(16)}` };
|
|
9
|
+
if (to !== null)
|
|
10
|
+
_ca_.to = to;
|
|
11
|
+
if (input !== null)
|
|
12
|
+
_ca_.input = inputHex;
|
|
13
|
+
const gasLimit = await node.estimateGas(_ca_, "latest");
|
|
14
|
+
const toBytes = to !== null ? Uint8Array.fromHex(to.slice(2)) : new Uint8Array();
|
|
15
|
+
const chainId = await node.chainId();
|
|
16
|
+
return sendLegacyTransaction(node, entity, nonce, gasPrice, gasLimit, toBytes, value, inputBytes, chainId);
|
|
4
17
|
}
|
|
5
|
-
function
|
|
6
|
-
return _ce_.node.gasPrice();
|
|
7
|
-
}
|
|
8
|
-
function _422b72_(_d6_, _fa_, _01_) {
|
|
9
|
-
const _5b_ = {};
|
|
10
|
-
_5b_.from = _d6_.entity.address;
|
|
11
|
-
if (_fa_ !== null)
|
|
12
|
-
_5b_.to = _fa_;
|
|
13
|
-
if (_01_ !== null)
|
|
14
|
-
_5b_.input = _01_;
|
|
15
|
-
return _d6_.node.estimateGas(_5b_, "latest");
|
|
16
|
-
}
|
|
17
|
-
function _e752dc_(_80_) {
|
|
18
|
-
if (_80_ === null)
|
|
19
|
-
return new Uint8Array();
|
|
20
|
-
if (_80_.startsWith("0x"))
|
|
21
|
-
return Uint8Array.fromHex(_80_.slice(2));
|
|
22
|
-
return Uint8Array.fromHex(_80_);
|
|
23
|
-
}
|
|
24
|
-
function _e4aeae_(_ef_) {
|
|
25
|
-
return _ef_.node.chainId();
|
|
26
|
-
}
|
|
27
|
-
function _3c6f98_() { }
|
|
28
|
-
async function _022a28_(_ad_, _85_) {
|
|
18
|
+
async function wait(_state, node, _entity, transactionHash) {
|
|
29
19
|
let receipt;
|
|
30
20
|
for (let i = 0; i < 5; i++) {
|
|
31
|
-
receipt = await
|
|
32
|
-
if (receipt
|
|
21
|
+
receipt = await node.getTransactionReceipt(transactionHash);
|
|
22
|
+
if (receipt !== null)
|
|
33
23
|
return receipt;
|
|
34
24
|
await new Promise(r => setTimeout(r, 250));
|
|
35
25
|
}
|
|
36
|
-
throw new Error(`failed to wait for receipt from transaction hash: ${_85_}`);
|
|
37
26
|
}
|
|
38
|
-
|
|
39
|
-
* A simple 75bb14 which will:
|
|
40
|
-
* - get the most recently available nonce from the node for each transaction
|
|
41
|
-
* - get the most recently available gas price from the node for each transaction
|
|
42
|
-
* - get the gas estimate from the node for each transaction
|
|
43
|
-
* - get the chain id from the node for each transaction
|
|
44
|
-
* without batching,
|
|
45
|
-
* and will perform a simple 5-attempt 250-ms delay poll for a transaction reciept from the node as a wait condition.
|
|
46
|
-
*
|
|
47
|
-
* "Good enough" for local development work, maybe.
|
|
48
|
-
*/
|
|
49
|
-
const _e4e1df_ = _75bb14_(_4403dc_, _0da055_, _422b72_, _e752dc_, _e752dc_, _e4aeae_, _3c6f98_, _022a28_);
|
|
27
|
+
const _e4e1df_ = _75bb14_(send, wait);
|
|
50
28
|
export { _e4e1df_ };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { EvmEntity } from "@bradthomasbrown/entity/evm";
|
|
2
|
+
import { Node } from "@bradthomasbrown/ejra";
|
|
3
|
+
export default function (node: InstanceType<typeof Node>, entity: InstanceType<typeof EvmEntity>, nonce: bigint, gasPrice: bigint, gasLimit: bigint, to: Uint8Array, value: bigint, input: Uint8Array, chainId: bigint): [string, Promise<string>];
|
|
4
|
+
//# sourceMappingURL=sendLegacyTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendLegacyTransaction.d.ts","sourceRoot":"","sources":["../../src/lib/sendLegacyTransaction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C,MAAM,CAAC,OAAO,WACV,IAAI,EAAC,YAAY,CAAC,OAAO,IAAI,CAAC,EAC9B,MAAM,EAAC,YAAY,CAAC,OAAO,SAAS,CAAC,EACrC,KAAK,EAAC,MAAM,EACZ,QAAQ,EAAC,MAAM,EACf,QAAQ,EAAC,MAAM,EACf,EAAE,EAAC,UAAU,EACb,KAAK,EAAC,MAAM,EACZ,KAAK,EAAC,UAAU,EAChB,OAAO,EAAC,MAAM,GAChB,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAW1B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { encode } from "@bradthomasbrown/rlp";
|
|
2
|
+
import { keccak256 } from "@bradthomasbrown/keccak/keccak256";
|
|
3
|
+
import { EvmEntity } from "@bradthomasbrown/entity/evm";
|
|
4
|
+
import { Node } from "@bradthomasbrown/ejra";
|
|
5
|
+
export default function (node, entity, nonce, gasPrice, gasLimit, to, value, input, chainId) {
|
|
6
|
+
const rawTxArray = [nonce, gasPrice, gasLimit, to, value, input, chainId, 0n, 0n];
|
|
7
|
+
const rawTxEncoded = encode(rawTxArray);
|
|
8
|
+
const signature = entity.sign(rawTxEncoded);
|
|
9
|
+
const _7f_ = chainId * 2n + 35n + signature.v;
|
|
10
|
+
const signedTxArray = [...rawTxArray.slice(0, 6), _7f_, signature.r, signature.s];
|
|
11
|
+
const signedTxEncoded = encode(signedTxArray);
|
|
12
|
+
const signedTxHex = `0x${signedTxEncoded.toHex()}`;
|
|
13
|
+
const signedTxHash = `0x${keccak256(signedTxEncoded).toHex()}`;
|
|
14
|
+
const promise = node.sendRawTransaction(signedTxHex);
|
|
15
|
+
return [signedTxHash, promise];
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bradthomasbrown/75bb14",
|
|
3
3
|
"description": "A light, flexible, convenience layer library for `EvmEntity`s and (EVM) Nodes in JavaScript/TypeScript.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"author": "Brad Brown <https://t.me/bradthomasbrown>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
],
|
|
10
10
|
"exports": {
|
|
11
11
|
".": "./dist/75bb14.js",
|
|
12
|
-
"./e4e1df": "./dist/concrete/e4e1df.js"
|
|
12
|
+
"./e4e1df": "./dist/concrete/e4e1df.js",
|
|
13
|
+
"./dd2554": "./dist/concrete/dd2554.js"
|
|
13
14
|
},
|
|
14
15
|
"dependencies": {
|
|
15
16
|
"@bradthomasbrown/ecdsa": "^2.0.2",
|