Skip to content

Commit

Permalink
fix: add approve
Browse files Browse the repository at this point in the history
  • Loading branch information
sirpy committed Jul 10, 2024
1 parent f3c48e7 commit 7a360e9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/sdk-js/scripts/swapAndStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,25 @@ config();
// const provider = new ethers.providers.JsonRpcProvider('https://alfajores-forno.celo-testnet.org');
const provider = new ethers.providers.JsonRpcProvider('https://forno.celo.org');
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY || '').connect(provider);
const sdk = new GoodCollectiveSDK('42220', provider, { nftStorageKey: process.env.VITE_NFTSTORAGE_KEY });
const sdk = new GoodCollectiveSDK('42220', provider, {});
console.log(wallet.address);
const main = async () => {
const swap = {
swapFrom: '0x471EcE3750Da237f93B8E339c536989b8978a438',
amount: ethers.utils.parseEther('0.1'),
minReturn: 0,
deadline: (Date.now() / 1000).toFixed(0) + 6000000,
path: '0x',
path: '0x471ece3750da237f93b8e339c536989b8978a43800271062b8b11039fcfe5ab0c56e502b1c372a3d2a9c7a',
};

const approve = await (
await sdk.approve(wallet, swap.swapFrom, '0x010d572cf7297509f4c3555f8bfb53e6e8d6d54a', swap.amount.toString())
).wait();
console.log({ approve });
const tx = await sdk.supportFlowWithSwap(
wallet,
'0x11f18e8f2a27d54a605cf10486b3d4c5aeeba81f',
ethers.utils.parseEther('0.0000001').toString(),
'0x010d572cf7297509f4c3555f8bfb53e6e8d6d54a',
ethers.utils.parseEther('0.01').toString(),
swap
);
const res = await tx.wait().catch(console.log);
Expand Down

0 comments on commit 7a360e9

Please sign in to comment.