Skip to content

Commit

Permalink
Merge pull request #114 from aankor/fix-rename-ts
Browse files Browse the repository at this point in the history
Downgrade anchor to release and rename ixes in ts code
  • Loading branch information
kiseln authored Nov 13, 2024
2 parents a289f34 + a8d5888 commit 3067c16
Show file tree
Hide file tree
Showing 14 changed files with 955 additions and 1,071 deletions.
11 changes: 10 additions & 1 deletion solana/bridge_token_factory/Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ resolution = true
skip-lint = false

[programs.localnet]
bridge_token_factory = "2ajXVaqXXpHWtPnW3tKZukuXHGGjVcENjuZaWrz6NhD4"
bridge_token_factory = "3ZtEZ8xABFbUr4c1FVpXbQiVdqv4vwhvfCc8HMmhEeua"

[registry]
url = "https://api.apr.dev"
Expand All @@ -14,5 +14,14 @@ url = "https://api.apr.dev"
cluster = "Localnet"
wallet = "~/.config/solana/id.json"

[test]
startup_wait = 20000
shutdown_wait = 2000
upgradeable = false

[[test.genesis]]
address = "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth"
program = "assets/wormhole.so"

[scripts]
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
50 changes: 33 additions & 17 deletions solana/bridge_token_factory/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion solana/bridge_token_factory/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"license": "ISC",
"scripts": {
"copy-idl": "copyfiles -u 2 target/types/bridge_token_factory.ts ts/sdk/src && copyfiles -u 2 target/idl/bridge_token_factory.json ts/sdk/src"
"copy-idl": "copyfiles -u 2 target/types/bridge_token_factory.ts ts/sdk/src && copyfiles -u 2 target/idl/bridge_token_factory.json ts/sdk/src",
"build-devnet": "PROGRAM_ID=\"3ZtEZ8xABFbUr4c1FVpXbQiVdqv4vwhvfCc8HMmhEeua\" anchor build -- --features devnet",
"build-test": "PROGRAM_ID=\"3ZtEZ8xABFbUr4c1FVpXbQiVdqv4vwhvfCc8HMmhEeua\" anchor build -- --features mainnet"
},
"devDependencies": {
"@types/bn.js": "^5.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@ cpi = ["no-entrypoint"]
no-entrypoint = []
no-idl = []
no-log-ix-name = []
idl-build = ["anchor-lang/idl-build", "anchor-spl/idl-build", "wormhole-anchor-sdk/idl-build"]
idl-build = [
"anchor-lang/idl-build",
"anchor-spl/idl-build",
"wormhole-anchor-sdk/idl-build",
"wormhole-anchor-sdk/mainnet",
]
devnet = ["wormhole-anchor-sdk/solana-devnet"]
mainnet = ["wormhole-anchor-sdk/mainnet"]

[dependencies]
anchor-lang = { version = "0.30.1", git = "https://github.com/coral-xyz/anchor/", rev = "06527e57c3e59683c36eb0a5c69ee669100b42e5", features = ["init-if-needed"] }
anchor-spl = { version = "0.30.1", git = "https://github.com/coral-xyz/anchor/", rev = "06527e57c3e59683c36eb0a5c69ee669100b42e5", features = ["metadata"] }
anchor-lang = { version = "0.30.1", features = ["init-if-needed"] }
anchor-spl = { version = "0.30.1", features = ["metadata"] }
cfg-if = "1.0.0"
near-sdk = "5.5.0"
wormhole-anchor-sdk = { git = "https://github.com/wormhole-foundation/wormhole-scaffolding.git", rev = "962ef4841697980474854edea192d26b01d27848", default-features = false, features = ["solana-devnet"]}
wormhole-anchor-sdk = { git = "https://github.com/aankor/wormhole-scaffolding.git", branch = "anchor0.30.1", default-features = false }


[dependencies.bitvec]
Expand Down
11 changes: 11 additions & 0 deletions solana/bridge_token_factory/programs/bridge_token_factory/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use std::{env, fs, path::Path};

fn main() {
println!("cargo:rerun-if-changed=build.rs");

let program_id = env::var("PROGRAM_ID").unwrap();

let out_dir = env::var_os("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("program_id.rs");
fs::write(&dest_path, format!("declare_id!(\"{}\");", program_id)).unwrap();
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use state::message::{
init_transfer::InitTransferPayload, SignedPayload,
};

declare_id!("5Q8uh6bK5e7zQ2tV8iGrAzUgRQcC9mvCzKQn6uPW2CGp");
include!(concat!(env!("OUT_DIR"), "/program_id.rs"));

#[program]
pub mod bridge_token_factory {
Expand Down
16 changes: 8 additions & 8 deletions solana/bridge_token_factory/ts/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import {Command} from 'commander';
import {setupContext} from './context';
import {installInitializeCLI} from './initialize';
import {installDeployTokenCLI} from './deployToken';
import {installFinalizeDepositCLI} from './finalizeDeposit';
import {installRepayCLI} from './repay';
import {installFinalizeTransferBridgedCLI} from './finalizeTransferBridged';
import {installInitTransferBridgedCLI} from './initTransferBridged';
import {installRegisterMintCLI} from './registerMint';
import {installCreateTokenCLI} from './createToken';
import {installFinalizeWithdrawCLI} from './finalizeWithdraw';
import {installSendCLI} from './send';
import {installFinalizeTransferNativeCLI} from './finalizeTransferNative';
import {installInitTransferNativeCLI} from './initTransferNative';

export function cli() {
const program = new Command();
Expand All @@ -29,11 +29,11 @@ export function cli() {
installCreateTokenCLI(program);
installInitializeCLI(program);
installDeployTokenCLI(program);
installFinalizeDepositCLI(program);
installRepayCLI(program);
installFinalizeTransferBridgedCLI(program);
installInitTransferBridgedCLI(program);
installRegisterMintCLI(program);
installFinalizeWithdrawCLI(program);
installSendCLI(program);
installFinalizeTransferNativeCLI(program);
installInitTransferNativeCLI(program);

return program;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import {executeTx} from './executor';
import BN from 'bn.js';
import {parsePubkey} from './keyParser';

export function installFinalizeDepositCLI(program: Command) {
export function installFinalizeTransferBridgedCLI(program: Command) {
program
.command('finalize-deposit')
.description('Finalize the deposit')
.command('finalize-transfer-bridged')
.description('Finalize bridged transfer')
.requiredOption('--token <string>', 'Near token address')
.requiredOption('--nonce <string>', 'Nonce')
.requiredOption('--amount <number>', 'Amount')
Expand All @@ -31,7 +31,7 @@ export function installFinalizeDepositCLI(program: Command) {
const recipientPk = recipient
? await parsePubkey(recipient)
: sdk.provider.publicKey!;
const {instructions, signers} = await sdk.finalizeDeposit({
const {instructions, signers} = await sdk.finalizeTransferBridged({
token,
nonce: new BN(nonce),
amount: new BN(amount),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import {executeTx} from './executor';
import BN from 'bn.js';
import {parsePubkey} from './keyParser';

export function installFinalizeWithdrawCLI(program: Command) {
export function installFinalizeTransferNativeCLI(program: Command) {
program
.command('finalize-withdraw')
.description('Finalize the withdraw')
.command('finalize-transfer-native')
.description('Finalize native transfer')
.requiredOption('--mint <pubkey>', 'Mint address')
.requiredOption('--nonce <string>', 'Nonce')
.requiredOption('--amount <number>', 'Amount')
Expand All @@ -32,7 +32,7 @@ export function installFinalizeWithdrawCLI(program: Command) {
const recipientPk = recipient
? await parsePubkey(recipient)
: sdk.provider.publicKey!;
const {instructions, signers} = await sdk.finalizeWithdraw({
const {instructions, signers} = await sdk.finalizeTransferNative({
mint: mintPk,
nonce: new BN(nonce),
amount: new BN(amount),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,32 @@ import {getContext} from './context';
import {executeTx} from './executor';
import BN from 'bn.js';

export function installRepayCLI(program: Command) {
export function installInitTransferBridgedCLI(program: Command) {
program
.command('repay')
.description('Repay')
.command('init-transfer-bridged')
.description('Init bridged transfer')
.requiredOption('--token <string>', 'Token address')
.requiredOption('--amount <number>', 'Amount')
.requiredOption('--recipient <address>', 'Recipient')
.option('--fee <number>', 'Fee', '0')
.action(
async ({
token,
amount,
recipient,
fee,
}: {
token: string;
amount: string;
recipient: string;
fee?: string;
}) => {
const {sdk} = getContext();
const {instructions, signers} = await sdk.repay({
const {instructions, signers} = await sdk.initTransferBridged({
token,
amount: new BN(amount),
recipient,
fee: fee ? new BN(fee) : new BN(0),
});
await executeTx({instructions, signers});
},
Expand Down
Loading

0 comments on commit 3067c16

Please sign in to comment.