@bradthomasbrown/75bb14 1.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/README.md +46 -0
- package/dist/75bb14.d.ts +27 -0
- package/dist/75bb14.d.ts.map +1 -0
- package/dist/75bb14.js +94 -0
- package/dist/concrete/e4e1df.d.ts +193 -0
- package/dist/concrete/e4e1df.d.ts.map +1 -0
- package/dist/concrete/e4e1df.js +50 -0
- package/package.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# 75bb14
|
|
2
|
+
This is a simple, convenience library for combining an EvmEntity and a Node in TypeScript/JavaScript.
|
|
3
|
+
|
|
4
|
+
## Why?
|
|
5
|
+
An EvmEntity, to us, is just an EVM-flavored secpk256k1-and-keccak256 powered ECDSA thin wrapper.
|
|
6
|
+
A Node is, to us, a wrapper over some EVM node (via JSON RPC API).
|
|
7
|
+
It would seem natural then that to make these things more convenient to use together, that we combine the ideas, but somewhere separate (here).
|
|
8
|
+
An ECDSA-focused concept like EvmEntity shouldn't be working in terms of EVM chain primitives like the `from`, `to`, `input` fields of some `transaction`, so this library bridges that gap so those simpler EVM chain primitives can be used.
|
|
9
|
+
It also is a place for putting features like the ability to "wait" for a transaction (or to define what that means) and to define behaviors for how transacting should be done.
|
|
10
|
+
For example, how do we want to manage the nonce? How do we want to manage the gas price? How do we want a consumer of a `75bb14`-generated class instance to specify how much gas they want to use?
|
|
11
|
+
One can use the `75bb14` function to generate classes whose instances act in simple or complex ways, handling these matters.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
```sh
|
|
15
|
+
npm i @bradthomasbrown/75bb14
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
```js
|
|
20
|
+
import { _e4e1df_ } from "@bradthomasbrown/75bb14/e4e1df";
|
|
21
|
+
import { _900ef2_ } from "@bradthomasbrown/900ef2";
|
|
22
|
+
import { EvmEntity } from "@bradthomasbrown/entity/evm";
|
|
23
|
+
|
|
24
|
+
const port = 8545;
|
|
25
|
+
// 900ef2 is a sort of "containerized EVM node manager". can work with anvil, geth, etc.
|
|
26
|
+
const Anvil = _900ef2_("ghcr.io/foundry-rs/foundry:v1.5.1", `anvil -b 1 -p ${port} --host 0.0.0.0`);
|
|
27
|
+
const node = await Anvil.make(port);
|
|
28
|
+
const alice = EvmEntity.random();
|
|
29
|
+
const bob = EvmEntity.random();
|
|
30
|
+
// e4e1df is a sort of "combining layer of an EvmEntity (itself just a light layer of secp256k1 and keccak256 over ECDSA
|
|
31
|
+
// it knows nothing about transactions, just raw data) and a node (JSON RPC convenience)
|
|
32
|
+
const _d5_ = new _e4e1df_(alice, node, null);
|
|
33
|
+
await node.client.request("anvil_setBalance", [alice.address, "0x10000000000000"]);
|
|
34
|
+
const [aliceStartBalance, bobStartBalance] = await Promise.all([alice, bob].map(entity => node.getBalance(entity.address, "latest")));
|
|
35
|
+
// "promise" here is just the promise that the node has received and accepted our request, not necessarily a sign that the tranasction is in the blockhain at all
|
|
36
|
+
const [txhash, promise] = await _d5_.send(bob.address, null, 1000000000000n);
|
|
37
|
+
await Promise.all([promise, _d5_.wait(txhash)]);
|
|
38
|
+
const [aliceEndBalance, bobEndBalance] = await Promise.all([alice, bob].map(entity => node.getBalance(entity.address, "latest")));
|
|
39
|
+
console.log({ aliceStartBalance, bobStartBalance, aliceEndBalance, bobEndBalance });
|
|
40
|
+
/* {
|
|
41
|
+
aliceStartBalance: 4503599627370496n,
|
|
42
|
+
bobStartBalance: 0n,
|
|
43
|
+
aliceEndBalance: 4460599627370496n,
|
|
44
|
+
bobEndBalance: 1000000000000n,
|
|
45
|
+
} */
|
|
46
|
+
```
|
package/dist/75bb14.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { EvmEntity } from "@bradthomasbrown/entity/evm";
|
|
2
|
+
import { Node } from "@bradthomasbrown/ejra";
|
|
3
|
+
/**
|
|
4
|
+
* A function which returns a class that can wrap an EvmEntity (`@bradthomasbrown/entity/evm`) and a Node (`@bradthomasbrown/ejra`)
|
|
5
|
+
* to make interacting with an EVM chain under an identity more convenient.
|
|
6
|
+
* @param _a6_ - A function that returns a promise for the nonce to use for some transaction.
|
|
7
|
+
* @param _66_ - A function that returns a promise for the gas price to use for some transaction.
|
|
8
|
+
* @param _f6_ - A function that returns a promise for the gas limit to use for some transaction.
|
|
9
|
+
* @param _a9_ - A function that converts an address into a Uint8Array.
|
|
10
|
+
* @param _c5_ - A function that converts data/input/calldata into a Uint8Array.
|
|
11
|
+
* @param _e4_ - A function that returns a promise for the chain ID to use for some transaction.
|
|
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
|
+
* @param _fe_ - A function that implements "waiting" for some transaction hash.
|
|
14
|
+
*/
|
|
15
|
+
declare function _75bb14_<_b6_ extends unknown[], R, S>(_a6_: (_45_: InstanceType<ReturnType<typeof _75bb14_>>) => Promise<bigint>, _66_: (_84_: InstanceType<ReturnType<typeof _75bb14_>>) => Promise<bigint>, _f6_: (_28_: InstanceType<ReturnType<typeof _75bb14_>>, _89__: null | string, _01_: null | string, _bc_: bigint) => Promise<bigint>, _a9_: (_03_: null | string) => Uint8Array, _c5_: (_47_: null | string) => Uint8Array, _e4_: (_2b_: InstanceType<ReturnType<typeof _75bb14_>>) => Promise<bigint>, _91_: () => void, _fe_: (_d3_: InstanceType<ReturnType<typeof _75bb14_>>, _e7_: string, ..._2a_: _b6_) => Promise<R>): {
|
|
16
|
+
new (entity: InstanceType<typeof EvmEntity>, node: InstanceType<typeof Node>, state: S): {
|
|
17
|
+
entity: InstanceType<typeof EvmEntity>;
|
|
18
|
+
node: InstanceType<typeof Node>;
|
|
19
|
+
state: S;
|
|
20
|
+
_78_(_e2_: null | string, _88_: null | string, value?: bigint): Promise<[bigint, string, Promise<string>]>;
|
|
21
|
+
send(to: null | string, input: null | string, value?: bigint): Promise<[string, Promise<string>]>;
|
|
22
|
+
deploy(input: string, value?: bigint): Promise<[string, string, Promise<string>]>;
|
|
23
|
+
wait(transactionHash: string, ...args: _b6_): Promise<R>;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export { _75bb14_ };
|
|
27
|
+
//# sourceMappingURL=75bb14.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"75bb14.d.ts","sourceRoot":"","sources":["../src/75bb14.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C;;;;;;;;;;;GAWG;AACH,iBAAS,QAAQ,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,EAC1C,IAAI,EAAC,CAAC,IAAI,EAAC,YAAY,CAAC,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,KAAG,OAAO,CAAC,MAAM,CAAC,EACtE,IAAI,EAAC,CAAC,IAAI,EAAC,YAAY,CAAC,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,KAAG,OAAO,CAAC,MAAM,CAAC,EACtE,IAAI,EAAC,CAAC,IAAI,EAAC,YAAY,CAAC,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAC,IAAI,GAAC,MAAM,EAAE,IAAI,EAAC,IAAI,GAAC,MAAM,EAAE,IAAI,EAAC,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC,EACxH,IAAI,EAAC,CAAC,IAAI,EAAC,IAAI,GAAC,MAAM,KAAG,UAAU,EACnC,IAAI,EAAC,CAAC,IAAI,EAAC,IAAI,GAAC,MAAM,KAAG,UAAU,EACnC,IAAI,EAAC,CAAC,IAAI,EAAC,YAAY,CAAC,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,KAAG,OAAO,CAAC,MAAM,CAAC,EACtE,IAAI,EAAC,MAAI,IAAI,EACb,IAAI,EAAC,CAAC,IAAI,EAAC,YAAY,CAAC,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAC,MAAM,EAAE,GAAG,IAAI,EAAC,IAAI,KAAG,OAAO,CAAC,CAAC,CAAC;iBAUrE,YAAY,CAAC,OAAO,SAAS,CAAC,QAAO,YAAY,CAAC,OAAO,IAAI,CAAC,SAAQ,CAAC;gBANnF,YAAY,CAAC,OAAO,SAAS,CAAC;cAEhC,YAAY,CAAC,OAAO,IAAI,CAAC;eAExB,CAAC;mBASE,IAAI,GAAC,MAAM,QACX,IAAI,GAAC,MAAM;iBAuBN,IAAI,GAAC,MAAM,SAAQ,IAAI,GAAC,MAAM;sBAKzB,MAAM;8BAQJ,MAAM,WAAU,IAAI;;EAKhD;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/75bb14.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
import { encode } from "@bradthomasbrown/rlp";
|
|
31
|
+
import { keccak256 } from "@bradthomasbrown/keccak/keccak256";
|
|
32
|
+
import { EvmEntity } from "@bradthomasbrown/entity/evm";
|
|
33
|
+
import { Node } from "@bradthomasbrown/ejra";
|
|
34
|
+
/**
|
|
35
|
+
* A function which returns a class that can wrap an EvmEntity (`@bradthomasbrown/entity/evm`) and a Node (`@bradthomasbrown/ejra`)
|
|
36
|
+
* to make interacting with an EVM chain under an identity more convenient.
|
|
37
|
+
* @param _a6_ - A function that returns a promise for the nonce to use for some transaction.
|
|
38
|
+
* @param _66_ - A function that returns a promise for the gas price to use for some transaction.
|
|
39
|
+
* @param _f6_ - A function that returns a promise for the gas limit to use for some transaction.
|
|
40
|
+
* @param _a9_ - A function that converts an address into a Uint8Array.
|
|
41
|
+
* @param _c5_ - A function that converts data/input/calldata into a Uint8Array.
|
|
42
|
+
* @param _e4_ - A function that returns a promise for the chain ID to use for some transaction.
|
|
43
|
+
* @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
|
+
* @param _fe_ - A function that implements "waiting" for some transaction hash.
|
|
45
|
+
*/
|
|
46
|
+
function _75bb14_(_a6_, _66_, _f6_, _a9_, _c5_, _e4_, _91_, _fe_) {
|
|
47
|
+
return class _57461f_ {
|
|
48
|
+
entity;
|
|
49
|
+
node;
|
|
50
|
+
state;
|
|
51
|
+
constructor(entity, node, state) {
|
|
52
|
+
this.entity = entity;
|
|
53
|
+
this.node = node;
|
|
54
|
+
this.state = state;
|
|
55
|
+
}
|
|
56
|
+
async _78_(_e2_, // to string
|
|
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);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export { _75bb14_ };
|
|
@@ -0,0 +1,193 @@
|
|
|
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
|
+
declare const _e4e1df_: {
|
|
14
|
+
new (entity: InstanceType<{
|
|
15
|
+
new (secret: bigint): {
|
|
16
|
+
_6e_: {
|
|
17
|
+
T: import("@bradthomasbrown/finite-domain").FiniteDomain;
|
|
18
|
+
_a7_: (M: Uint8Array) => bigint;
|
|
19
|
+
sign: (d: bigint, M: Uint8Array) => {
|
|
20
|
+
r: bigint;
|
|
21
|
+
s: bigint;
|
|
22
|
+
v: bigint;
|
|
23
|
+
};
|
|
24
|
+
recover: (S: {
|
|
25
|
+
r: bigint;
|
|
26
|
+
s: bigint;
|
|
27
|
+
v: bigint;
|
|
28
|
+
}, M: Uint8Array) => import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
29
|
+
verify(Q: import("@bradthomasbrown/finite-curve").FinitePoint, S: {
|
|
30
|
+
r: bigint;
|
|
31
|
+
s: bigint;
|
|
32
|
+
v: bigint;
|
|
33
|
+
}, M: Uint8Array): boolean;
|
|
34
|
+
};
|
|
35
|
+
secret: bigint;
|
|
36
|
+
sign: (M: Uint8Array) => {
|
|
37
|
+
r: bigint;
|
|
38
|
+
s: bigint;
|
|
39
|
+
v: bigint;
|
|
40
|
+
};
|
|
41
|
+
_public: undefined | import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
42
|
+
_publicHex: undefined | string;
|
|
43
|
+
_hexlen: undefined | number;
|
|
44
|
+
_address: string | undefined;
|
|
45
|
+
get public(): import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
46
|
+
get hashlen(): number;
|
|
47
|
+
get publicHex(): string;
|
|
48
|
+
get address(): string;
|
|
49
|
+
};
|
|
50
|
+
random(): {
|
|
51
|
+
_6e_: {
|
|
52
|
+
T: import("@bradthomasbrown/finite-domain").FiniteDomain;
|
|
53
|
+
_a7_: (M: Uint8Array) => bigint;
|
|
54
|
+
sign: (d: bigint, M: Uint8Array) => {
|
|
55
|
+
r: bigint;
|
|
56
|
+
s: bigint;
|
|
57
|
+
v: bigint;
|
|
58
|
+
};
|
|
59
|
+
recover: (S: {
|
|
60
|
+
r: bigint;
|
|
61
|
+
s: bigint;
|
|
62
|
+
v: bigint;
|
|
63
|
+
}, M: Uint8Array) => import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
64
|
+
verify(Q: import("@bradthomasbrown/finite-curve").FinitePoint, S: {
|
|
65
|
+
r: bigint;
|
|
66
|
+
s: bigint;
|
|
67
|
+
v: bigint;
|
|
68
|
+
}, M: Uint8Array): boolean;
|
|
69
|
+
};
|
|
70
|
+
secret: bigint;
|
|
71
|
+
sign: (M: Uint8Array) => {
|
|
72
|
+
r: bigint;
|
|
73
|
+
s: bigint;
|
|
74
|
+
v: bigint;
|
|
75
|
+
};
|
|
76
|
+
_public: undefined | import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
77
|
+
_publicHex: undefined | string;
|
|
78
|
+
_hexlen: undefined | number;
|
|
79
|
+
_address: string | undefined;
|
|
80
|
+
get public(): import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
81
|
+
get hashlen(): number;
|
|
82
|
+
get publicHex(): string;
|
|
83
|
+
get address(): string;
|
|
84
|
+
};
|
|
85
|
+
}>, node: InstanceType<typeof Node>, state: unknown): {
|
|
86
|
+
entity: InstanceType<{
|
|
87
|
+
new (secret: bigint): {
|
|
88
|
+
_6e_: {
|
|
89
|
+
T: import("@bradthomasbrown/finite-domain").FiniteDomain;
|
|
90
|
+
_a7_: (M: Uint8Array) => bigint;
|
|
91
|
+
sign: (d: bigint, M: Uint8Array) => {
|
|
92
|
+
r: bigint;
|
|
93
|
+
s: bigint;
|
|
94
|
+
v: bigint;
|
|
95
|
+
};
|
|
96
|
+
recover: (S: {
|
|
97
|
+
r: bigint;
|
|
98
|
+
s: bigint;
|
|
99
|
+
v: bigint;
|
|
100
|
+
}, M: Uint8Array) => import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
101
|
+
verify(Q: import("@bradthomasbrown/finite-curve").FinitePoint, S: {
|
|
102
|
+
r: bigint;
|
|
103
|
+
s: bigint;
|
|
104
|
+
v: bigint;
|
|
105
|
+
}, M: Uint8Array): boolean;
|
|
106
|
+
};
|
|
107
|
+
secret: bigint;
|
|
108
|
+
sign: (M: Uint8Array) => {
|
|
109
|
+
r: bigint;
|
|
110
|
+
s: bigint;
|
|
111
|
+
v: bigint;
|
|
112
|
+
};
|
|
113
|
+
_public: undefined | import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
114
|
+
_publicHex: undefined | string;
|
|
115
|
+
_hexlen: undefined | number;
|
|
116
|
+
_address: string | undefined;
|
|
117
|
+
get public(): import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
118
|
+
get hashlen(): number;
|
|
119
|
+
get publicHex(): string;
|
|
120
|
+
get address(): string;
|
|
121
|
+
};
|
|
122
|
+
random(): {
|
|
123
|
+
_6e_: {
|
|
124
|
+
T: import("@bradthomasbrown/finite-domain").FiniteDomain;
|
|
125
|
+
_a7_: (M: Uint8Array) => bigint;
|
|
126
|
+
sign: (d: bigint, M: Uint8Array) => {
|
|
127
|
+
r: bigint;
|
|
128
|
+
s: bigint;
|
|
129
|
+
v: bigint;
|
|
130
|
+
};
|
|
131
|
+
recover: (S: {
|
|
132
|
+
r: bigint;
|
|
133
|
+
s: bigint;
|
|
134
|
+
v: bigint;
|
|
135
|
+
}, M: Uint8Array) => import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
136
|
+
verify(Q: import("@bradthomasbrown/finite-curve").FinitePoint, S: {
|
|
137
|
+
r: bigint;
|
|
138
|
+
s: bigint;
|
|
139
|
+
v: bigint;
|
|
140
|
+
}, M: Uint8Array): boolean;
|
|
141
|
+
};
|
|
142
|
+
secret: bigint;
|
|
143
|
+
sign: (M: Uint8Array) => {
|
|
144
|
+
r: bigint;
|
|
145
|
+
s: bigint;
|
|
146
|
+
v: bigint;
|
|
147
|
+
};
|
|
148
|
+
_public: undefined | import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
149
|
+
_publicHex: undefined | string;
|
|
150
|
+
_hexlen: undefined | number;
|
|
151
|
+
_address: string | undefined;
|
|
152
|
+
get public(): import("@bradthomasbrown/finite-curve").FinitePoint;
|
|
153
|
+
get hashlen(): number;
|
|
154
|
+
get publicHex(): string;
|
|
155
|
+
get address(): string;
|
|
156
|
+
};
|
|
157
|
+
}>;
|
|
158
|
+
node: InstanceType<typeof Node>;
|
|
159
|
+
state: unknown;
|
|
160
|
+
_78_(_e2_: null | string, _88_: null | string, value?: bigint): Promise<[bigint, string, Promise<string>]>;
|
|
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<{
|
|
164
|
+
transactionHash: string;
|
|
165
|
+
transactionIndex: bigint;
|
|
166
|
+
blockHash: string;
|
|
167
|
+
blockNumber: bigint;
|
|
168
|
+
from: string;
|
|
169
|
+
to: string | null;
|
|
170
|
+
cumulativeGasUsed: bigint;
|
|
171
|
+
effectiveGasPrice: bigint;
|
|
172
|
+
gasUsed: bigint;
|
|
173
|
+
contractAddress: string | null;
|
|
174
|
+
logs: {
|
|
175
|
+
removed: boolean;
|
|
176
|
+
logIndex: bigint | null;
|
|
177
|
+
transactionIndex: bigint | null;
|
|
178
|
+
transactionHash: string | null;
|
|
179
|
+
blockHash: string | null;
|
|
180
|
+
blockNumber: bigint | null;
|
|
181
|
+
address: string;
|
|
182
|
+
data: string[];
|
|
183
|
+
topics: string[];
|
|
184
|
+
}[];
|
|
185
|
+
logsBloom: string;
|
|
186
|
+
type: number;
|
|
187
|
+
root: string | null;
|
|
188
|
+
status: number | null;
|
|
189
|
+
}>;
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
export { _e4e1df_ };
|
|
193
|
+
//# sourceMappingURL=e4e1df.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"e4e1df.d.ts","sourceRoot":"","sources":["../../src/concrete/e4e1df.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AA6ClD;;;;;;;;;;GAUG;AACH,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAA2F,CAAC;AAE1G,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { _75bb14_ } from "../75bb14.js";
|
|
2
|
+
function _4403dc_(_d2_) {
|
|
3
|
+
return _d2_.node.getTransactionCount(_d2_.entity.address, "latest");
|
|
4
|
+
}
|
|
5
|
+
function _0da055_(_ce_) {
|
|
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_) {
|
|
29
|
+
let receipt;
|
|
30
|
+
for (let i = 0; i < 5; i++) {
|
|
31
|
+
receipt = await _ad_.node.getTransactionReceipt(_85_);
|
|
32
|
+
if (receipt != null)
|
|
33
|
+
return receipt;
|
|
34
|
+
await new Promise(r => setTimeout(r, 250));
|
|
35
|
+
}
|
|
36
|
+
throw new Error(`failed to wait for receipt from transaction hash: ${_85_}`);
|
|
37
|
+
}
|
|
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_);
|
|
50
|
+
export { _e4e1df_ };
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bradthomasbrown/75bb14",
|
|
3
|
+
"description": "A light, flexible, convenience layer library for `EvmEntity`s and (EVM) Nodes in JavaScript/TypeScript.",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"author": "Brad Brown <https://t.me/bradthomasbrown>",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/"
|
|
9
|
+
],
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./dist/75bb14.js",
|
|
12
|
+
"./e4e1df": "./dist/concrete/e4e1df.js"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@bradthomasbrown/ecdsa": "^2.0.1",
|
|
16
|
+
"@bradthomasbrown/ejra": "^1.0.6",
|
|
17
|
+
"@bradthomasbrown/entity": "^1.0.1",
|
|
18
|
+
"@bradthomasbrown/keccak": "^1.0.1",
|
|
19
|
+
"@bradthomasbrown/rlp": "^1.0.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@bradthomasbrown/900ef2": "^1.0.0",
|
|
23
|
+
"@types/bun": "^1.3.5"
|
|
24
|
+
}
|
|
25
|
+
}
|