open-index/open-npm huggingface dataset:
npm package: @safeheron/truffle-safeheron
Description: truffle plugin for integrating with Safeheron
Author: xigaoku
Latest version: 1.0.0

# Safeheron Truffle Plugin

This is a [Truffle](https://archive.trufflesuite.com/docs/truffle/) plugin for integrating with [Safeheron](https://www.safeheron.com).

This plugin will help you to seamlessly integrate Safeheron into your Truffle development stack.

You can use it to deploy contracts and sign transactions.

## Installation 

```bash
npm install @safeheron/truffle-safeheron
```

## Usage

Configure your `truffle-config.js` in your truffle project.

```javascript
const SafeheronProvider = require("@safeheron/truffle-safehreon");

module.exports = {
  // ...
  networks: {
    sepolia: {
      provider: () => new SafeheronProvider('https://sepolia.infura.io/v3/8026****2fcb', {
        baseUrl: '<Safeheron Open API Url>',
        apiKey: '3faeb3****da25d2',
        // Here are two configuration options:
        // 1. Configure the path to the private key file, for example: file:/path/to/your/private/key/file.pem
        // 2. Configure the private key content in string format, for example: -----BEGIN PRIVATE KEY-----\nMIIJQgIBADANBgkqhkiG****ICAQDidDHYV73U4cub\n-----END PUBLIC KEY-----
        rsaPrivateKey: "-----BEGIN PRIVATE KEY-----\nMIIJQgIBADANBgkqh****mCAruusbobkuJ3rB6h\n-----END PRIVATE KEY-----",
        // You can get safeheronRsaPublicKey from Safeheron Web Console. Here are two configuration options:
        // 1. Save safeheronRsaPublicKey to a file and configure the path to the file, for example: file:/path/to/safeheron/public/key/file.pem
        // 2. Directly paste the public key that you copied from the web console, for example: MIICIjANBgkqhki****8eUQV63wRS0CAwEAAQ==
        safeheronRsaPublicKey: "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0B****S0CAwEAAQ==\n-----END PUBLIC KEY-----",
        requestTimeout: 10000,
        web3WalletAccountKey: "accoun****8e74f",
        web3WalletEVMAddress: "0x426e****14DDE"
      }),
      network_id: "11155111",
      networkCheckTimeout: 5000,
      // This field must be set to true!
      skipDryRun: true
    }
  },

  // ... 
  
};
```

## QA

1. How to get `web3WalletAccountKey` and `web3WalletEVMAddress` ?

Please open [Safeheron Web Console](https://www.safeheron.com/console/wallet), choose an Web3 wallet which you want to use, 
click to go to wallet detail page,
then you will see a link like https://www.safeheron.com/console/wallet/account58xxxxcbf34_web3 in your browser address bar,
the `account58xxxxcbf34` string without `_web3` suffix is your web3 account key. 
And you can also copy your Web3 EVM address at the top of this page.
npm package: @safejs/serializer
Description: Serializer is a superset of JSON that includes recursive objects, dates, regular expressions, functions and others which you also can expand by yourself
Author: Rinat Arsaev
Latest version: 0.1.3

# Serializer

[![npm version](https://badge.fury.io/js/%40safejs%2Fserializer.svg)](https://badge.fury.io/js/%40safejs%2Fserializer)

Serializer is a superset of JSON that includes recursive objects, dates, regular expressions, functions and others which you also can expand by yourself.

-   Recursive objects
-   JS presets:
    -   constants: `undefined`, `Infinity`, `NaN`
    -   functions (default disabled)
    -   ES5 (contains constants) (by default): `Date`, `RegExp`
    -   ES2015 (contains ES5 & constants): `Symbol`, `Map`, `Set`
-   Support custom serializers

> [Other "safe" extensions and utilities for JavaScript (TypeScript)](https://github.com/KrickRay/safejs)

## Installation

```sh
npm i @safejs/serializer
```

## Usage

### Serialize recursive objects

```ts
const serializer = new Serializer();

const recursiveObj = { obj: null };
recursiveObj.obj = recursiveObj;

const serializedObj = serializer.serialize(recursiveObj);
const deserializedObj = serializer.deserialize(serializedObj); // is equal with var recursiveObj
```

### Serialize JS types & objects

```ts
const serializer = new Serializer({ preset: "es2015" });

const recursiveSet = new Set();
recursiveSet.add(recursiveSet);

const obj = {
    und: undefined,
    inf: Infinity,
    map: new Map([
        ["a", 0],
        ["b", 1],
    ]),
    recursiveSet,
    date: new Date(),
    regexp: /\d/g,
};

const serializedObj = serializer.serialize(obj);
const deserializedObj = serializer.deserialize(serializedObj); // is equal with var obj
```

### Serialize moment

```ts
const serializer = new Serializer({
    extra: {
        determine: (v) => v instanceof Moment,
        serialize: (v) => v.valueOf();,
        deserialize: (ms) => moment(ms),
    },
});

const date = moment();
const serializedDate = serializer.serialize(date);
const deserializedDate = serializer.deserialize(serializedDate); // is instanceof Moment & is equal with var date
```

### Serialize your class

```ts
class User {
    name: string;
    age: 10;

    serialize() {
        return [this.name, this.age];
    }

    static deserialize([name, age]: [string, number]) {
        return new User(name, age);
    }
}

const serializer = new Serializer({
    extra: {
        determine: (v) => v instanceof User,
        serialize: (v) => user.serialize(),
        deserialize: (v) => User.deserialize(v),
    },
});

const alex = new User("Alex", 20);
const serializedAlex = serializer.serialize(alex);
const deserializedAlex = serializer.deserialize(serializedAlex); // is instanceof User & is equal with var alex
```
npm package: @safely-project/serum
Description: Library for interacting with the safely dex
Latest version: 0.13.63

[![npm (scoped)](https://img.shields.io/npm/v/@project-serum/serum)](https://www.npmjs.com/package/@project-serum/serum)
[![Build Status](https://travis-ci.com/project-serum/serum-js.svg?branch=master)](https://travis-ci.com/project-serum/serum-js)

# Serum JS Client Library

JavaScript client library for interacting with the Project Serum DEX.

## Installation

Using npm:

```
npm install @safecoin/web3.js @project-serum/serum
```

Using yarn:

```
yarn add @safecoin/web3.js @project-serum/serum
```

## Usage

```js
import { Account, Connection, PublicKey } from '@safecoin/web3.js';
import { Market } from '@project-serum/serum';

let connection = new Connection('https://testnet.solana.com');
let marketAddress = new PublicKey('...');
let programAddress = new PublicKey("...");
let market = await Market.load(connection, marketAddress, {}, programAddress);

// Fetching orderbooks
let bids = await market.loadBids(connection);
let asks = await market.loadAsks(connection);
// L2 orderbook data
for (let [price, size] of bids.getL2(20)) {
  console.log(price, size);
}
// Full orderbook data
for (let order of asks) {
  console.log(
    order.orderId,
    order.price,
    order.size,
    order.side, // 'buy' or 'sell'
  );
}

// Placing orders
let owner = new Account('...');
let payer = new PublicKey('...'); // spl-token account
await market.placeOrder(connection, {
  owner,
  payer,
  side: 'buy', // 'buy' or 'sell'
  price: 123.45,
  size: 17.0,
  orderType: 'limit', // 'limit', 'ioc', 'postOnly'
});

// Retrieving open orders by owner
let myOrders = await market.loadOrdersForOwner(connection, owner.publicKey);

// Cancelling orders
for (let order of myOrders) {
  await market.cancelOrder(connection, owner, order);
}

// Retrieving fills
for (let fill of await market.loadFills(connection)) {
  console.log(fill.orderId, fill.price, fill.size, fill.side);
}

// Settle funds
for (let openOrders of await market.findOpenOrdersAccountsForOwner(
  connection,
  owner.publicKey,
)) {
  if (openOrders.baseTokenFree > 0 || openOrders.quoteTokenFree > 0) {
    // spl-token accounts to which to send the proceeds from trades
    let baseTokenAccount = new PublicKey('...');
    let quoteTokenAccount = new PublicKey('...');

    await market.settleFunds(
      connection,
      owner,
      openOrders,
      baseTokenAccount,
      quoteTokenAccount,
    );
  }
}
```