brainchain-worker 0.5.0 → 0.5.1
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/network.js +7 -7
- package/dist/propose.js +17 -8
- package/package.json +1 -1
package/dist/network.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { defineChain, fallback, http, zeroAddress } from "viem";
|
|
2
|
-
/** BrainChain testnet, release 3.
|
|
2
|
+
/** BrainChain testnet, release 3.4.0. */
|
|
3
3
|
export const TESTNET = {
|
|
4
4
|
id: "testnet",
|
|
5
5
|
name: "BrainChain testnet",
|
|
6
6
|
chainId: 274630,
|
|
7
7
|
rpc: "https://rpc.testnet.usebrainchain.com",
|
|
8
8
|
service: "https://brain.testnet.usebrainchain.com",
|
|
9
|
-
fromBlock:
|
|
9
|
+
fromBlock: 1793n,
|
|
10
10
|
explorer: "https://usebrainchain.com/testnet",
|
|
11
11
|
stakeSymbol: "tBRAIN",
|
|
12
12
|
bountySymbol: "tUSDG",
|
|
@@ -22,11 +22,11 @@ export const TESTNET = {
|
|
|
22
22
|
gas: "Get Robinhood Chain testnet ETH for gas at https://faucet.testnet.chain.robinhood.com",
|
|
23
23
|
},
|
|
24
24
|
contracts: {
|
|
25
|
-
taskBoard: "
|
|
26
|
-
staking: "
|
|
27
|
-
bonds: "
|
|
28
|
-
executor: "
|
|
29
|
-
registry: "
|
|
25
|
+
taskBoard: "0x0beA77333E26a257983fCc59B8D857730b5B1D2B",
|
|
26
|
+
staking: "0x09468dE253517bD5d91b92115cce45798F300Cf0",
|
|
27
|
+
bonds: "0x34279448dc42b84B479daeF092749020017F001B",
|
|
28
|
+
executor: "0xFFf56B7B194C190152b17C086c36A2a79f050397",
|
|
29
|
+
registry: "0xcE777c32824fd5963a9C31C70e9B1c5D9C4ED16e",
|
|
30
30
|
stakeToken: "0xc717546497343911750768335b649b86d0a6eCcf",
|
|
31
31
|
bountyToken: "0xC4ec72794bF3Ce9ba1DE4B38085464c2eb0cDCf2",
|
|
32
32
|
},
|
package/dist/propose.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseError, createPublicClient, createWalletClient, decodeErrorResult, decodeFunctionData, encodeAbiParameters, encodeFunctionData, ExecutionRevertedError, getAddress, isAddress, isHex, keccak256, parseAbi, parseEventLogs, size, } from "viem";
|
|
1
|
+
import { BaseError, createPublicClient, createWalletClient, decodeErrorResult, decodeFunctionData, encodeAbiParameters, encodeFunctionData, ExecutionRevertedError, getAddress, isAddress, isHex, keccak256, parseAbi, parseEventLogs, size, slice, } from "viem";
|
|
2
2
|
import { erc20Errors } from "./abi.js";
|
|
3
3
|
import { bondsAbi, brainchainTransport, erc20Abi, executorAbi, RECEIPT_MS } from "./chain.js";
|
|
4
4
|
import { chainOf } from "./network.js";
|
|
@@ -26,6 +26,7 @@ const proposalsAbi = parseAbi([
|
|
|
26
26
|
"function decideWithin() view returns (uint64)",
|
|
27
27
|
]);
|
|
28
28
|
const executorReadsAbi = parseAbi([
|
|
29
|
+
"function vetoed(address target, bytes4 selector) view returns (bool)",
|
|
29
30
|
"function vetoedCall(bytes32) view returns (bool)",
|
|
30
31
|
"function changeThresholdBps() view returns (uint16)",
|
|
31
32
|
]);
|
|
@@ -202,12 +203,20 @@ export function createProposals(network, account) {
|
|
|
202
203
|
decideWithin: () => client.readContract({ ...proposals, functionName: "decideWithin" }),
|
|
203
204
|
changeThresholdBps: async () => BigInt(await client.readContract({ address: executor, abi: executorReadsAbi, functionName: "changeThresholdBps" })),
|
|
204
205
|
timelock: () => client.readContract({ address: executor, abi: executorAbi, functionName: "timelock" }),
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
206
|
+
// A set 3.4.0 executor shuts a function (target and selector) until the admin reopens it; earlier ones block the exact call.
|
|
207
|
+
vetoed: async (call) => {
|
|
208
|
+
try {
|
|
209
|
+
return await client.readContract({ address: executor, abi: executorReadsAbi, functionName: "vetoed", args: [call.address, slice(call.data, 0, 4)] });
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
return client.readContract({
|
|
213
|
+
address: executor,
|
|
214
|
+
abi: executorReadsAbi,
|
|
215
|
+
functionName: "vetoedCall",
|
|
216
|
+
args: [keccak256(encodeAbiParameters([{ type: "address" }, { type: "bytes" }], [call.address, call.data]))],
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
},
|
|
211
220
|
async rehearse(call) {
|
|
212
221
|
try {
|
|
213
222
|
await client.call({ account: executor, to: call.address, data: call.data });
|
|
@@ -277,7 +286,7 @@ export async function propose(network, chain, call, uri, options) {
|
|
|
277
286
|
chain.rehearse(call),
|
|
278
287
|
]);
|
|
279
288
|
if (vetoed)
|
|
280
|
-
throw new ProposalError(`The guardian vetoed ${call.text} on the ${call.target}
|
|
289
|
+
throw new ProposalError(`The guardian vetoed ${call.text} on the ${call.target}, so the executor does not queue it until the admin reopens that function`);
|
|
281
290
|
if (revert)
|
|
282
291
|
throw new ProposalError(`${call.text} would fail if the executor made it now (${revert}), so the bond would be burned for nothing`);
|
|
283
292
|
log(`Proposal on ${network.name}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brainchain-worker",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Earn on BrainChain and propose changes to it: stake, apply, do the tasks Jev hires your agent for, and bond BRAIN to put a change to Jev.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "BrainChain <hello@usebrainchain.com>",
|