|
1 |
| -const { providers, Wallet } = require('ethers') |
2 |
| -const hre = require('hardhat') |
| 1 | +const { providers, Wallet } = require('ethers'); |
| 2 | +const hre = require('hardhat'); |
3 | 3 | const {
|
4 | 4 | ArbAddressTable__factory,
|
5 |
| -} = require('@arbitrum/sdk/dist/lib/abi/factories/ArbAddressTable__factory') |
6 |
| -const { arbLog, requireEnvVariables } = require('arb-shared-dependencies') |
7 |
| -const { |
8 |
| - ARB_ADDRESS_TABLE_ADDRESS, |
9 |
| -} = require('@arbitrum/sdk/dist/lib/dataEntities/constants') |
10 |
| -require('dotenv').config() |
11 |
| -requireEnvVariables(['PRIVATE_KEY', 'CHAIN_RPC']) |
| 5 | +} = require('@arbitrum/sdk/dist/lib/abi/factories/ArbAddressTable__factory'); |
| 6 | +const { arbLog, requireEnvVariables } = require('arb-shared-dependencies'); |
| 7 | +const { ARB_ADDRESS_TABLE_ADDRESS } = require('@arbitrum/sdk/dist/lib/dataEntities/constants'); |
| 8 | +require('dotenv').config(); |
| 9 | +requireEnvVariables(['PRIVATE_KEY', 'CHAIN_RPC']); |
12 | 10 |
|
13 | 11 | /**
|
14 | 12 | * Set up: instantiate wallets connected to providers
|
15 | 13 | */
|
16 |
| -const walletPrivateKey = process.env.PRIVATE_KEY |
17 |
| -const provider = new providers.JsonRpcProvider(process.env.CHAIN_RPC) |
18 |
| -const wallet = new Wallet(walletPrivateKey, provider) |
| 14 | +const walletPrivateKey = process.env.PRIVATE_KEY; |
| 15 | +const provider = new providers.JsonRpcProvider(process.env.CHAIN_RPC); |
| 16 | +const wallet = new Wallet(walletPrivateKey, provider); |
19 | 17 |
|
20 | 18 | async function main() {
|
21 |
| - await arbLog('Using the Address Table') |
| 19 | + await arbLog('Using the Address Table'); |
22 | 20 |
|
23 | 21 | /**
|
24 | 22 | * Deploy ArbitrumVIP contract
|
25 | 23 | */
|
26 | 24 | const ArbitrumVIPContract = await (
|
27 | 25 | await hre.ethers.getContractFactory('ArbitrumVIP')
|
28 |
| - ).connect(wallet) |
29 |
| - console.log('Deploying ArbitrumVIP contract...') |
30 |
| - const arbitrumVIP = await ArbitrumVIPContract.deploy() |
31 |
| - await arbitrumVIP.deployed() |
32 |
| - console.log('ArbitrumVIP deployed to:', arbitrumVIP.address) |
| 26 | + ).connect(wallet); |
| 27 | + console.log('Deploying ArbitrumVIP contract...'); |
| 28 | + const arbitrumVIP = await ArbitrumVIPContract.deploy(); |
| 29 | + await arbitrumVIP.deployed(); |
| 30 | + console.log('ArbitrumVIP deployed to:', arbitrumVIP.address); |
33 | 31 |
|
34 |
| - const myAddress = wallet.address |
| 32 | + const myAddress = wallet.address; |
35 | 33 |
|
36 | 34 | /**
|
37 | 35 | * Connect to the Arbitrum Address table pre-compile contract
|
38 | 36 | */
|
39 |
| - const arbAddressTable = ArbAddressTable__factory.connect( |
40 |
| - ARB_ADDRESS_TABLE_ADDRESS, |
41 |
| - wallet |
42 |
| - ) |
| 37 | + const arbAddressTable = ArbAddressTable__factory.connect(ARB_ADDRESS_TABLE_ADDRESS, wallet); |
43 | 38 |
|
44 |
| - //** |
45 |
| - /* Let's find out if our address is registered in the table: |
| 39 | + /** |
| 40 | + * Let's find out if our address is registered in the table: |
46 | 41 | */
|
47 |
| - const addressIsRegistered = await arbAddressTable.addressExists(myAddress) |
| 42 | + const addressIsRegistered = await arbAddressTable.addressExists(myAddress); |
48 | 43 |
|
49 | 44 | if (!addressIsRegistered) {
|
50 |
| - //** |
51 |
| - /* If it isn't registered yet, let's register it! |
| 45 | + /** |
| 46 | + * If it isn't registered yet, let's register it! |
52 | 47 | */
|
53 |
| - |
54 |
| - const txnRes = await arbAddressTable.register(myAddress) |
55 |
| - const txnRec = await txnRes.wait() |
56 |
| - console.log(`Successfully registered address ${myAddress} to address table`) |
| 48 | + const txnRes = await arbAddressTable.register(myAddress); |
| 49 | + await txnRes.wait(); |
| 50 | + console.log(`Successfully registered address ${myAddress} to address table`); |
57 | 51 | } else {
|
58 |
| - console.log(`Address ${myAddress} already (previously) registered to table`) |
| 52 | + console.log(`Address ${myAddress} already (previously) registered to table`); |
59 | 53 | }
|
60 | 54 | /**
|
61 | 55 | * Now that we know it's registered, let's go ahead and retrieve its index
|
62 | 56 | */
|
63 |
| - const addressIndex = await arbAddressTable.lookup(myAddress) |
| 57 | + const addressIndex = await arbAddressTable.lookup(myAddress); |
64 | 58 |
|
65 | 59 | /**
|
66 | 60 | * From here on out we can use this index instead of our address as a parameter into any contract with affordances to look up out address in the address data.
|
67 | 61 | */
|
68 | 62 |
|
69 |
| - const txnRes = await arbitrumVIP.addVIPPoints(addressIndex) |
70 |
| - await txnRes.wait() |
| 63 | + const txnRes = await arbitrumVIP.addVIPPoints(addressIndex); |
| 64 | + await txnRes.wait(); |
71 | 65 | /**
|
72 | 66 | * We got VIP points, and we minimized the calldata required, saving us precious gas. Yay rollups!
|
73 | 67 | */
|
74 |
| - console.log( |
75 |
| - `Successfully added VIP points using address w/ index ${addressIndex.toNumber()}` |
76 |
| - ) |
| 68 | + console.log(`Successfully added VIP points using address w/ index ${addressIndex.toNumber()}`); |
77 | 69 | }
|
78 | 70 | main()
|
79 | 71 | .then(() => process.exit(0))
|
80 |
| - .catch(error => { |
81 |
| - console.error(error) |
82 |
| - process.exit(1) |
83 |
| - }) |
| 72 | + .catch((error) => { |
| 73 | + console.error(error); |
| 74 | + process.exit(1); |
| 75 | + }); |
0 commit comments