UNPKG

@ingocollatz/sdk-tests

Version:
63 lines (47 loc) 1.8 kB
import { CirclesSdk } from "@ingocollatz/sdk"; import { PUBLIC_KEY_1, RPC_URL, SAFE_ADDRESS_USER } from "../config"; import Web3 from "web3"; import Safe, { Web3Adapter } from "@safe-global/protocol-kit"; import { Web3AbiEncoder } from "@ingocollatz/sdk-web3-adapter"; import { EthersAbiEncoder } from "@ingocollatz/sdk-ethers-adapter"; import { ethers } from "ethers"; import { EthersAdapter } from "@safe-global/protocol-kit"; import type { TxHistory, TxHistoryTypes } from "@ingocollatz/sdk-interfaces"; (async (): Promise<void> => { // Ethers const provider = new ethers.providers.JsonRpcProvider(RPC_URL); const safe = await Safe.create({ ethAdapter: new EthersAdapter({ ethers, signerOrProvider: provider, }), safeAddress: SAFE_ADDRESS_USER, }); const abiEncoder = new EthersAbiEncoder(); const circlesSdk = new CirclesSdk(safe, abiEncoder); const history: TxHistory = await circlesSdk.fetchTransactionHistory({ limit: 10, offset: 0, type: "HUB_TRANSFER", unit: "tc", }); console.log(`History for ${SAFE_ADDRESS_USER}: `, history); // Web3 // const web3 = new Web3(new Web3.providers.HttpProvider(RPC_URL)); // const safe = await Safe.create({ // ethAdapter: new Web3Adapter({ // web3: new Web3(new Web3.providers.HttpProvider(RPC_URL)), // signerAddress: PUBLIC_KEY_1, // }), // safeAddress: SAFE_ADDRESS_USER, // }); // const safeAddress = await safe.getAddress(); // const abiEncoder = new Web3AbiEncoder(web3); // const circlesSdk = new CirclesSdk(safe, abiEncoder); // const history = await circlesSdk.fetchTransactionHistory({ // limit: 10, // offset: 0, // type: "HUB_TRANSFER", // }); // console.log(`History for ${SAFE_ADDRESS_USER}: `, history); })();