Skip to content

Commit

Permalink
fix address of xfer instruction, fix get decimals to return bigint
Browse files Browse the repository at this point in the history
  • Loading branch information
barnjamin committed Oct 17, 2023
1 parent d60b7cf commit 28b6b4e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/base/src/utils/amount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function normalizeAmount(

// combine whole and partial without decimals
const amt = BigInt(whole + partial);

// adjust number of decimals to account for decimals accounted for
// when we remove the decimal place for amt
decimals -= BigInt(partial.length);
Expand Down
15 changes: 14 additions & 1 deletion examples/src/helpers/signers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
TxClient,
createTransaction,
} from "@injectivelabs/sdk-ts";
import { Keypair } from "@solana/web3.js";
import { Keypair, Transaction } from "@solana/web3.js";
import {
ChainName,
PlatformToChains,
Expand Down Expand Up @@ -88,9 +88,22 @@ export class SolSigner implements Signer {
const signed = [];
for (const txn of tx) {
const { description, transaction } = txn;

console.log(`Signing: ${description} for ${this.address()}`);
transaction.partialSign(this._keypair);
signed.push(transaction.serialize());

// Uncomment for debug
//const st = transaction as Transaction;
//console.log(st.signatures);
//console.log(st.feePayer);
//st.instructions.forEach((ix) => {
// console.log("Program", ix.programId.toBase58());
// console.log("Data: ", ix.data.toString("hex"));
// ix.keys.forEach((k) => {
// console.log(k.pubkey.toBase58());
// });
//});
}
return signed;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/src/tokenBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ChainName,
Signer,
normalizeAmount,
nativeChainAddress,
} from "@wormhole-foundation/connect-sdk";
// Import the platform specific packages
import { EvmPlatform } from "@wormhole-foundation/connect-sdk-evm";
Expand All @@ -30,7 +31,6 @@ import { TransferStuff, getStuff, waitLog } from "./helpers";
// Signer interface (e.g. wrapper around web wallet) should work
const source = await getStuff(sendChain);
const destination = await getStuff(rcvChain);

const amt = normalizeAmount("0.01", 18n);

// Choose your adventure
Expand Down
2 changes: 1 addition & 1 deletion platforms/solana/src/platformUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export module SolanaUtils {
if (!mint || !mint.value) throw new Error('could not fetch token details');

const { decimals } = (mint.value.data as ParsedAccountData).parsed.info;
return decimals;
return BigInt(decimals);
}

export async function getBalance(
Expand Down
2 changes: 1 addition & 1 deletion platforms/solana/src/protocols/tokenBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ export class SolanaTokenBridge implements TokenBridge<'Solana'> {

const approvalIx = createApproveAuthoritySignerInstruction(
this.tokenBridge.programId,
token.toUint8Array(),
senderTokenAddress,
senderAddress,
amount,
);
Expand Down

0 comments on commit 28b6b4e

Please sign in to comment.