Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
artursapek committed Jul 3, 2024
1 parent b5d8411 commit 2f29106
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 79 deletions.
2 changes: 1 addition & 1 deletion wormhole-connect/src/config/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class SDKConverter {
if (this.isTokenConfigV1(token)) {
if (chain && chain != token.nativeChain) {
// Getting foreign address
let foreignAsset = token.foreignAssets?.[chain];
const foreignAsset = token.foreignAssets?.[chain];
if (foreignAsset) {
return v2.Wormhole.tokenId(
this.toChainV2(chain),
Expand Down
95 changes: 46 additions & 49 deletions wormhole-connect/src/routes/sdkv2/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ export class SDKv2Signer<N extends Network, C extends Chain>
}

async signAndSend(txs: UnsignedTransaction<N, C>[]): Promise<TxHash[]> {
let txHashes: TxHash[] = [];
const txHashes: TxHash[] = [];

for (let tx of txs) {
let request: SignRequest = this.createSignRequest(tx);
for (const tx of txs) {
const request: SignRequest = this.createSignRequest(tx);

let txId = await signAndSendTransaction(
const txId = await signAndSendTransaction(
this._chainNameV1,
request,
TransferWallet.SENDING,
Expand All @@ -77,51 +77,48 @@ export class SDKv2Signer<N extends Network, C extends Chain>
private createSignRequest(tx: UnsignedTransaction<N, C>): SignRequest {
const platform = chainToPlatform(tx.chain);

switch (platform) {
case 'Evm':
// TODO switch multi-provider to ethers 6
// and remove this ethers5-to-6 conversion
let serialized = ethers6.Transaction.from({
to: tx.transaction.to,
data: tx.transaction.data,
}).unsignedSerialized;
let tx5: ethers5.Transaction =
ethers5.utils.parseTransaction(serialized);
let unsignedTx: Deferrable<TransactionRequest> = {
to: tx5.to,
type: tx5.type as number,
chainId: tx5.chainId,
data: tx5.data,
};
return {
platform,
transaction: unsignedTx,
};
case 'Solana':
return {
platform,
transaction: tx.transaction.transaction,
};
case 'Cosmwasm':
debugger;
return {
platform,
transaction: tx,
};
case 'Sui':
return {
platform,
transaction: tx,
};
case 'Aptos':
return {
platform,
transaction: tx.transaction,
};
default:
throw new Error(
`toSendResult is unimplemented for platform ${platform}`,
);
if (platform === 'Evm') {
// TODO switch multi-provider to ethers 6
// and remove this ethers5-to-6 conversion
const serialized = ethers6.Transaction.from({
to: tx.transaction.to,
data: tx.transaction.data,
}).unsignedSerialized;
const tx5: ethers5.Transaction =
ethers5.utils.parseTransaction(serialized);
const unsignedTx: Deferrable<TransactionRequest> = {
to: tx5.to,
type: tx5.type as number,
chainId: tx5.chainId,
data: tx5.data,
};
return {
platform,
transaction: unsignedTx,
};
} else if (platform === 'Solana') {
return {
platform,
transaction: tx.transaction.transaction,
};
} else if (platform === 'Cosmwasm') {
//debugger;
return {
platform,
transaction: tx,
};
} else if (platform === 'Sui') {
return {
platform,
transaction: tx,
};
} else if (platform === 'Aptos') {
return {
platform,
transaction: tx.transaction,
};
} else {
throw new Error(`toSendResult is unimplemented for platform ${platform}`);
//return tx as SendResult;
}
}
Expand Down
40 changes: 19 additions & 21 deletions wormhole-connect/src/sdklegacy/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
Wormhole Connect SDK
--------------------

## Wormhole Connect SDK

An SDK that wraps the core Wormhole SDK and provides a convenient API to interact with the Wormhole Token Bridge protocol.

Here is an example showing how to send a token across chains using this SDK:

Here is an example showing how to send a token across chains using this SDK:
```ts
const context = new WormholeContext('MAINNET');
// interact easily with any chain!
// supports EVM, Solana, Terra, etc
const tokenId = {
chain: 'ethereum',
address: '0x123...',
}
const context = new WormholeContext('MAINNET');

// interact easily with any chain!
// supports EVM, Solana, Terra, etc
const tokenId = {
chain: 'ethereum',
address: '0x123...',
};

const receipt = context.send(
tokenId,
'10', // amount
'ethereum', // sending chain
'0x789...', // sender address
'moonbeam', // destination chain
'0x789...', // recipient address on destination chain
)
```
const receipt = context.send(
tokenId,
'10', // amount
'ethereum', // sending chain
'0x789...', // sender address
'moonbeam', // destination chain
'0x789...', // recipient address on destination chain
);
```
4 changes: 3 additions & 1 deletion wormhole-connect/src/sdklegacy/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export const waitFor = (
clearInterval(interval);
resolve();
}
} catch (e) {}
} catch (e) {
console.error(e);
}

count++;
}, ms);
Expand Down
16 changes: 12 additions & 4 deletions wormhole-connect/src/sdklegacy/wormhole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ export class WormholeContext extends MultiProvider<Domain> {
// BEGIN stubbed methods for SDKV2 migration
// TODO SDKV2

sign() {}
sign() {
console.log('TODO remove');
}

async approve(a: any, b: any, c: any, d: any): Promise<boolean> {
return true;
Expand All @@ -206,12 +208,18 @@ export class WormholeContext extends MultiProvider<Domain> {
}

/* @ts-ignore */
mustGetProvider(a: any) {}
mustGetProvider(a: any) {
console.log('TODO remove');
}

get contracts() {
return {
mustGetCore(a: any) {},
mustGetBridge(a: any) {},
mustGetCore(a: any) {
console.log('TODO remove');
},
mustGetBridge(a: any) {
console.log('TODO remove');
},
};
}
}
2 changes: 1 addition & 1 deletion wormhole-connect/src/utils/wallet/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function signAndSendTransaction(
if (!signer) throw new Error('No signer found for chain' + chainName);

const tx = await signer.sendTransaction(request.transaction);
let result = await tx.wait();
const result = await tx.wait();

// TODO move all this to ethers 6
/* @ts-ignore */
Expand Down
4 changes: 2 additions & 2 deletions wormhole-connect/src/views/Redeem/BridgeComplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ function BridgeComplete() {
dispatch(setRoute('bridge'));
};

let containerBg: string | undefined = undefined;
let component: React.JSX.Element = (
const containerBg: string | undefined = undefined;
const component: React.JSX.Element = (
<div data-testid="transaction-complete-message">
The bridge is now complete.
</div>
Expand Down

0 comments on commit 2f29106

Please sign in to comment.