Skip to content

Commit

Permalink
fix: delegate and revoke examples working
Browse files Browse the repository at this point in the history
  • Loading branch information
mishuagopian committed Feb 29, 2024
1 parent a19c9b9 commit 043f44f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
20 changes: 18 additions & 2 deletions examples/delegateAndRevoke.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address } from 'viem';
import { Address, isAddress } from 'viem';

import { testSingleNftOfferInput, testTokenId, users } from './common';

Expand All @@ -8,7 +8,16 @@ const delegateAndRevoke = async (contract?: Address) => {
console.log(`offer placed successfully: ${contractVersionString}`);

const emitLoan = await users[1].emitLoan({
offer: signedOffer,
offerExecution: [
{
offer: {
...signedOffer,
maxTrancheFloor: signedOffer.maxTrancheFloor ?? 0n,
},
lenderOfferSignature: signedOffer.signature,
},
],
duration: signedOffer.duration,
tokenId: testTokenId,
});
const { loan, loanId } = await emitLoan.waitTxInBlock();
Expand Down Expand Up @@ -56,6 +65,13 @@ const delegateAndRevoke = async (contract?: Address) => {
async function main() {
try {
await delegateAndRevoke();

const oldContracts = [process.env.MULTI_SOURCE_LOAN_CONTRACT_V5 ?? ''];
for (const contract of oldContracts) {
if (isAddress(contract)) {
await delegateAndRevoke(contract);
}
}
} catch (e) {
console.log('Error:');
console.log(e);
Expand Down
20 changes: 18 additions & 2 deletions examples/delegateAndRevokeAll.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address } from 'viem';
import { Address, isAddress } from 'viem';

import { testSingleNftOfferInput, testTokenId, users } from './common';

Expand All @@ -8,7 +8,16 @@ const delegateAndRevokeAll = async (contract?: Address) => {
console.log(`offer placed successfully: ${contractVersionString}`);

const emitLoan = await users[1].emitLoan({
offer: signedOffer,
offerExecution: [
{
offer: {
...signedOffer,
maxTrancheFloor: signedOffer.maxTrancheFloor ?? 0n,
},
lenderOfferSignature: signedOffer.signature,
},
],
duration: signedOffer.duration,
tokenId: testTokenId,
});
const { loan, loanId } = await emitLoan.waitTxInBlock();
Expand Down Expand Up @@ -42,6 +51,13 @@ const delegateAndRevokeAll = async (contract?: Address) => {
async function main() {
try {
await delegateAndRevokeAll();

const oldContracts = [process.env.MULTI_SOURCE_LOAN_CONTRACT_V5 ?? ''];
for (const contract of oldContracts) {
if (isAddress(contract)) {
await delegateAndRevokeAll(contract);
}
}
} catch (e) {
console.log('Error:');
console.log(e);
Expand Down

0 comments on commit 043f44f

Please sign in to comment.