Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixer mixer #750

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions __tests__/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The `__test__/mocks` directory should contain mocks for things like RPCs and Sig

Each platform should have a `__test__/integration/fixtures` directory that contains fixtures for complex blockchain data structures

Using nock, we can gather the request/responses and using jest.mock, mock the RPC calls to return the fixtures. This allows us to test the code without having to make RPC calls to the blockchain.
Using nock, we can gather the requests/responses and use jest.mock, mock the RPC calls to return the fixtures. This allows us to test the code without having to make RPC calls to the blockchain.


## End-to-End Tests
Expand All @@ -30,4 +30,4 @@ https://github.com/wormhole-foundation/wormhole-circle-integration/blob/main/evm

https://github.com/circlefin/evm-cctp-contracts/blob/master/anvil/crosschainTransferIT.py#L261

-->
-->
14 changes: 7 additions & 7 deletions connect/src/protocols/gateway/gatewayTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ export class GatewayTransfer<N extends Network = Network> implements WormholeTra
private _state: TransferState;

// cached message derived from transfer details
// note: we dont want to create multiple different ones since
// note: we don't want to create multiple different ones since
// the nonce may change and we want to keep it consistent
private msg: GatewayTransferMsg | GatewayTransferWithPayloadMsg;

// Initial Transfer Settings
transfer: GatewayTransferDetails;

// Transaction Ids from source chain
// Transaction IDs from the source chain
transactions: TransactionId[] = [];

// The corresponding vaa representing the GatewayTransfer
// on the source chain (if it came from outside cosmos and if its been completed and finalized)
// on the source chain (if it came from outside cosmos and if it has been completed and finalized)
vaas?: {
id: WormholeMessageId;
vaa?: TokenBridge.TransferVAA;
Expand Down Expand Up @@ -146,7 +146,7 @@ export class GatewayTransfer<N extends Network = Network> implements WormholeTra
gtd = await GatewayTransfer._fromTransaction(wh, from);
} else if (isWormholeMessageId(from)) {
// TODO: we're missing the transaction that created this
// get it from transaction status search on wormholescan?
// get it from a transaction status search on wormholescan?
gtd = await GatewayTransfer._fromMsgId(wh, from);
} else {
throw new Error("Invalid `from` parameter for GatewayTransfer");
Expand Down Expand Up @@ -179,13 +179,13 @@ export class GatewayTransfer<N extends Network = Network> implements WormholeTra
vaa.payloadName === "TransferWithPayload" ? vaa.payload.payload : undefined;

// Nonce for GatewayTransferMessage may be in the payload
// and since we use the payload to find the Wormchain transacton
// and since we use the payload to find the Wormchain transaction
// we need to preserve it
let nonce: number | undefined;

let to: ChainAddress = { ...vaa.payload.to };
// The payload here may be the message for Gateway
// Lets be sure to pull the real payload if its set
// Let's be sure to pull the real payload if it's set
// Otherwise revert to undefined
if (payload) {
try {
Expand All @@ -202,7 +202,7 @@ export class GatewayTransfer<N extends Network = Network> implements WormholeTra
);
to = Wormhole.chainAddress(destChain, recipientAddress);
} catch {
/*Ignoring, throws if not the payload isnt JSON*/
/*Ignoring, throws if not the payload isn't JSON*/
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/base/src/constants/tokens/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ export function getCanonicalToken<N extends Network, C extends Chain>(
const original = getTokensBySymbol(network, token.original, token.symbol);
if (!original) return;

// return the the token with this symbol where no `original` field exists
// return the token with this symbol where no `original` field exists
return original.find((t) => !t.original);
}
2 changes: 1 addition & 1 deletion core/definitions/__tests__/governanceVaa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const guardianSetUpgrade =
/*nonce*/ "9e0c5dfa" +
/*emitterChain*/ "0001" +
/*emitterAddress*/ "0000000000000000000000000000000000000000000000000000000000000004" +
/*seqeuence*/ "6c5a054d7833d1e4" +
/*sequence*/ "6c5a054d7833d1e4" +
/*consistencyLevel*/ "20" +
/*module*/ "00000000000000000000000000000000000000000000000000000000436f7265" +
/*action*/ "02" +
Expand Down
4 changes: 2 additions & 2 deletions core/definitions/src/protocols/governance/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const contractActions = [
//a word on the chainId for RecoverChainId:
//The EVM contracts accept an arbitrary number when recovering chain ids however I don't think you
// ever want to set the wormhole chain id of a contract (even on a fork) to 0 since this would
// mean that afterwards all the checks that use `vaa.chainId == this.chainId` in the contract
//means that afterwards all the checks that use `vaa.chainId == this.chainId` in the contract
// would suddenly accept "broadcast VAAs" which is almost certainly not what's intended.
//TODO should we define governance actions that are platform specific here?
// (reason against: we might want to deserialize types that are specific to the platform)
Expand Down Expand Up @@ -95,7 +95,7 @@ const wormchainActions = [
// It has a variable length string that has no length prefix as its first item followed by a uint.
// So deserialization has to reason backwards to determine the length.
// see: https://github.com/wormhole-foundation/wormhole/blob/2eb5cca8e72c5379cd444ae3f25a012c1e04ad65/sdk/vaa/payloads.go#L396-L407
// We have to do a bit of footwork here to accomodate this oddity.
// We have to do a bit of footwork here to accommodate this oddity.
const gatewayScheduleUpgradeItem = (() => {
const stringBytesLayout = (size: number) =>
({ binary: "bytes", size, custom: stringConversion } as const satisfies Layout);
Expand Down
2 changes: 1 addition & 1 deletion core/definitions/src/vaa/registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { ProtocolName } from "../protocol.js";
// // payload types that are declared in different protocols. This allows us to have full type safety
// // when constructing payloads via the factory without having to ever declare the mapping of all
// // payloads and their respective layouts in a single place (which, besides being a terrible code
// // smell, would also prevent users of the SDK to register their own payload types!)
// // smell, would also prevent users of the SDK from registering their own payload types!)
// export namespace WormholeRegistry {
// //effective type: Record<string, Layout>
// export interface PayloadLiteralToLayoutMapping {}
Expand Down