Skip to content

Commit

Permalink
Remove console.logs
Browse files Browse the repository at this point in the history
  • Loading branch information
dankelleher committed Sep 3, 2024
1 parent 203c728 commit 0baef09
Show file tree
Hide file tree
Showing 18 changed files with 2 additions and 102 deletions.
35 changes: 0 additions & 35 deletions scripts/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,35 +101,6 @@ export const createWormholeWrappedTransfer = async (
return { instruction: tokenBridgeTransferIx, message }
}

// export const createTransferInstruction = async (
// connection,
// SOL_BRIDGE_ADDRESS,
// SOL_TOKEN_BRIDGE_ADDRESS,
// payerAddress,
// fromAddress,
// mintAddress,
// amount,
// targetAddress,
// CHAIN_ID_ETH,
// originAddress,
// originChain
// ) => {
// const tx = await transferFromSolana(
// connection,
// SOL_BRIDGE_ADDRESS,
// SOL_TOKEN_BRIDGE_ADDRESS,
// payerAddress,
// fromAddress,
// mintAddress,
// amount,
// targetAddress,
// CHAIN_ID_ETH,
// originAddress,
// originChain
// );
// return tx.instructions[1];
// }

/*
0. get test token
- i actually found USDC faucet here: https://usdcfaucet.com/, however not available on testnet
Expand Down Expand Up @@ -164,12 +135,6 @@ async function bridge() {
Wormhole.tryNativeToUint8Array(HOLDING_CONTRACT_ADDRESS, CHAIN_ID_POLYGON),
);

instruction.keys.forEach((key) => {
console.log(key.pubkey.toString(), key.isSigner, key.isWritable);
});
console.log(instruction.keys.length);
console.log(instruction.data.toString("hex"));

const txSig = await solanaProgram.methods.bridge(new BN(amount.toString()), instruction.data).accounts({
state: STATE_ADDRESS,
bridgeAuthority,
Expand Down
1 change: 0 additions & 1 deletion scripts/createHoldingContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ async function createHoldingContract() {
maxFeePerGas: ethers.utils.parseUnits('30', 'gwei'),
maxPriorityFeePerGas: ethers.utils.parseUnits('30', 'gwei'),
});
console.log(tx);
const receipt: ContractReceipt = await tx.wait();
return receipt;
}
Expand Down
5 changes: 0 additions & 5 deletions scripts/swapJupiterApiV6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,10 @@ const getSwapIx = async (
console.log({r});
})



const programATA = await getAssociatedTokenAddress(
new PublicKey(BRIDGE_INPUT_MINT_ADDRESS),
USER_KEYPAIR.publicKey
)
console.log(programATA);
const programATA2 = PublicKey.findProgramAddressSync(
[
USER_KEYPAIR.publicKey.toBuffer(),
Expand All @@ -175,8 +172,6 @@ const getSwapIx = async (
],
ASSOCIATED_TOKEN_PROGRAM_ID
)[0];
console.log(programATA2);
console.log(USER_KEYPAIR.publicKey);

const jupiterIx = await getSwapIx(USER_KEYPAIR.publicKey, quote); // programATA,

Expand Down
9 changes: 0 additions & 9 deletions solana-contract/tests/swap-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,20 @@ export const createWormholeWrappedTransfer = async (
// so we don't want an explicit signer here
tokenBridgeTransferIx.keys.find((key) => key.pubkey.equals(tokenAuthority))!.isSigner = false;

console.log("payer: ", payerAddress.toBase58())
console.log("tokenAuthority: ", tokenAuthority.toBase58())
console.log("message: ", message.publicKey.toBase58())

return { instruction: tokenBridgeTransferIx, message }
}

describe("swap-bridge", () => {
// Configure the client to use the local cluster.
console.log("test start");
// const userKeypair = Keypair.generate();
const stateKeypair = Keypair.generate();
const stateAddress = stateKeypair.publicKey;
const wallet = new Wallet(USER_KEYPAIR);
const connection = new Connection("http://localhost:8890");
const provider = new AnchorProvider(connection, wallet, {});
console.log("provider set");

const program = new Program<SwapBridge>(IDL as SwapBridge, provider);
const tokenAuthority = PublicKey.findProgramAddressSync([Buffer.from("token_authority"), stateAddress.toBuffer()], PROGRAM_ID)[0];
console.log("program set");
// const bridgeInputTokenAccount = getAssociatedTokenAddressSync(new PublicKey(BRIDGE_INPUT_MINT_ADDRESS), tokenAuthority, true);
const bridgeAuthority = PublicKey.findProgramAddressSync([Buffer.from("authority_signer")], new PublicKey(SOL_TOKEN_BRIDGE_ADDRESS))[0];

Expand Down Expand Up @@ -129,8 +122,6 @@ describe("swap-bridge", () => {
);
const blockhash2 = await connection.getLatestBlockhash();
await connection.confirmTransaction({ signature: tx2, ...blockhash2 });
console.log("airdrop done")
console.log(holdingContractAddress);
if (!holdingContractAddress) return;

const tx = await program.methods.initialize({
Expand Down
6 changes: 0 additions & 6 deletions ui/src/api/polygonRetirement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,13 @@ import {ContractReceipt} from "ethers";

export const getVAAFromPolygonTransactionSignature = async (receipt: TransactionReceipt): Promise<VAAResult> => {
// Get the sequence number and emitter address required to fetch the signedVAA of our message
// TODO is this cast a problem?
console.log({receipt})
// Note - to deal with an issue in the wormhole sdk, we need to lowercase the bridge address and the addresses in the receipt logs
receipt.logs.forEach((log) => {
log.address = log.address.toLowerCase() as `0x${string}`;
});
const sequence = parseSequenceFromLogEth(receipt as unknown as ContractReceipt, POLYGON_BRIDGE_ADDRESS.toLowerCase());
const emitterAddress = getEmitterAddressEth(POLYGON_NFT_BRIDGE_ADDRESS);

console.log({sequence, emitterAddress})

// Fetch the signedVAA from the Wormhole Network (this may require retries while you wait for confirmation)
const { vaaBytes } = await getSignedVAAWithRetry(
WORMHOLE_RPC_HOSTS_MAINNET,
Expand All @@ -29,8 +25,6 @@ export const getVAAFromPolygonTransactionSignature = async (receipt: Transaction
sequence
);

console.log({vaaBytes: Buffer.from(vaaBytes).toString("hex")});

return {
sequence,
emitterAddress,
Expand Down
14 changes: 0 additions & 14 deletions ui/src/api/solanaRetirement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ export class SolanaRetirement {

async getState(): Promise<SolanaStateAccount | null> {
const state = await this.program.account.state.fetchNullable(new PublicKey(this.stateAddress));
console.log("State:", state);
return state;
}

Expand All @@ -97,7 +96,6 @@ export class SolanaRetirement {
const tokenAccount = getAssociatedTokenAddressSync(mint, owner, true);

const notify = () => {
console.log("Getting balance for token account", tokenAccount.toBase58(), ", mint ", mint.toBase58(), " and owner ", owner.toBase58());
this.solConnection.getTokenAccountBalance(tokenAccount).then((balance) => {
callback(BigInt(balance.value.amount));
}).catch((error) => {
Expand Down Expand Up @@ -195,8 +193,6 @@ export class SolanaRetirement {

const quote = await getQuote(inputMint, BRIDGE_INPUT_MINT_ADDRESS, Number(amount), 20);

console.log("Routes: " + JSON.stringify(quote.route));

const jupiterIx = await getSwapIx(this.tokenAuthority, quote);
const {
computeBudgetInstructions, // The necessary instructions to setup the compute budget.
Expand All @@ -208,8 +204,6 @@ export class SolanaRetirement {
// create the swap instruction proxying the jupiter instruction
const accountMetas = jupiterSwapIx.keys;

console.log({ accountMetas });

// mark the token authority as a non-signer, because it is a PDA owned by the Offset Bridge program
accountMetas.filter((meta) => meta.pubkey.equals(this.tokenAuthority)).forEach(
(meta) => {
Expand Down Expand Up @@ -238,8 +232,6 @@ export class SolanaRetirement {
this.tokenAuthority,
true
);
console.log(`ata: ${ata.toBase58()}`);

const ataAccountInfo = await this.solConnection.getAccountInfo(ata)
let preIxs: TransactionInstruction[] = [];
preIxs.push(...preInstructions ?? []);
Expand Down Expand Up @@ -285,13 +277,11 @@ export class SolanaRetirement {
}

async depositAndSwap(inputMint: PublicKey, amount: bigint) : Promise<VersionedTransaction> {
console.log("Swapping: ", amount, "of", inputMint.toBase58());
return this.swap(inputMint, amount, [this.makeDepositIx(inputMint, amount)]);
}

async wrapAndSwap(amountToDeposit: bigint, amountToWrap: bigint = 0n) : Promise<VersionedTransaction> {
const preInstructions = amountToDeposit > 0n ? await this.makeDepositAndWrapSolIxes(amountToDeposit) : await this.makeWrapSolIx();
console.log("Swapping: ", amountToDeposit + amountToWrap, " lamports");
return this.swap(WRAPPED_SOL_TOKEN_MINT, amountToDeposit + amountToWrap, preInstructions);
}

Expand Down Expand Up @@ -386,10 +376,6 @@ export class SolanaRetirement {
const mintToIx = response.transaction.message.instructions[response.transaction.message.instructions.length - 1];
const mintAccountIndex = mintToIx.accounts[1];

console.log("Mint account index:", mintAccountIndex);
console.log("Total accounts for ix:", mintToIx.accounts.length);
console.log("Ix program ID:", response.transaction.message.accountKeys[mintToIx.programIdIndex].toBase58());

return response.transaction.message.accountKeys[mintAccountIndex];
}

Expand Down
4 changes: 0 additions & 4 deletions ui/src/context/solanaRetirementContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ export const SolanaRetirementProvider: FC<PropsWithChildren> = ({children}) => {
const solanaStateAddress = useAppStore(state => state.solanaStateAddress);

useEffect(() => {
console.log("SolanaRetirementProvider useEffect");
if (wallet && holdingContractTarget && solanaStateAddress) {
console.log("SolanaRetirementProvider useEffect: creating SolanaRetirement api");
console.log("SolanaRetirementProvider useEffect: State Address:", solanaStateAddress)
console.log("SolanaRetirementProvider useEffect: Target:", holdingContractTarget);
SolanaRetirement.build(
wallet,
connection,
Expand Down
2 changes: 1 addition & 1 deletion ui/src/hooks/holdingContract/useHoldingContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const useHoldingContract = () => {
return writeContract(config.request)
}, [holdingContractTarget]);

console.log("data", reads.data);
console.log("Holding Contract:", reads.data);

return {
reads,
Expand Down
1 change: 0 additions & 1 deletion ui/src/hooks/holdingContract/useHoldingContractFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export const useHoldingContractFactory = (retirementProject = DEFAULT_RETIREMENT
, [read.data, deploy.data, read.isRefetching]);

const create = async () => {
console.log('create', {deploy, read, config});
if (!deploy.writeAsync) return;
return deploy.writeAsync();
}
Expand Down
4 changes: 0 additions & 4 deletions ui/src/hooks/holdingContract/useOffset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import {useAppStore} from "@/app/providers";

export const useOffset = () => {
const holdingContractTarget = useAppStore(state => state.holdingContractTarget);
console.log("useOffset", {
holdingContractTarget,
})
const { config, error, isError } = usePrepareContractWrite({
address: holdingContractTarget,
abi: HOLDING_CONTRACT_ABI,
Expand All @@ -15,7 +12,6 @@ export const useOffset = () => {
args:[ "Sunrise", "Climate-Positive Staking on Solana" ],
})
const offset = useContractWrite(config)
if (isError) console.log("offset error", error);

if (!offset.writeAsync) return undefined;

Expand Down
2 changes: 0 additions & 2 deletions ui/src/hooks/useBridgeRetirementCert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,5 @@ export const useBridgeRetirementCert = () => {
args: [BigInt(nftToRetire.tokenId), solanaAddressToHex(new PublicKey(nftToRetire.solanaTokenAddress))]
})

if (bridgePrepare.isError) console.log(bridgePrepare.error)

return useContractWrite(bridgePrepare.config)
}
6 changes: 0 additions & 6 deletions ui/src/hooks/useToucan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@ export const useToucan = () => {
}
`;

console.log("Querying for all NCT tokens")

const result = await toucan.fetchCustomQuery<PooledTokenLookup>(query, { poolAddress: NCT_TOKEN_ADDRESS });

console.log({result})

if (!result) return [];

return result.pooledTCO2Tokens.map((pooledToken) => pooledToken.token);
Expand Down Expand Up @@ -83,8 +79,6 @@ export const useToucan = () => {
}))
});

console.log({tokenIds, data})

if (!data) return [];

return data
Expand Down
1 change: 0 additions & 1 deletion ui/src/hooks/useVerra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const useVerra = (project: PooledTCO2Token | undefined): VerraResource |
const [link, setLink] = useState<string>()

useEffect(() => {
console.log("project", project)
if (!project) return;
const resourceId = projectToResourceId(project);
setLink(VERRA_URL + resourceId);
Expand Down
1 change: 0 additions & 1 deletion ui/src/lib/prices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const PRICES: Prices = {
fetch("https://api.sunrisestake.com/prices")
.then(async (res) => res.json())
.then(({ solana, "toucan-protocol-nature-carbon-tonne": nct }) => {
console.log("Prices", { solana, nct });
PRICES.solana = Number(solana.usd) * 100;
PRICES.nct = Number(nct.usd) * 100;
})
Expand Down
1 change: 0 additions & 1 deletion ui/src/pages/step1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export default function Step1() {
const [holdingContractUpdateReady, setHoldingContractUpdateReady] = useState(false);

const ready = useMemo(() => {
console.log("Step1: ready", api?.ready, holdingContract?.tco2, holdingContractUpdateReady);
const solanaState = api?.state;
const holdingContractDeployed = !!holdingContract?.tco2;
return api?.ready && solanaState && holdingContractDeployed && holdingContractUpdateReady;
Expand Down
2 changes: 0 additions & 2 deletions ui/src/pages/step2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,9 @@ export default function Step2() {
name: token.symbol
}));
const CarbonAmount:FC<{ tokenAmount: bigint | undefined }> = ({ tokenAmount }) => {
console.log('tokenAmount', tokenAmount)
if (tokenAmount === undefined) return <span className="loading loading-spinner text-primary"/>;

const carbonAmount = isSolSelected ? lamportsToCarbon(Number(tokenAmount)) : usdcToCarbon(tokenAmount);
console.log('carbonAmount', carbonAmount)

return <span>
{formatDecimal(tokenAmount, selectedInputToken.decimals)} {selectedInputToken.symbol} ( {toFixedWithPrecision(carbonAmount, 2)} tCO₂E )
Expand Down
9 changes: 1 addition & 8 deletions ui/src/pages/step4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,7 @@ export default function Step4() {
}

const handleRetire = async () => {
if (offset?.error) console.log("OFFSET ERROR", offset.error);
if (!offset || !offset.writeAsync || !retireEnabled) {
console.log("offset not ready", {
offset,
retireEnabled
})
return;
}
if (!offset || !offset.writeAsync || !retireEnabled) return;
offset.writeAsync().then(result => retireInProgress(result.hash))
.catch(retireFailed);
};
Expand Down
1 change: 0 additions & 1 deletion ui/src/pages/step5.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export default function Step5() {
}

const getVAAFailed = (error: Error) => {
console.log(error);
toast.error(<div>
Failed to retrieve information from bridge: {error.message}
</div>);
Expand Down

0 comments on commit 0baef09

Please sign in to comment.