@ingocollatz/sdk-tests
Version:
171 lines (151 loc) • 6.51 kB
text/typescript
// import { CirclesSdkWeb3Factory } from "@ingocollatz/sdk-web3-adapter";
// import Web3 from "web3";
// import { SafeFactory } from "@safe-global/protocol-kit";
// import { Web3Adapter } from "@safe-global/protocol-kit";
// import { Account } from "web3-core";
// import Safe from "@safe-global/protocol-kit/dist/src/Safe";
// import { describe } from "node:test";
// import { CirclesSdk } from "@ingocollatz/sdk";
// import HDWalletProvider from "@truffle/hdwallet-provider";
// import { GnosisSafe } from "./GnosisSafe";
// import { ProxyFactory } from "./ProxyFactory";
// import { AbiItem } from 'web3-utils';
// import { CompatibilityFallbackHandler } from "./CompatibilityFallbackHandler";
// const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
// // const config = {
// // "hubContract": "0x5528544b97869ce105be00fccf250f659e787034",
// // "proxyFactoryContract": "0xd5e7d393226a6e9089601080e4b92bcaf536bada",
// // "masterSafeContract": "0x5e484da6227ab3ba047121742ee766cc6389db4f",
// // "defaultOwnerAccount": {
// // "address": "0x85a88313b37676ef7F846E00287090E75931E44B",
// // "privateKey": "0x5bc6328efff9fc724aad89edf1356a6ba7bee56368b4b9b47b1f29a5cd6d73c7"
// // },
// // "multiSendContract": "0x0605ac8ff5952393ec94ef4a03c2e17af0939bbb",
// // "safeProxyContract": "0x8b124d5d9c30ba89c079116c030b54c7ff300d0c",
// // "compatibilityFallbackHandlerContract": "0xd165c5951d08e64c8741d8c48320fb383fb42370",
// // "multiSendCallOnlyContract": "0x8d4f7c464e07f2b2284cc51e6442ec88af4d52c8",
// // "migrationsContract": {
// // "chain": {},
// // "await": {},
// // "started": true
// // },
// // "rootSafeContract": "0x01ae162ec19d914f8454ed88a17d73c27643a204",
// // "operatorOrgaSafeContract": "0x67a303aebbb61e4cf71660613e3a598aeb422f7f",
// // "invitationFundsSafeContract": "0xdad511a686704f1efccb6bb08088619a7b0e5602",
// // "otherSafes": [
// // "0x6d752db5a6a0f3afa0dbb11e721bdc3995bfb410",
// // "0x2b86d1c067df6aaade04092b8923ef3949041983",
// // "0xb41c94271843388972c3efa342f834a26d2cbfe0",
// // "0x49e9b3bb7263333a8897181849561cf2bbdb4c3c",
// // "0x8eb6bcaeb19c37a6a110ecc67991020e02894c47",
// // "0xe8f6616ab46c2d5172dcca8bc219a951b9a4bc40",
// // "0xeffaa7be240cb3ddf304c403fa430f585dd8fcc2",
// // "0x4b44483dae3f4514cb26af2996b3445db79859c7",
// // "0x6eb9fdf4689c81879c28e6c5e4eecceddf68ed78",
// // "0x963ce23b14c3d2a3f6c9efec3bd6fbba7d88c15c",
// // "0xc4eea7362fc077e77ac898981fc3e0dff681dced",
// // "0x759d5347e5eb8dc2848792edc3b770339ccdf4af",
// // "0x928bd0158d3867a2cf5c9ca8101ceacee25a2d3f",
// // "0x2dc7c6980bc1142f0210e0ffc20775acafd38a1b",
// // "0xbf3454035dbf7a84355de1d5eb79770659755a8c",
// // "0x8285aa960086cc5674d780db5e3f362c394d1105"
// // ],
// // "network": {
// // "host": "ganache",
// // "port": 8545,
// // "network_id": "*"
// // },
// // "otherOrgaSafes": [
// // "0xc0c84de71d4d2ce9a4968052a78631f6e5a16ada",
// // "0x523a15096813f822ad86675f2b31743303122200",
// // "0x88fb5fbd2617e0948d8b9d4f70d5abcebe97be37",
// // "0x9802d6cb723e233ffca854f9ae0e4d4d99cdbba8"
// // ]
// // }
// const rpcEndpoint = `https://rpc.circlesubi.id`;
// let web3: Web3;
// let signerAccount: Account;
// let web3EthAdapter: Web3Adapter;
// describe("Circles SDK", () => {
// beforeAll(async () => {
// // init web3
// web3 = new Web3();
// let account = web3.eth.accounts.privateKeyToAccount(config.defaultOwnerAccount.privateKey);
// // Create an HDWalletProvider using the mnemonic and the RPC endpoint
// const provider = new HDWalletProvider({
// privateKeys: [account.privateKey.slice(2)],
// providerOrUrl: rpcEndpoint,
// });
// // Set the provider for web3
// web3.setProvider(<any>provider);
// // // Get the signer account
// // signerAccount = web3.eth.accounts.privateKeyToAccount(
// // account.privateKey
// // );
// // Init safe sdk and deploy safe
// web3EthAdapter = new Web3Adapter({
// web3,
// signerAddress: provider.getAddress(),
// });
// provider.engine.stop();
// });
// describe("with safe", async () => {
// let safeAddress: string;
// let safe: Safe;
// beforeAll(async () => {
// let chainId = await web3EthAdapter.getChainId();
// const safeFactory = await SafeFactory.create({
// ethAdapter: web3EthAdapter,
// contractNetworks: {
// [chainId]: {
// safeMasterCopyAddress: config.masterSafeContract,
// safeProxyFactoryAddress: config.proxyFactoryContract,
// multiSendAddress: config.multiSendContract,
// multiSendCallOnlyAddress: config.multiSendCallOnlyContract,
// fallbackHandlerAddress: config.compatibilityFallbackHandlerContract,
// signMessageLibAddress: ZERO_ADDRESS,
// createCallAddress: ZERO_ADDRESS,
// simulateTxAccessorAddress: ZERO_ADDRESS,
// safeMasterCopyAbi: <AbiItem[]>GnosisSafe.abi,
// safeProxyFactoryAbi: <AbiItem[]>ProxyFactory.abi,
// fallbackHandlerAbi: <AbiItem[]>CompatibilityFallbackHandler.abi
// }
// }
// });
// safe = await safeFactory.deploySafe({
// safeAccountConfig: {
// owners: [signerAccount.address],
// threshold: 1,
// },
// });
// safeAddress = await safe.getAddress();
// });
// let sdkInstance: CirclesSdk;
// test("create sdk instance from existing safe", async () => {
// console.log("safeAddress: ", safeAddress)
// // Init sdk
// sdkInstance = await CirclesSdkWeb3Factory.withExistingSafe(
// web3,
// signerAccount.address,
// safeAddress
// );
// expect(sdkInstance).toBeDefined();
// });
// describe("with sdk", async () => {
// test("signupPerson", async () => {
// await sdkInstance.signupPerson();
// });
// // test("getSafeBalance", async () => {
// // const balance = await sdkInstance.getSafeBalance();
// // expect(balance).toEqual("0");
// // });
// test("transferUbi", async () => {
// const paymentPath = await sdkInstance.transferUbi(
// safeAddress,
// signerAccount.address,
// "1000000000000000000"
// );
// });
// });
// });
// });