mirror of https://github.com/certusone/oyster.git
feat: transfer
This commit is contained in:
parent
a9fc4dbf8d
commit
b0ae8b4c88
|
@ -95,50 +95,68 @@ export const Transfer = () => {
|
|||
return;
|
||||
}
|
||||
try {
|
||||
const bridgeAddress = programIds().wormhole.bridge;
|
||||
|
||||
let signer = provider.getSigner();
|
||||
let e = WrappedAssetFactory.connect(asset, provider);
|
||||
let addr = await signer.getAddress();
|
||||
let balance = await e.balanceOf(addr);
|
||||
let decimals = await e.decimals();
|
||||
let symbol = await e.symbol();
|
||||
if(request.from === ASSET_CHAIN.Solana) {
|
||||
const bridgeAddress = programIds().wormhole.bridge;
|
||||
|
||||
let allowance = await e.allowance(addr, bridgeAddress);
|
||||
let signer = provider.getSigner();
|
||||
let e = WrappedAssetFactory.connect(asset, provider);
|
||||
let addr = await signer.getAddress();
|
||||
let balance = await e.balanceOf(addr);
|
||||
let decimals = await e.decimals();
|
||||
let symbol = await e.symbol();
|
||||
|
||||
let info = {
|
||||
address: asset,
|
||||
name: symbol,
|
||||
balance: balance,
|
||||
balanceAsNumber:
|
||||
new BN(balance.toString())
|
||||
.div(new BN(10).pow(new BN(decimals - 2)))
|
||||
.toNumber() / 100,
|
||||
allowance: allowance,
|
||||
decimals: decimals,
|
||||
isWrapped: false,
|
||||
chainID: ASSET_CHAIN.Ethereum,
|
||||
assetAddress: Buffer.from(asset.slice(2), 'hex'),
|
||||
mint: '',
|
||||
};
|
||||
let allowance = await e.allowance(addr, bridgeAddress);
|
||||
|
||||
let b = WormholeFactory.connect(bridgeAddress, provider);
|
||||
let info = {
|
||||
address: asset,
|
||||
name: symbol,
|
||||
balance: balance,
|
||||
balanceAsNumber:
|
||||
new BN(balance.toString())
|
||||
.div(new BN(10).pow(new BN(decimals - 2)))
|
||||
.toNumber() / 100,
|
||||
allowance: allowance,
|
||||
decimals: decimals,
|
||||
isWrapped: false,
|
||||
chainID: ASSET_CHAIN.Ethereum,
|
||||
assetAddress: Buffer.from(asset.slice(2), 'hex'),
|
||||
mint: '',
|
||||
};
|
||||
|
||||
let isWrapped = await b.isWrappedAsset(asset);
|
||||
if (isWrapped) {
|
||||
info.chainID = await e.assetChain();
|
||||
info.assetAddress = Buffer.from(
|
||||
(await e.assetAddress()).slice(2),
|
||||
'hex',
|
||||
);
|
||||
info.isWrapped = true;
|
||||
let b = WormholeFactory.connect(bridgeAddress, provider);
|
||||
|
||||
let isWrapped = await b.isWrappedAsset(asset);
|
||||
if (isWrapped) {
|
||||
info.chainID = await e.assetChain();
|
||||
info.assetAddress = Buffer.from(
|
||||
(await e.assetAddress()).slice(2),
|
||||
'hex',
|
||||
);
|
||||
info.isWrapped = true;
|
||||
}
|
||||
|
||||
setRequest({
|
||||
...request,
|
||||
asset,
|
||||
info,
|
||||
});
|
||||
} else {
|
||||
console.log(asset);
|
||||
// let info = {
|
||||
// address: fromAddress,
|
||||
// name: "",
|
||||
// balance: acc.balance,
|
||||
// allowance: 0,
|
||||
// decimals: acc.assetMeta.decimals,
|
||||
// isWrapped: acc.assetMeta.chain != ChainID.SOLANA,
|
||||
// chainID: acc.assetMeta.chain,
|
||||
// assetAddress: acc.assetMeta.address,
|
||||
|
||||
// // Solana specific
|
||||
// mint: acc.mint,
|
||||
// };
|
||||
}
|
||||
|
||||
setRequest({
|
||||
...request,
|
||||
asset,
|
||||
info,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e.toString());
|
||||
notify({
|
||||
|
|
|
@ -17,10 +17,10 @@ const WormholeCanvas = ({
|
|||
rotate?: boolean;
|
||||
}) => {
|
||||
return (
|
||||
<Canvas onCreated={onCreated}>
|
||||
<Canvas onCreated={onCreated} style={{ opacity: 0.4 }}>
|
||||
<Camera />
|
||||
<React.Suspense fallback={null}>
|
||||
<WormholeGeometry rotate={rotate} />
|
||||
<WormholeGeometry rotate={rotate}/>
|
||||
</React.Suspense>
|
||||
</Canvas>
|
||||
);
|
||||
|
|
|
@ -15,15 +15,8 @@ import { ASSET_CHAIN } from '../../../utils/assets';
|
|||
import { BigNumber } from 'ethers/utils';
|
||||
import { Erc20Factory } from '../../../contracts/Erc20Factory';
|
||||
import { WormholeFactory } from '../../../contracts/WormholeFactory';
|
||||
import { AssetMeta, createWrappedAssetInstruction } from './../meta';
|
||||
import { bridgeAuthorityKey, wrappedAssetMintKey } from './../helpers';
|
||||
import {
|
||||
Account,
|
||||
Connection,
|
||||
PublicKey,
|
||||
SystemProgram,
|
||||
TransactionInstruction,
|
||||
} from '@solana/web3.js';
|
||||
import { bridgeAuthorityKey } from './../helpers';
|
||||
import { Connection, PublicKey, SystemProgram } from '@solana/web3.js';
|
||||
import { Token } from '@solana/spl-token';
|
||||
import { ProgressUpdate, TransferRequest } from './interface';
|
||||
import BN from 'bn.js';
|
||||
|
|
Loading…
Reference in New Issue