Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment scripts #28

Merged
merged 13 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
ENDPOINT: http://localhost:8899

env:
PROGRAM_ID: Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS
PROGRAM_ID: WabZqXyytFA2XeXswf9DdQkQuSZuRiEgKdDmq7c5Mnp

defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion frontend/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ FUNDER_KEYPAIR=[145,197,43,77,224,103,196,174,132,195,48,31,177,97,237,163,15,19
DEPLOYER_WALLET=[145,197,43,77,224,103,196,174,132,195,48,31,177,97,237,163,15,196,217,142,181,204,104,107,98,82,213,0,155,140,218,180,30,119,201,38,51,176,207,221,193,222,235,244,163,250,125,66,68,196,45,208,212,201,232,178,100,163,24,21,106,83,66,174]


PROGRAM_ID=Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS
PROGRAM_ID=WabZqXyytFA2XeXswf9DdQkQuSZuRiEgKdDmq7c5Mnp
CSV_DIR=/tmp

# Datadog Event Subscriber Configs
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/BoxTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ReactNode } from 'react'

export function BoxTitle({ children }: { children: ReactNode }) {
return (
<h4 className="border-b border-light border-opacity-25 bg-dark bg-opacity-30 py-8 px-4 font-header text-[28px] font-light leading-[1.2] sm:px-10">
<h4 className="border-b border-light border-opacity-25 bg-dark bg-opacity-30 px-4 py-8 font-header text-[28px] font-light leading-[1.2] sm:px-10">
{children}
</h4>
)
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function Dropdown({ icon, title, items }: DropdownProps) {
<Listbox.Option
key={index}
value={item.label}
className="relative z-50 flex cursor-pointer items-center justify-center gap-2.5 py-3 px-8 hover:bg-darkGray3"
className="relative z-50 flex cursor-pointer items-center justify-center gap-2.5 px-8 py-3 hover:bg-darkGray3"
onClick={item.onClick}
>
{item.icon}
Expand Down
6 changes: 3 additions & 3 deletions frontend/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const Layout = ({ children, setDisclaimerWasRead }: LayoutProps) => {
return (
<>
<header className="absolute left-0 top-0 z-40 w-full px-1 transition-all lg:px-10">
<div className=" relative flex items-center justify-between gap-2 px-4 py-3 lg:py-6 lg:px-10">
<div className=" relative flex items-center justify-between gap-2 px-4 py-3 lg:px-10 lg:py-6">
<Link
href="/"
className="flex items-center justify-center border-light border-opacity-60 outline-none sm:h-12 sm:border sm:px-4 md:px-[29px]"
Expand All @@ -60,7 +60,7 @@ export const Layout = ({ children, setDisclaimerWasRead }: LayoutProps) => {
</div>
</div>
</header>
<div className="relative min-h-[calc(100vh-80px)] px-4 pt-20 pb-32 sm:pt-28 lg:pt-40">
<div className="relative min-h-[calc(100vh-80px)] px-4 pb-32 pt-20 sm:pt-28 lg:pt-40">
<div className="mx-auto max-w-[997px] items-start justify-between gap-2.5 lg:flex">
<ul
className={classNames(
Expand Down Expand Up @@ -107,7 +107,7 @@ export const Layout = ({ children, setDisclaimerWasRead }: LayoutProps) => {
</div>
<footer className="footer">
<span>{year} Ⓒ Wormhole. All Rights Reserved.</span>
<span className="mb-2 flex-1 space-y-2 border-white border-opacity-50 py-2 text-center opacity-75 md:space-y-0 md:space-x-10 lg:mb-0 lg:ml-10 lg:border-l lg:py-0 lg:pl-10 lg:text-left">
<span className="mb-2 flex-1 space-y-2 border-white border-opacity-50 py-2 text-center opacity-75 md:space-x-10 md:space-y-0 lg:mb-0 lg:ml-10 lg:border-l lg:py-0 lg:pl-10 lg:text-left">
<a
target="_blank"
rel="noreferrer"
Expand Down
4 changes: 2 additions & 2 deletions frontend/components/modal/Disclaimer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export function Disclaimer({ onAgree, showModal }: DisclaimerProps) {
Terms.{' '}
</p>
</div>
<div className="[&>button]:w-[200px] flex min-h-fit flex-col items-stretch gap-4 py-5 px-6 text-sm md:px-10">
<div className="[&>button]:w-[200px] flex min-h-fit flex-col items-stretch gap-4 px-6 py-5 text-sm md:px-10">
<div
className="flex items-center justify-center gap-2 hover:cursor-pointer"
onClick={() => setAgreed((agreed) => !agreed)}
Expand All @@ -143,7 +143,7 @@ export function Disclaimer({ onAgree, showModal }: DisclaimerProps) {
className={classNames(
'relative h-4 w-4 border',
agreed
? 'before:absolute before:top-1/2 before:left-1/2 before:h-2.5 before:w-2.5 before:-translate-y-1/2 before:-translate-x-1/2 before:bg-light'
? 'before:absolute before:left-1/2 before:top-1/2 before:h-2.5 before:w-2.5 before:-translate-x-1/2 before:-translate-y-1/2 before:bg-light'
: ''
)}
></span>
Expand Down
2 changes: 1 addition & 1 deletion frontend/integration/integrationTest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('integration test', () => {
const funderWallet = loadFunderWallet()
const endpoint = 'http://127.0.0.1:8899'
const tokenDispenserPid = new PublicKey(
'Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS'
'WabZqXyytFA2XeXswf9DdQkQuSZuRiEgKdDmq7c5Mnp'
)

const confirmOpts: anchor.web3.ConfirmOptions = {
Expand Down
2 changes: 1 addition & 1 deletion frontend/sections/WalletsEligibility.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function TableRow({ ecosystem }: TableRowProps) {
<tr className={'border-b border-light-35'}>
<td
className={classNames(
'w-full py-2 pl-4 pr-2 sm:pr-4 sm:pl-10',
'w-full py-2 pl-4 pr-2 sm:pl-10 sm:pr-4',
rowDisabled ? 'opacity-25' : ''
)}
>
Expand Down
8 changes: 4 additions & 4 deletions frontend/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

@layer utilities {
.gradient-border {
@apply absolute left-8 bottom-0 h-px w-[calc(100%-64px)] bg-radial opacity-60;
@apply absolute bottom-0 left-8 h-px w-[calc(100%-64px)] bg-radial opacity-60;
}
.btn-bg {
@apply absolute top-px left-px h-[calc(100%-2px)] w-[calc(100%-2px)] transition-all;
@apply absolute left-px top-px h-[calc(100%-2px)] w-[calc(100%-2px)] transition-all;
}
}

Expand All @@ -38,7 +38,7 @@
}

.diaglogPanel {
@apply flex h-full min-h-[420px] w-[calc(100%-64px)] max-w-3xl transform items-center justify-center rounded-[40px] bg-[rgba(49,47,71,0.85)] p-5 px-6 pt-20 pb-8 text-center align-middle shadow-xl transition-all md:mt-[92px] lg:p-10;
@apply flex h-full min-h-[420px] w-[calc(100%-64px)] max-w-3xl transform items-center justify-center rounded-[40px] bg-[rgba(49,47,71,0.85)] p-5 px-6 pb-8 pt-20 text-center align-middle shadow-xl transition-all md:mt-[92px] lg:p-10;
}
.diaglogClose {
@apply absolute right-10 top-8 flex items-center leading-none;
Expand Down Expand Up @@ -86,7 +86,7 @@
}

.claim_li {
@apply mb-[1px] block cursor-pointer py-4 px-4 font-header text-base18 font-light transition-colors hover:bg-opacity-60 sm:px-6;
@apply mb-[1px] block cursor-pointer px-4 py-4 font-header text-base18 font-light transition-colors hover:bg-opacity-60 sm:px-6;
}

.claim_li span {
Expand Down
17 changes: 14 additions & 3 deletions token-dispenser/Anchor.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
[features]
seeds = false
skip-lint = false
[programs.localnet]
token_dispenser = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"

[toolchain]
anchor_version = "0.29.0"
solana_version = "1.17.24"

[registry]
url = "https://api.apr.dev"

[provider]
cluster = "Localnet"
cluster = "devnet"
wallet = "../frontend/integration/keys/funder_private_key.json"

[programs.localnet]
token_dispenser = "WabZqXyytFA2XeXswf9DdQkQuSZuRiEgKdDmq7c5Mnp"

[programs.mainnet]
token_dispenser = "WabZqXyytFA2XeXswf9DdQkQuSZuRiEgKdDmq7c5Mnp"

[programs.devnet]
token_dispenser = "WabZqXyytFA2XeXswf9DdQkQuSZuRiEgKdDmq7c5Mnp"

[scripts]
test = "cargo test-bpf"
export = "anchor build && ./scripts/export_idl.sh"
17 changes: 9 additions & 8 deletions token-dispenser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
"lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
"lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check"
},
"dependencies": {
"@coral-xyz/anchor": "^0.27.0"
},
"devDependencies": {
"chai": "^4.3.4",
"mocha": "^9.0.3",
"ts-mocha": "^10.0.0",
"@coral-xyz/anchor": "0.27.0",
"@solana/spl-token": "^0.4.1",
"@types/bn.js": "^5.1.0",
"@types/chai": "^4.3.0",
"@types/mocha": "^9.0.0",
"typescript": "^4.3.5",
"prettier": "^2.6.2"
"@wormhole-foundation/sdk-base": "^0.5.0-beta.9",
"@xlabs-xyz/ledger-signer-solana": "^0.0.1",
"chai": "^4.3.4",
"mocha": "^9.0.3",
"prettier": "^2.6.2",
"ts-mocha": "^10.0.0",
"typescript": "^4.3.5"
}
}
2 changes: 1 addition & 1 deletion token-dispenser/programs/token-dispenser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ mod tests;

mod ecosystems;

declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
declare_id!("WabZqXyytFA2XeXswf9DdQkQuSZuRiEgKdDmq7c5Mnp");

const CONFIG_SEED: &[u8] = b"config";
const RECEIPT_SEED: &[u8] = b"receipt";
Expand Down
1 change: 1 addition & 0 deletions token-dispenser/scripts/initialize_token_dispenser.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx tsx ./ts/scripts/initialize-token-dispenser.ts
45 changes: 45 additions & 0 deletions token-dispenser/ts/scripts/create-spl-token.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {
MINT_SIZE,
TOKEN_PROGRAM_ID,
createInitializeMint2Instruction,
} from "@solana/spl-token";
import { SystemProgram, Keypair, PublicKey } from "@solana/web3.js";

import { connection, getSigner } from "./env";
import { ledgerSignAndSend } from "./helpers";

const mintKeypair = Keypair.generate();

console.log(
"Creating mint account with keypair:",
mintKeypair.publicKey.toBase58()
);

(async () => {
const tokenConfig = {
decimals: 9,
name: "Test grant Token",
symbol: "TEST_GRANT_TKN",
uri: "https://thisisnot.arealurl/info.json",
};
const signer = await getSigner();
const signerPk = new PublicKey(await signer.getAddress());

const createAccountIx = SystemProgram.createAccount({
fromPubkey: signerPk,
newAccountPubkey: mintKeypair.publicKey,
space: MINT_SIZE,
lamports: await connection.getMinimumBalanceForRentExemption(MINT_SIZE),
programId: TOKEN_PROGRAM_ID,
});

const initMintIx = createInitializeMint2Instruction(
mintKeypair.publicKey,
tokenConfig.decimals,
signerPk,
signerPk, //signerPk,
TOKEN_PROGRAM_ID
);

return ledgerSignAndSend([createAccountIx, initMintIx], [mintKeypair]);
})();
33 changes: 33 additions & 0 deletions token-dispenser/ts/scripts/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Connection, Keypair, Commitment } from "@solana/web3.js";
import { SolanaLedgerSigner } from "@xlabs-xyz/ledger-signer-solana";

if (!process.env.LEDGER_DERIVATION_PATH) {
throw new Error("LEDGER_DERIVATION_PATH is not set");
}

const derivationPath = process.env.LEDGER_DERIVATION_PATH! as string;

let signer;
export async function getSigner(): Promise<SolanaLedgerSigner> {
if (!signer) {
signer = await SolanaLedgerSigner.create(derivationPath);
}

return signer;
}

export function getEnv(key: string): string {
if (!process.env[key]) {
throw new Error(`${key} not found on environment`);
}

return process.env[key]!;
}

export const rpcUrl =
process.env.SOLANA_RPC_URL || "https://api.devnet.solana.com";

export const connectionCommitmentLevel = (process.env.SOLANA_COMMITMENT ||
"confirmed") as Commitment;

export const connection = new Connection(rpcUrl, connectionCommitmentLevel);
71 changes: 71 additions & 0 deletions token-dispenser/ts/scripts/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import {
Transaction,
TransactionInstruction,
Keypair,
PublicKey,
VersionedTransaction,
TransactionMessage,
} from "@solana/web3.js";
import { SolanaLedgerSigner } from "@xlabs-xyz/ledger-signer-solana";

import { connection, getSigner } from "./env";

export async function ledgerSignAndSend(
instructions: TransactionInstruction[],
signers: Keypair[]
) {
const deployerSigner = await getSigner();
const deployerPk = new PublicKey(await deployerSigner.getAddress());

const tx = new Transaction();
tx.add(...instructions);

const recentBlockHash = await connection.getRecentBlockhash();

tx.recentBlockhash = recentBlockHash.blockhash;
tx.feePayer = deployerPk;

signers.forEach((signer) => tx.partialSign(signer));

await addLedgerSignature(tx, deployerSigner, deployerPk);

return connection.sendRawTransaction(tx.serialize());
}

export async function ledgerSignAndSendV0(
instructions: TransactionInstruction[],
signers: Keypair[]
) {
const deployerSigner = await getSigner();
const deployerPk = new PublicKey(await deployerSigner.getAddress());
const recentBlockhash = (await connection.getRecentBlockhash()).blockhash;

const message = new TransactionMessage({
payerKey: deployerPk,
recentBlockhash,
instructions,
}).compileToV0Message();

const transaction = new VersionedTransaction(message);

transaction.sign(signers);

const signedByPayer = await deployerSigner.signTransaction(
Buffer.from(transaction.message.serialize())
);

transaction.addSignature(deployerPk, signedByPayer);

return connection.sendRawTransaction(transaction.serialize());
}

export async function addLedgerSignature(
tx: Transaction,
signer: SolanaLedgerSigner,
signerPk: PublicKey
) {
const signedByPayer = await signer.signTransaction(
tx.compileMessage().serialize()
);
tx.addSignature(signerPk, signedByPayer);
}
Loading
Loading