Skip to content

Commit

Permalink
chore(bouncer): Update sdk to 0.0.40 (#3945)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasnatter committed Sep 6, 2023
1 parent 3d38229 commit a841d84
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 30 deletions.
2 changes: 1 addition & 1 deletion bouncer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"prettier:write": "prettier --write ."
},
"dependencies": {
"@chainflip-io/cli": "^0.0.30",
"@chainflip-io/cli": "^0.0.40",
"@polkadot/api": "10.7.2",
"@polkadot/keyring": "12.2.1",
"@polkadot/util": "12.2.1",
Expand Down
30 changes: 19 additions & 11 deletions bouncer/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions bouncer/shared/contract_swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ export async function executeContractSwap(
const destChain = assetChains[destAsset];

const nonce = await getNextEthNonce();
const options = {
const networkOptions = {
signer: wallet,
nonce,
network: 'localnet',
vaultContractAddress: getEthContractAddress('VAULT'),
...(srcAsset !== 'ETH' ? { srcTokenContractAddress: getEthContractAddress(srcAsset) } : {}),
gasLimit: 200000,
srcTokenContractAddress: getEthContractAddress(srcAsset),
} as const;
const txOptions = {
nonce: BigInt(nonce),
gasLimit: 200000n,
} as const;

const receipt = await executeSwap(
Expand All @@ -58,7 +60,8 @@ export async function executeContractSwap(
message: messageMetadata.message,
},
} as ExecuteSwapParams,
options,
networkOptions,
txOptions,
);

return receipt;
Expand Down Expand Up @@ -146,11 +149,13 @@ export async function approveTokenVault(srcAsset: 'FLIP' | 'USDC', amount: strin
},
{
signer: wallet,
nonce: nextNonce,
network: 'localnet',
vaultContractAddress: getEthContractAddress('VAULT'),
srcTokenContractAddress: getEthContractAddress(srcAsset),
},
{
nonce: BigInt(nextNonce),
},
),
);
}
16 changes: 11 additions & 5 deletions bouncer/shared/fund_flip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ export async function fundFlip(address: string, flipAmount: string) {
ethers.getDefaultProvider(process.env.ETH_ENDPOINT ?? 'http://127.0.0.1:8545'),
);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const options: any = {
const networkOptions = {
signer: wallet,
network: 'localnet',
stateChainGatewayContractAddress: gatewayContractAddress,
flipContractAddress,
nonce: await getNextEthNonce(),
};
} as const;
const txOptions = {
nonce: BigInt(await getNextEthNonce()),
} as const;

console.log('Funding ' + flipAmount + ' FLIP to ' + address);
let pubkey = address;
Expand All @@ -53,7 +54,12 @@ export async function fundFlip(address: string, flipAmount: string) {
if (pubkey.substr(0, 2) !== '0x') {
pubkey = '0x' + pubkey;
}
const receipt2 = await fundStateChainAccount(pubkey as HexString, flipperinoAmount, options);
const receipt2 = await fundStateChainAccount(
pubkey as HexString,
flipperinoAmount,
networkOptions,
txOptions,
);

console.log(
'Transaction complete, tx_hash: ' +
Expand Down
2 changes: 1 addition & 1 deletion bouncer/shared/get_btc_balance.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getBtcClient } from './utils';

export async function getBtcBalance(bitcoinAddress: string): Promise<number> {
const client = getBtcClient(process.env.BTC_ENDPOINT);
const client = getBtcClient();
const result = await client.listReceivedByAddress(1, false, true, bitcoinAddress);
return result[0]?.amount || 0;
}
10 changes: 5 additions & 5 deletions bouncer/shared/redeem_flip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ export async function redeemFlip(flipSeed: string, ethAddress: HexString, flipAm
.signAndSend(flipWallet, { nonce: -1 }, handleSubstrateError(chainflip));
await redemptionRequestHandle;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const options: any = {
const networkOptions = {
signer: ethWallet,
network: 'localnet',
stateChainGatewayContractAddress: getEthContractAddress('GATEWAY'),
};
flipContractAddress: getEthContractAddress('FLIP'),
} as const;
console.log('Waiting for redemption to be registered');
await observeEVMEvent(gatewayAbi, getEthContractAddress('GATEWAY'), 'RedemptionRegistered', [
accountIdHex,
Expand All @@ -54,7 +54,7 @@ export async function redeemFlip(flipSeed: string, ethAddress: HexString, flipAm
'*',
]);

const delay = await getRedemptionDelay(options);
const delay = await getRedemptionDelay(networkOptions);
console.log(`Waiting for ${delay}s before we can execute redemption`);
await sleep(delay * 1000);

Expand All @@ -69,6 +69,6 @@ export async function redeemFlip(flipSeed: string, ethAddress: HexString, flipAm
);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
await executeRedemption(accountIdHex as any, { nonce, ...options });
await executeRedemption(accountIdHex as any, networkOptions, { nonce: BigInt(nonce) });
await redemptionExecutedHandle;
}
2 changes: 1 addition & 1 deletion bouncer/tests/multiple_members_governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function getGovernanceMembers(): Promise<string[]> {
async function setGovernanceMembers(members: string[]) {
const chainflip = await getChainflipApi();

await submitGovernanceExtrinsic(chainflip.tx.governance.newMembershipSet(members), true);
await submitGovernanceExtrinsic(chainflip.tx.governance.newMembershipSet(members));
}

await cryptoWaitReady();
Expand Down

0 comments on commit a841d84

Please sign in to comment.