Skip to content

Commit

Permalink
feat: deployment of new contracts (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
gidonkatten authored Aug 21, 2024
1 parent 23416db commit 01ed760
Show file tree
Hide file tree
Showing 41 changed files with 1,441 additions and 213 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-shoes-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@folks-finance/xchain-sdk": patch
---

deployment of new contracts
5 changes: 5 additions & 0 deletions .changeset/giant-geckos-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@folks-finance/xchain-sdk": patch
---

update contract calls for new contracts
27 changes: 16 additions & 11 deletions examples/read-write-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ import {
FolksCore,
FolksAccount,
FOLKS_CHAIN_ID,
BYTES32_LENGTH,
BYTES4_LENGTH,
getSupportedMessageAdapters,
Action,
MessageAdapterParamsType,
buildAccountId,
convertToGenericAddress,
ChainType,
} from "../src/index.js";

import type { AccountId } from "../src/common/types/lending.js";
import type { FolksCoreConfig, MessageAdapters } from "../src/index.js";
import type { EvmAddress, FolksCoreConfig, MessageAdapters, Nonce } from "../src/index.js";

async function main() {
const folksConfig: FolksCoreConfig = {
Expand All @@ -25,12 +27,7 @@ async function main() {
FolksCore.init(folksConfig);
FolksCore.setNetwork(NetworkType.TESTNET);

const accountId: AccountId = getRandomBytes(BYTES32_LENGTH) as AccountId;

// read
const accountInfo = await FolksAccount.read.accountInfo(accountId);

console.log(accountInfo);
const nonce: Nonce = getRandomBytes(BYTES4_LENGTH) as Nonce;

// write
const MNEMONIC = "your mnemonic here";
Expand Down Expand Up @@ -58,8 +55,16 @@ async function main() {
folksChainId: FOLKS_CHAIN_ID.AVALANCHE_FUJI,
});

const prepareCreateAccountCall = await FolksAccount.prepare.createAccount(accountId, adapters);
const createAccountCallRes = await FolksAccount.write.createAccount(accountId, prepareCreateAccountCall);
// read
const folksChain = FolksCore.getSelectedFolksChain();
const userAddress = convertToGenericAddress(account.address as EvmAddress, ChainType.EVM);
const accountId = buildAccountId(userAddress, folksChain.folksChainId, nonce);
const accountInfo = await FolksAccount.read.accountInfo(accountId);
console.log(accountInfo);

// write
const prepareCreateAccountCall = await FolksAccount.prepare.createAccount(nonce, adapters);
const createAccountCallRes = await FolksAccount.write.createAccount(nonce, prepareCreateAccountCall);

console.log(createAccountCallRes);
}
Expand Down
3 changes: 2 additions & 1 deletion examples/user-loan-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ async function main() {
[FolksTokenId.AVAX]: await FolksPool.read.poolInfo(FolksTokenId.AVAX),
[FolksTokenId.ETH_eth_sep]: await FolksPool.read.poolInfo(FolksTokenId.ETH_eth_sep),
[FolksTokenId.ETH_base_sep]: await FolksPool.read.poolInfo(FolksTokenId.ETH_base_sep),
[FolksTokenId.ETH_arb_sep]: await FolksPool.read.poolInfo(FolksTokenId.ETH_arb_sep),
[FolksTokenId.LINK_eth_sep]: await FolksPool.read.poolInfo(FolksTokenId.LINK_eth_sep),
[FolksTokenId.BNB]: await FolksPool.read.poolInfo(FolksTokenId.BNB),
};
const loanTypeInfo = {
[LoanTypeId.GENERAL]: await FolksLoan.read.loanTypeInfo(LoanTypeId.GENERAL),
Expand All @@ -54,7 +56,6 @@ async function main() {

const userGeneralLoans = await FolksLoan.read.userLoans(generalLoansIds);
const userGeneralLoansInfo = FolksLoan.util.userLoansInfo(userGeneralLoans, poolsInfo, loanTypeInfo, oraclePrices);

console.log(userGeneralLoansInfo);
}

Expand Down
Loading

0 comments on commit 01ed760

Please sign in to comment.