@swapkit/toolboxes 0.0.0-nightly-20250304130539
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/chunk-fazw0jvt.js +3 -0
- package/dist/chunk-fazw0jvt.js.map +9 -0
- package/dist/chunk-tvrdndbw.js +4 -0
- package/dist/chunk-tvrdndbw.js.map +9 -0
- package/dist/cosmos/index.cjs +3 -0
- package/dist/cosmos/index.cjs.map +19 -0
- package/dist/cosmos/index.js +3 -0
- package/dist/cosmos/index.js.map +19 -0
- package/dist/evm/index.cjs +3 -0
- package/dist/evm/index.cjs.map +18 -0
- package/dist/evm/index.js +3 -0
- package/dist/evm/index.js.map +18 -0
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +9 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +9 -0
- package/dist/radix/index.cjs +3 -0
- package/dist/radix/index.cjs.map +10 -0
- package/dist/radix/index.js +3 -0
- package/dist/radix/index.js.map +10 -0
- package/dist/solana/index.cjs +3 -0
- package/dist/solana/index.cjs.map +10 -0
- package/dist/solana/index.js +3 -0
- package/dist/solana/index.js.map +10 -0
- package/dist/substrate/index.cjs +3 -0
- package/dist/substrate/index.cjs.map +12 -0
- package/dist/substrate/index.js +3 -0
- package/dist/substrate/index.js.map +12 -0
- package/dist/utxo/index.cjs +3 -0
- package/dist/utxo/index.cjs.map +17 -0
- package/dist/utxo/index.js +3 -0
- package/dist/utxo/index.js.map +17 -0
- package/package.json +102 -0
- package/src/cosmos/index.ts +8 -0
- package/src/cosmos/thorchainUtils/addressFormat.ts +23 -0
- package/src/cosmos/thorchainUtils/index.ts +4 -0
- package/src/cosmos/thorchainUtils/messages.ts +244 -0
- package/src/cosmos/thorchainUtils/registry.ts +47 -0
- package/src/cosmos/thorchainUtils/types/client-types.ts +79 -0
- package/src/cosmos/thorchainUtils/types/index.ts +1 -0
- package/src/cosmos/thorchainUtils/types/proto/MsgCompiled.js +2806 -0
- package/src/cosmos/thorchainUtils/types/proto/MsgCompiled.ts +2802 -0
- package/src/cosmos/thorchainUtils/util.ts +46 -0
- package/src/cosmos/toolbox/BaseCosmosToolbox.ts +257 -0
- package/src/cosmos/toolbox/gaia.ts +39 -0
- package/src/cosmos/toolbox/getToolboxByChain.ts +29 -0
- package/src/cosmos/toolbox/kujira.ts +61 -0
- package/src/cosmos/toolbox/thorchain.ts +305 -0
- package/src/cosmos/types.ts +42 -0
- package/src/cosmos/util.ts +230 -0
- package/src/evm/__tests__/ethereum.test.ts +147 -0
- package/src/evm/api.ts +157 -0
- package/src/evm/contracts/eth/multicall.ts +165 -0
- package/src/evm/contracts/op/gasOracle.ts +151 -0
- package/src/evm/helpers.ts +213 -0
- package/src/evm/index.ts +15 -0
- package/src/evm/toolbox/baseEVMToolbox.ts +670 -0
- package/src/evm/toolbox/evm.ts +89 -0
- package/src/evm/toolbox/getToolboxByChain.ts +37 -0
- package/src/evm/toolbox/op.ts +152 -0
- package/src/evm/types.ts +110 -0
- package/src/index.ts +0 -0
- package/src/radix/index.ts +151 -0
- package/src/radix/toolbox.ts +693 -0
- package/src/solana/index.ts +49 -0
- package/src/solana/toolbox.ts +271 -0
- package/src/substrate/index.ts +3 -0
- package/src/substrate/toolbox/baseSubstrateToolbox.ts +288 -0
- package/src/substrate/toolbox/index.ts +40 -0
- package/src/substrate/types/index.ts +2 -0
- package/src/substrate/types/network.ts +42 -0
- package/src/substrate/types/wallet.ts +78 -0
- package/src/utxo/helpers/api.ts +431 -0
- package/src/utxo/helpers/bchaddrjs.ts +177 -0
- package/src/utxo/helpers/coinselect.ts +96 -0
- package/src/utxo/helpers/index.ts +5 -0
- package/src/utxo/helpers/txSize.ts +103 -0
- package/src/utxo/helpers/utils.ts +48 -0
- package/src/utxo/index.ts +7 -0
- package/src/utxo/toolbox/bitcoinCash.ts +268 -0
- package/src/utxo/toolbox/index.ts +41 -0
- package/src/utxo/toolbox/utxo.ts +372 -0
- package/src/utxo/types.ts +51 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import type ethers from "@nomicfoundation/hardhat-ethers";
|
|
3
|
+
import { AssetValue, Chain } from "@swapkit/helpers";
|
|
4
|
+
import { erc20ABI } from "@swapkit/helpers/contracts";
|
|
5
|
+
import type { JsonRpcProvider } from "ethers";
|
|
6
|
+
// import hre from "hardhat";
|
|
7
|
+
|
|
8
|
+
import type { ETHToolbox } from "../index";
|
|
9
|
+
const testAddress = "0x6d6e022eE439C8aB8B7a7dBb0576f8090319CDc6";
|
|
10
|
+
const emptyRecipient = "0xE29E61479420Dd1029A9946710Ac31A0d140e77F";
|
|
11
|
+
const USDCAddress = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
|
|
12
|
+
// Get latest block to use as base for reset fork after test
|
|
13
|
+
// const _block = await hre.ethers.provider.getBlock("latest");
|
|
14
|
+
|
|
15
|
+
beforeAll(() => {
|
|
16
|
+
// hre.run("node");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const context: {
|
|
20
|
+
ethers: typeof ethers;
|
|
21
|
+
provider: JsonRpcProvider;
|
|
22
|
+
toolbox: ReturnType<typeof ETHToolbox>;
|
|
23
|
+
} = {} as any;
|
|
24
|
+
|
|
25
|
+
beforeEach(async () => {
|
|
26
|
+
// context.ethers = hre.artifacts;
|
|
27
|
+
// const provider = getProvider(Chain.Ethereum, "http://127.0.0.1:8545/");
|
|
28
|
+
// const signer = (await hre.ethers.getImpersonatedSigner(testAddress)) as unknown as JsonRpcSigner;
|
|
29
|
+
// context.provider = provider;
|
|
30
|
+
// context.toolbox = ETHToolbox({ provider, signer });
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
afterEach(async () => {
|
|
34
|
+
// await helpers.reset(hre.config.networks.hardhat.forking?.url, block?.number);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe("Ethereum toolkit", () => {
|
|
38
|
+
test.todo(
|
|
39
|
+
"Get Balances",
|
|
40
|
+
async () => {
|
|
41
|
+
const balances = await context.toolbox.getBalance(testAddress);
|
|
42
|
+
expect(balances.find((balance) => balance.symbol === "ETH")?.getBaseValue("string")).toBe(
|
|
43
|
+
"20526000000000000",
|
|
44
|
+
);
|
|
45
|
+
expect(
|
|
46
|
+
balances
|
|
47
|
+
.find(
|
|
48
|
+
(balance) =>
|
|
49
|
+
balance.symbol.toLowerCase() ===
|
|
50
|
+
"USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48".toLowerCase(),
|
|
51
|
+
)
|
|
52
|
+
?.getBaseValue("string"),
|
|
53
|
+
).toBe("6656178");
|
|
54
|
+
},
|
|
55
|
+
10000,
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
test.todo(
|
|
59
|
+
"Send ETH",
|
|
60
|
+
async () => {
|
|
61
|
+
expect((await context.provider.getBalance(emptyRecipient)).toString()).toBe("0");
|
|
62
|
+
await context.toolbox.transfer({
|
|
63
|
+
recipient: emptyRecipient,
|
|
64
|
+
assetValue: await AssetValue.from({ chain: Chain.Ethereum, value: "0.010526" }),
|
|
65
|
+
from: testAddress,
|
|
66
|
+
});
|
|
67
|
+
expect((await context.provider.getBalance(emptyRecipient)).toString()).toBe(
|
|
68
|
+
"10526000000000000",
|
|
69
|
+
);
|
|
70
|
+
},
|
|
71
|
+
10000,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
test.todo(
|
|
75
|
+
"Send Token",
|
|
76
|
+
async () => {
|
|
77
|
+
const USDC = await context.toolbox.createContract(USDCAddress, erc20ABI);
|
|
78
|
+
const balance = await USDC.balanceOf?.(emptyRecipient);
|
|
79
|
+
expect(balance.toString()).toBe("0");
|
|
80
|
+
await context.toolbox.transfer({
|
|
81
|
+
recipient: emptyRecipient,
|
|
82
|
+
assetValue: await AssetValue.from({
|
|
83
|
+
asset: "ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
84
|
+
value: "1",
|
|
85
|
+
}),
|
|
86
|
+
from: testAddress,
|
|
87
|
+
});
|
|
88
|
+
// biome-ignore lint/correctness/noUnsafeOptionalChaining: <explanation>
|
|
89
|
+
expect((await USDC.balanceOf?.(emptyRecipient)).toString()).toBe("1000000");
|
|
90
|
+
},
|
|
91
|
+
10000,
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
test.todo(
|
|
95
|
+
"Approve Token and validate approved amount",
|
|
96
|
+
async () => {
|
|
97
|
+
expect(
|
|
98
|
+
await context.toolbox.isApproved({
|
|
99
|
+
assetAddress: USDCAddress,
|
|
100
|
+
spenderAddress: emptyRecipient,
|
|
101
|
+
from: testAddress,
|
|
102
|
+
amount: "1000000",
|
|
103
|
+
}),
|
|
104
|
+
).toBe(false);
|
|
105
|
+
await context.toolbox.approve({
|
|
106
|
+
assetAddress: USDCAddress,
|
|
107
|
+
spenderAddress: emptyRecipient,
|
|
108
|
+
amount: "1000000",
|
|
109
|
+
from: testAddress,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
expect(
|
|
113
|
+
await context.toolbox.isApproved({
|
|
114
|
+
assetAddress: USDCAddress,
|
|
115
|
+
spenderAddress: emptyRecipient,
|
|
116
|
+
from: testAddress,
|
|
117
|
+
amount: "1000000",
|
|
118
|
+
}),
|
|
119
|
+
).toBe(true);
|
|
120
|
+
},
|
|
121
|
+
10000,
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
test.todo(
|
|
125
|
+
"Create contract tx object and sendTransaction",
|
|
126
|
+
async () => {
|
|
127
|
+
const USDC = context.toolbox.createContract(USDCAddress, erc20ABI);
|
|
128
|
+
const balance = await USDC.balanceOf?.(emptyRecipient);
|
|
129
|
+
expect(balance.toString()).toBe("0");
|
|
130
|
+
|
|
131
|
+
const txObject = await context.toolbox.createContractTxObject({
|
|
132
|
+
contractAddress: USDCAddress,
|
|
133
|
+
abi: erc20ABI,
|
|
134
|
+
funcName: "transfer",
|
|
135
|
+
funcParams: [emptyRecipient, BigInt("2222222")],
|
|
136
|
+
txOverrides: {
|
|
137
|
+
from: testAddress,
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
await context.toolbox.sendTransaction(txObject);
|
|
142
|
+
// biome-ignore lint/correctness/noUnsafeOptionalChaining: <explanation>
|
|
143
|
+
expect((await USDC?.balanceOf?.(emptyRecipient)).toString()).toBe("2222222");
|
|
144
|
+
},
|
|
145
|
+
10000,
|
|
146
|
+
);
|
|
147
|
+
});
|
package/src/evm/api.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Chain,
|
|
3
|
+
ChainToChainId,
|
|
4
|
+
type EVMChain,
|
|
5
|
+
RequestClient,
|
|
6
|
+
SKConfig,
|
|
7
|
+
formatBigIntToSafeValue,
|
|
8
|
+
warnOnce,
|
|
9
|
+
} from "@swapkit/helpers";
|
|
10
|
+
|
|
11
|
+
async function getEthplorerBalance({ address }: { address: string }) {
|
|
12
|
+
const apiKey = SKConfig.get("apiKeys").ethplorer || "freekey";
|
|
13
|
+
|
|
14
|
+
const { tokens = [] } = await RequestClient.get<AddressInfo>(
|
|
15
|
+
`https://api.ethplorer.io/getAddressInfo/${address}`,
|
|
16
|
+
{ searchParams: { apiKey } },
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
return tokens
|
|
20
|
+
.filter(({ tokenInfo: { symbol }, rawBalance }) => symbol && rawBalance !== "0")
|
|
21
|
+
.map(({ tokenInfo: { symbol, decimals, address: tokenAddress }, rawBalance }) => ({
|
|
22
|
+
chain: Chain.Ethereum,
|
|
23
|
+
decimal: Number.parseInt(decimals),
|
|
24
|
+
symbol: tokenAddress ? `${symbol}-${tokenAddress}` : symbol,
|
|
25
|
+
value: formatBigIntToSafeValue({
|
|
26
|
+
value: BigInt(rawBalance),
|
|
27
|
+
decimal: Number.parseInt(decimals),
|
|
28
|
+
bigIntDecimal: Number.parseInt(decimals),
|
|
29
|
+
}),
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function getCovalentBalance({ chain, address }: { chain: Chain; address: string }) {
|
|
34
|
+
const apiKey = SKConfig.get("apiKeys").covalent;
|
|
35
|
+
|
|
36
|
+
if (!apiKey) {
|
|
37
|
+
warnOnce(true, "No covalent api key found. Use SKConfig.setApiKey('your-api-key')");
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const { data } = await RequestClient.get<{ data: CovalentBalanceResponse }>(
|
|
42
|
+
`https://api.covalenthq.com/v1/${ChainToChainId[chain]}/address/${address}/balances_v2/`,
|
|
43
|
+
{ searchParams: { key: apiKey } },
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return (data?.items || [])
|
|
47
|
+
.filter(({ is_spam }) => !is_spam)
|
|
48
|
+
.map(
|
|
49
|
+
({ balance, contract_decimals, contract_ticker_symbol, contract_address, native_token }) => ({
|
|
50
|
+
value: formatBigIntToSafeValue({
|
|
51
|
+
value: BigInt(balance),
|
|
52
|
+
decimal: contract_decimals,
|
|
53
|
+
bigIntDecimal: contract_decimals,
|
|
54
|
+
}),
|
|
55
|
+
decimal: contract_decimals,
|
|
56
|
+
chain,
|
|
57
|
+
symbol: `${contract_ticker_symbol || "Unknown"}${native_token ? "" : `-${contract_address}`}`,
|
|
58
|
+
}),
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function getEvmApi(chain: EVMChain) {
|
|
63
|
+
const getBalance = chain === Chain.Ethereum ? getEthplorerBalance : getCovalentBalance;
|
|
64
|
+
return { getBalance: (address: string) => getBalance({ address, chain }) };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function createCustomEvmApi(methods: ReturnType<typeof getEvmApi>) {
|
|
68
|
+
return methods;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
type CovalentBalanceResponse = {
|
|
72
|
+
address: string;
|
|
73
|
+
updated_at: string;
|
|
74
|
+
next_updated_at: string;
|
|
75
|
+
quote_currency: string;
|
|
76
|
+
items: {
|
|
77
|
+
is_spam: boolean;
|
|
78
|
+
contract_decimals: number;
|
|
79
|
+
contract_name: string;
|
|
80
|
+
contract_ticker_symbol: string;
|
|
81
|
+
contract_address: string;
|
|
82
|
+
logo_url: string;
|
|
83
|
+
last_transferred_at: string;
|
|
84
|
+
native_token: boolean;
|
|
85
|
+
type: string;
|
|
86
|
+
balance: number;
|
|
87
|
+
balance_24h: number;
|
|
88
|
+
quote_rate: number;
|
|
89
|
+
quote_rate_24h: number;
|
|
90
|
+
quote: number;
|
|
91
|
+
quote_24h: number;
|
|
92
|
+
}[];
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
type PriceInfo = {
|
|
96
|
+
rate: number;
|
|
97
|
+
diff: number;
|
|
98
|
+
diff7d?: number;
|
|
99
|
+
ts: number;
|
|
100
|
+
marketCapUsd?: number;
|
|
101
|
+
availableSupply?: number;
|
|
102
|
+
volume24h?: number;
|
|
103
|
+
diff30d?: number;
|
|
104
|
+
volDiff1?: number;
|
|
105
|
+
volDiff7?: number;
|
|
106
|
+
volDiff30?: number;
|
|
107
|
+
currency?: string;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
type TokenInfo = {
|
|
111
|
+
address: string;
|
|
112
|
+
decimals: string;
|
|
113
|
+
name: string;
|
|
114
|
+
owner: string;
|
|
115
|
+
symbol: string;
|
|
116
|
+
totalSupply: string;
|
|
117
|
+
lastUpdated: number;
|
|
118
|
+
issuancesCount: number;
|
|
119
|
+
holdersCount: number;
|
|
120
|
+
image?: string;
|
|
121
|
+
description?: string;
|
|
122
|
+
website?: string;
|
|
123
|
+
twitter?: string;
|
|
124
|
+
facebook?: string;
|
|
125
|
+
coingecko?: string;
|
|
126
|
+
ethTransfersCount: number;
|
|
127
|
+
price: boolean | PriceInfo | unknown;
|
|
128
|
+
publicTags?: string[];
|
|
129
|
+
txsCount?: number;
|
|
130
|
+
transfersCount?: number;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
type TokenBalance = {
|
|
134
|
+
tokenInfo: TokenInfo;
|
|
135
|
+
balance: number;
|
|
136
|
+
rawBalance: string;
|
|
137
|
+
totalIn?: number;
|
|
138
|
+
totalOut?: number;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export type AddressInfo = {
|
|
142
|
+
address: string;
|
|
143
|
+
ETH: {
|
|
144
|
+
balance: number;
|
|
145
|
+
totalIn?: number;
|
|
146
|
+
totalOut?: number;
|
|
147
|
+
price: PriceInfo;
|
|
148
|
+
};
|
|
149
|
+
contractInfo?: {
|
|
150
|
+
creatorAddress: string;
|
|
151
|
+
transactionHash: string;
|
|
152
|
+
timestamp: string;
|
|
153
|
+
};
|
|
154
|
+
tokenInfo?: TokenInfo;
|
|
155
|
+
tokens?: TokenBalance[];
|
|
156
|
+
countTxs: number;
|
|
157
|
+
};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
export const multicallAbi = [
|
|
2
|
+
{
|
|
3
|
+
inputs: [
|
|
4
|
+
{
|
|
5
|
+
components: [
|
|
6
|
+
{ internalType: "address", name: "target", type: "address" },
|
|
7
|
+
{ internalType: "bytes", name: "callData", type: "bytes" },
|
|
8
|
+
],
|
|
9
|
+
internalType: "struct Multicall2.Call[]",
|
|
10
|
+
name: "calls",
|
|
11
|
+
type: "tuple[]",
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
name: "aggregate",
|
|
15
|
+
outputs: [
|
|
16
|
+
{ internalType: "uint256", name: "blockNumber", type: "uint256" },
|
|
17
|
+
{ internalType: "bytes[]", name: "returnData", type: "bytes[]" },
|
|
18
|
+
],
|
|
19
|
+
stateMutability: "nonpayable",
|
|
20
|
+
type: "function",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
inputs: [
|
|
24
|
+
{
|
|
25
|
+
components: [
|
|
26
|
+
{ internalType: "address", name: "target", type: "address" },
|
|
27
|
+
{ internalType: "bytes", name: "callData", type: "bytes" },
|
|
28
|
+
],
|
|
29
|
+
internalType: "struct Multicall2.Call[]",
|
|
30
|
+
name: "calls",
|
|
31
|
+
type: "tuple[]",
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
name: "blockAndAggregate",
|
|
35
|
+
outputs: [
|
|
36
|
+
{ internalType: "uint256", name: "blockNumber", type: "uint256" },
|
|
37
|
+
{ internalType: "bytes32", name: "blockHash", type: "bytes32" },
|
|
38
|
+
{
|
|
39
|
+
components: [
|
|
40
|
+
{ internalType: "bool", name: "success", type: "bool" },
|
|
41
|
+
{ internalType: "bytes", name: "returnData", type: "bytes" },
|
|
42
|
+
],
|
|
43
|
+
internalType: "struct Multicall2.Result[]",
|
|
44
|
+
name: "returnData",
|
|
45
|
+
type: "tuple[]",
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
stateMutability: "nonpayable",
|
|
49
|
+
type: "function",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
inputs: [{ internalType: "uint256", name: "blockNumber", type: "uint256" }],
|
|
53
|
+
name: "getBlockHash",
|
|
54
|
+
outputs: [{ internalType: "bytes32", name: "blockHash", type: "bytes32" }],
|
|
55
|
+
stateMutability: "view",
|
|
56
|
+
type: "function",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
inputs: [],
|
|
60
|
+
name: "getBlockNumber",
|
|
61
|
+
outputs: [{ internalType: "uint256", name: "blockNumber", type: "uint256" }],
|
|
62
|
+
stateMutability: "view",
|
|
63
|
+
type: "function",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
inputs: [],
|
|
67
|
+
name: "getCurrentBlockCoinbase",
|
|
68
|
+
outputs: [{ internalType: "address", name: "coinbase", type: "address" }],
|
|
69
|
+
stateMutability: "view",
|
|
70
|
+
type: "function",
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
inputs: [],
|
|
74
|
+
name: "getCurrentBlockDifficulty",
|
|
75
|
+
outputs: [{ internalType: "uint256", name: "difficulty", type: "uint256" }],
|
|
76
|
+
stateMutability: "view",
|
|
77
|
+
type: "function",
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
inputs: [],
|
|
81
|
+
name: "getCurrentBlockGasLimit",
|
|
82
|
+
outputs: [{ internalType: "uint256", name: "gaslimit", type: "uint256" }],
|
|
83
|
+
stateMutability: "view",
|
|
84
|
+
type: "function",
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
inputs: [],
|
|
88
|
+
name: "getCurrentBlockTimestamp",
|
|
89
|
+
outputs: [{ internalType: "uint256", name: "timestamp", type: "uint256" }],
|
|
90
|
+
stateMutability: "view",
|
|
91
|
+
type: "function",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
inputs: [{ internalType: "address", name: "addr", type: "address" }],
|
|
95
|
+
name: "getEthBalance",
|
|
96
|
+
outputs: [{ internalType: "uint256", name: "balance", type: "uint256" }],
|
|
97
|
+
stateMutability: "view",
|
|
98
|
+
type: "function",
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
inputs: [],
|
|
102
|
+
name: "getLastBlockHash",
|
|
103
|
+
outputs: [{ internalType: "bytes32", name: "blockHash", type: "bytes32" }],
|
|
104
|
+
stateMutability: "view",
|
|
105
|
+
type: "function",
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
inputs: [
|
|
109
|
+
{ internalType: "bool", name: "requireSuccess", type: "bool" },
|
|
110
|
+
{
|
|
111
|
+
components: [
|
|
112
|
+
{ internalType: "address", name: "target", type: "address" },
|
|
113
|
+
{ internalType: "bytes", name: "callData", type: "bytes" },
|
|
114
|
+
],
|
|
115
|
+
internalType: "struct Multicall2.Call[]",
|
|
116
|
+
name: "calls",
|
|
117
|
+
type: "tuple[]",
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
name: "tryAggregate",
|
|
121
|
+
outputs: [
|
|
122
|
+
{
|
|
123
|
+
components: [
|
|
124
|
+
{ internalType: "bool", name: "success", type: "bool" },
|
|
125
|
+
{ internalType: "bytes", name: "returnData", type: "bytes" },
|
|
126
|
+
],
|
|
127
|
+
internalType: "struct Multicall2.Result[]",
|
|
128
|
+
name: "returnData",
|
|
129
|
+
type: "tuple[]",
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
stateMutability: "nonpayable",
|
|
133
|
+
type: "function",
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
inputs: [
|
|
137
|
+
{ internalType: "bool", name: "requireSuccess", type: "bool" },
|
|
138
|
+
{
|
|
139
|
+
components: [
|
|
140
|
+
{ internalType: "address", name: "target", type: "address" },
|
|
141
|
+
{ internalType: "bytes", name: "callData", type: "bytes" },
|
|
142
|
+
],
|
|
143
|
+
internalType: "struct Multicall2.Call[]",
|
|
144
|
+
name: "calls",
|
|
145
|
+
type: "tuple[]",
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
name: "tryBlockAndAggregate",
|
|
149
|
+
outputs: [
|
|
150
|
+
{ internalType: "uint256", name: "blockNumber", type: "uint256" },
|
|
151
|
+
{ internalType: "bytes32", name: "blockHash", type: "bytes32" },
|
|
152
|
+
{
|
|
153
|
+
components: [
|
|
154
|
+
{ internalType: "bool", name: "success", type: "bool" },
|
|
155
|
+
{ internalType: "bytes", name: "returnData", type: "bytes" },
|
|
156
|
+
],
|
|
157
|
+
internalType: "struct Multicall2.Result[]",
|
|
158
|
+
name: "returnData",
|
|
159
|
+
type: "tuple[]",
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
stateMutability: "nonpayable",
|
|
163
|
+
type: "function",
|
|
164
|
+
},
|
|
165
|
+
];
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
export const gasOracleAbi = [
|
|
2
|
+
{
|
|
3
|
+
inputs: [{ internalType: "address", name: "_owner", type: "address" }],
|
|
4
|
+
stateMutability: "nonpayable",
|
|
5
|
+
type: "constructor",
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
anonymous: false,
|
|
9
|
+
inputs: [{ indexed: false, internalType: "uint256", name: "", type: "uint256" }],
|
|
10
|
+
name: "DecimalsUpdated",
|
|
11
|
+
type: "event",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
anonymous: false,
|
|
15
|
+
inputs: [{ indexed: false, internalType: "uint256", name: "", type: "uint256" }],
|
|
16
|
+
name: "GasPriceUpdated",
|
|
17
|
+
type: "event",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
anonymous: false,
|
|
21
|
+
inputs: [{ indexed: false, internalType: "uint256", name: "", type: "uint256" }],
|
|
22
|
+
name: "L1BaseFeeUpdated",
|
|
23
|
+
type: "event",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
anonymous: false,
|
|
27
|
+
inputs: [{ indexed: false, internalType: "uint256", name: "", type: "uint256" }],
|
|
28
|
+
name: "OverheadUpdated",
|
|
29
|
+
type: "event",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
anonymous: false,
|
|
33
|
+
inputs: [
|
|
34
|
+
{ indexed: true, internalType: "address", name: "previousOwner", type: "address" },
|
|
35
|
+
{ indexed: true, internalType: "address", name: "newOwner", type: "address" },
|
|
36
|
+
],
|
|
37
|
+
name: "OwnershipTransferred",
|
|
38
|
+
type: "event",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
anonymous: false,
|
|
42
|
+
inputs: [{ indexed: false, internalType: "uint256", name: "", type: "uint256" }],
|
|
43
|
+
name: "ScalarUpdated",
|
|
44
|
+
type: "event",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
inputs: [],
|
|
48
|
+
name: "decimals",
|
|
49
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
50
|
+
stateMutability: "view",
|
|
51
|
+
type: "function",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
inputs: [],
|
|
55
|
+
name: "gasPrice",
|
|
56
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
57
|
+
stateMutability: "view",
|
|
58
|
+
type: "function",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
inputs: [{ internalType: "bytes", name: "_data", type: "bytes" }],
|
|
62
|
+
name: "getL1Fee",
|
|
63
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
64
|
+
stateMutability: "view",
|
|
65
|
+
type: "function",
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
inputs: [{ internalType: "bytes", name: "_data", type: "bytes" }],
|
|
69
|
+
name: "getL1GasUsed",
|
|
70
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
71
|
+
stateMutability: "view",
|
|
72
|
+
type: "function",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
inputs: [],
|
|
76
|
+
name: "l1BaseFee",
|
|
77
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
78
|
+
stateMutability: "view",
|
|
79
|
+
type: "function",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
inputs: [],
|
|
83
|
+
name: "overhead",
|
|
84
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
85
|
+
stateMutability: "view",
|
|
86
|
+
type: "function",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
inputs: [],
|
|
90
|
+
name: "owner",
|
|
91
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
92
|
+
stateMutability: "view",
|
|
93
|
+
type: "function",
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
inputs: [],
|
|
97
|
+
name: "renounceOwnership",
|
|
98
|
+
outputs: [],
|
|
99
|
+
stateMutability: "nonpayable",
|
|
100
|
+
type: "function",
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
inputs: [],
|
|
104
|
+
name: "scalar",
|
|
105
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
106
|
+
stateMutability: "view",
|
|
107
|
+
type: "function",
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
inputs: [{ internalType: "uint256", name: "_decimals", type: "uint256" }],
|
|
111
|
+
name: "setDecimals",
|
|
112
|
+
outputs: [],
|
|
113
|
+
stateMutability: "nonpayable",
|
|
114
|
+
type: "function",
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
inputs: [{ internalType: "uint256", name: "_gasPrice", type: "uint256" }],
|
|
118
|
+
name: "setGasPrice",
|
|
119
|
+
outputs: [],
|
|
120
|
+
stateMutability: "nonpayable",
|
|
121
|
+
type: "function",
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
inputs: [{ internalType: "uint256", name: "_baseFee", type: "uint256" }],
|
|
125
|
+
name: "setL1BaseFee",
|
|
126
|
+
outputs: [],
|
|
127
|
+
stateMutability: "nonpayable",
|
|
128
|
+
type: "function",
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
inputs: [{ internalType: "uint256", name: "_overhead", type: "uint256" }],
|
|
132
|
+
name: "setOverhead",
|
|
133
|
+
outputs: [],
|
|
134
|
+
stateMutability: "nonpayable",
|
|
135
|
+
type: "function",
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
inputs: [{ internalType: "uint256", name: "_scalar", type: "uint256" }],
|
|
139
|
+
name: "setScalar",
|
|
140
|
+
outputs: [],
|
|
141
|
+
stateMutability: "nonpayable",
|
|
142
|
+
type: "function",
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
inputs: [{ internalType: "address", name: "newOwner", type: "address" }],
|
|
146
|
+
name: "transferOwnership",
|
|
147
|
+
outputs: [],
|
|
148
|
+
stateMutability: "nonpayable",
|
|
149
|
+
type: "function",
|
|
150
|
+
},
|
|
151
|
+
];
|