-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f0b51e
commit 49b7561
Showing
20 changed files
with
582 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ANCHOR_PROVIDER_URL= | ||
ANCHOR_WALLET= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,6 @@ test-ledger | |
|
||
devnet.json | ||
yarn-error.log | ||
|
||
.env* | ||
!.env.example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { FundSenderClient } from "../client"; | ||
import { logBalance } from "./lib/util"; | ||
import {PublicKey} from "@solana/web3.js"; | ||
|
||
// USAGE: yarn ts-node packages/fund-sender/getStateFromAddress.ts stateAddress | ||
const stateAddress = process.argv[2]; | ||
|
||
(async () => { | ||
const client = await FundSenderClient.fetch(new PublicKey(stateAddress)); | ||
const log = logBalance(client); | ||
|
||
console.log("state address", stateAddress); | ||
console.log("state account data", { | ||
destinationName: client.config.destinationName, | ||
updateAuthority: client.config.updateAuthority.toBase58(), | ||
destinationAccount: client.config.destinationAccount.toBase58(), | ||
certificateVault: client.config.certificateVault.toBase58(), | ||
spendThreshold: client.config.spendThreshold.toNumber(), | ||
}); | ||
console.log("input address", client.getInputAccount().toBase58()); | ||
|
||
await log("input token", client.getInputAccount()); | ||
})().catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { FundSenderClient } from "../client"; | ||
import { PublicKey } from "@solana/web3.js"; | ||
|
||
// mainnet Sunrise | ||
const defaultSunriseStateAddress = | ||
"43m66crxGfXSJpmx5wXRoFuHubhHA1GCvtHgmHW6cM1P"; | ||
const sunriseStateAddress = new PublicKey( | ||
process.env.STATE_ADDRESS ?? defaultSunriseStateAddress | ||
); | ||
|
||
// USAGE: yarn ts-node packages/fund-sender/sendFromState.ts destinationName | ||
const destinationName = process.argv[2]; | ||
|
||
(async () => { | ||
const stateAddress = FundSenderClient.getStateAddressFromSunriseAddress( | ||
sunriseStateAddress, | ||
destinationName | ||
); | ||
const client = await FundSenderClient.fetch(stateAddress); | ||
|
||
console.log("state address", stateAddress.toBase58()); | ||
console.log("input address", client.getInputAccount().toBase58()); | ||
|
||
const stateBalance = await client.provider.connection.getBalance(stateAddress); | ||
console.log("state balance", stateBalance); | ||
|
||
console.log("Sending fund..."); | ||
await client.sendFromState(); | ||
})().catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import {showData} from "./util"; | ||
import {showMenu} from "./prompt"; | ||
|
||
await showData(); | ||
|
||
showMenu(); | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import chalk from 'chalk'; | ||
import readlineSync from 'readline-sync'; | ||
import {showData} from "./util"; | ||
import {submenuRouteToRecipient} from "./submenu/routeToRecipient"; | ||
import {submenuAllocateYield} from "./submenu/allocateYield"; | ||
|
||
export const showMenu = async () => { | ||
console.log(chalk.magentaBright('\nChoose an option:')); | ||
console.log(chalk.cyanBright('1) Refresh')); | ||
console.log(chalk.cyanBright('2) Allocate Yield')); | ||
console.log(chalk.cyanBright('3) Route Funds to Recipient')); | ||
console.log(chalk.cyanBright('4) Update Proportions')); | ||
console.log(chalk.cyanBright('5) Add Recipient')); | ||
console.log(chalk.cyanBright('6) Remove Recipient')); | ||
console.log(chalk.cyanBright('7) Quit')); | ||
|
||
const choice = readlineSync.keyIn(chalk.yellow('\nEnter your choice: '), { limit: '$<1-7>' }); | ||
|
||
switch (choice) { | ||
case '1': | ||
console.log(chalk.green('Refreshing...')); | ||
await showData(); | ||
break; | ||
case '2': | ||
await submenuAllocateYield(); | ||
break; | ||
case '3': | ||
await submenuRouteToRecipient(); | ||
break; | ||
case '4': | ||
console.log(chalk.green('Updating proportions...')); | ||
// Call your update proportions function here | ||
break; | ||
case '5': | ||
console.log(chalk.green('Adding recipient...')); | ||
// Call your add recipient function here | ||
break; | ||
case '6': | ||
console.log(chalk.green('Removing recipient...')); | ||
// Call your remove recipient function here | ||
break; | ||
case '7': | ||
console.log(chalk.green('Exiting...')); | ||
process.exit(0); | ||
break; | ||
default: | ||
console.log(chalk.red('Invalid choice, please try again.')); | ||
showMenu(); // Re-display menu for invalid input | ||
break; | ||
} | ||
showMenu(); | ||
}; |
Oops, something went wrong.