Skip to content

Commit

Permalink
create ata for the redeem process
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianscatularo committed Aug 11, 2023
1 parent 7e08a5c commit 44d3c21
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/assets/providers/tbtc/solana/WormholeGateway.v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,20 @@ export function newThresholdWormholeGateway(
custodianData.wrappedTbtcMint as string
);
const recipientToken = await Token.getAssociatedTokenAddress(
ASSOCIATED_TOKEN_PROGRAM_ID,
TOKEN_PROGRAM_ID,
tbtcMint,
recipient
);
ASSOCIATED_TOKEN_PROGRAM_ID,
TOKEN_PROGRAM_ID,
tbtcMint,
recipient
);
const recipientTokenAta = Token.createAssociatedTokenAccountInstruction(
ASSOCIATED_TOKEN_PROGRAM_ID,
TOKEN_PROGRAM_ID,
tbtcMint,
recipientToken,
recipient, // owner
recipient // payer
)
console.log(recipientToken);
const tokenBridgeWrappedAsset = tokenBridge.deriveWrappedMetaKey(
TOKEN_BRIDGE_PROGRAM_ID,
wrappedTbtcMint
Expand Down Expand Up @@ -222,11 +231,13 @@ export function newThresholdWormholeGateway(
tokenBridgeProgram: TOKEN_BRIDGE_PROGRAM_ID,
coreBridgeProgram: CORE_BRIDGE_PROGRAM_ID,
};
const tx = program.methods
const tx = await program.methods
.receiveTbtc(parsed.hash)
.accounts(accounts)
.transaction();
return tx;
return new Transaction()
.add(recipientTokenAta)
.add(tx);
};

const sendTbtc = async (
Expand Down Expand Up @@ -305,8 +316,6 @@ export function newThresholdWormholeGateway(
tokenBridgeProgram: TOKEN_BRIDGE_PROGRAM_ID,
coreBridgeProgram: CORE_BRIDGE_PROGRAM_ID
}
console.log('accounts', Object.entries(wrappedAccounts).map(([k, v]) => [k, v.toBase58()]));
console.log('args', Object.entries(args).map(([k, v]) => [k, v.toString()]));
return sendTbtcWrapped(program, args, wrappedAccounts);
} else {
const gatewayAccounts = {
Expand Down
6 changes: 6 additions & 0 deletions src/components/TokenSelectors/EvmTokenPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ export default function EvmTokenPicker(

const isMigrationEligible = useCallback(
(address: string) => {
// TODO at the end of a transfer from from Solanato Eth an error happens
/**
* Select as source solana
* Select as target eth
* Sent the tokens, and hit transfer more tokens button
*/
const assetMap = getMigrationAssetMap(chainId);
return !!assetMap.get(getEthAddress(address));
},
Expand Down

0 comments on commit 44d3c21

Please sign in to comment.