open-index/open-npm huggingface dataset:
npm package: @rubicondefi/gladius-sdk
Description: SDK for Rubicon Gladius
Author: Rubicon
Latest version: 1.4.27

# gladius-sdk

SDK for Rubicon Gladius

## Usage

The SDK contains bindings for two main flows: parsing serialized orders & building new orders.

### Building & Signing Orders

```ts
import { DutchOrder, NonceManager } from '@rubicondefi/gladius-sdk';
import { ethers } from 'ethers';

const provider = new ethers.providers.JsonRpcProvider(RPC_URL);
const account = await provider.getSigner().getAddress(); 
const nonceMgr = new NonceManager(provider, 1); 
const nonce = await nonceMgr.useNonce(account); 

const chainId = 1;
const builder = new DutchOrderBuilder(chainId);
const order = builder
  .deadline(deadline)
  .decayEndTime(deadline)
  .decayStartTime(deadline - 100)
  .nonce(nonce)
  .input({
    token: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
    amount: BigNumber.from('1000000'),
  })
  .output({
    token: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
    startAmount: BigNumber.from('1000000000000000000'),
    endAmount: BigNumber.from('900000000000000000'),
    recipient: '0x0000000000000000000000000000000000000000',
  })
  .build();
 
// Sign the built order 
const { domain, types, values } = order.permitData();
const signature = wallet._signTypedData(domain, types, values);

const serializedOrder = order.serialize();
// submit serializedOrder and signature to order pool
```

### Parsing Orders
```ts
import { parseOrder, Order, OrderValidation } from '@rubicondefi/gladius-sdk';

const serializedOrder = '0x1111222233334444555500000000234300234...';
const order: Order = parseOrder(serializedOrder);

const orderData = order.info;
const orderHash = order.hash();
```
### Validating Orders 
```ts
import { ethers } from 'ethers';
import { OrderValidator } from 'gladius-sdk';

const provider = new ethers.providers.JsonRpcProvider(RPC_URL);
const validator = new OrderValidator(provider, CHAIN_ID); 
const orders: SignedOrder[] = [
  {
    order: order1, 
    signature: signature1
  }, 
  {
    order: order2, 
    signature: signature2
  }
]; 

try {
  const statusList: OrderValidation[] = await validator.validateBatch(orders); 
  // Do something with list of statuses 
}
catch(e) {
  // Handle error
}

```

### Order Object

**serialize()**

Returns an abi-encoded serialization of the order. This serialized format is passed into the corresponding reactor contract for execution.


**getSigner(signature)**

Recovers the address which created the given signature over the order. Used to determine the order maker.


**permitData()**

Returns the domain, types, and values used to generate an EIP-712 signature over the order. Note that this signature both approves the release of the order's input tokens _and_ the execution of the order itself.


**hash()**

Returns the order hash. This is used as a key to track order fulfillment on-chain. It may also be useful as a unique order identifier for off-chain purposes.
npm package: @rubiin/tsconfig
Description: Shared TypeScript config for my projects
Author: Rubin Bhandari
Latest version: 1.2.1

# tsconfig

> Shared [TypeScript config](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) for my projects

## Install

```sh
npm install --save-dev @rubiin/tsconfig
```

*This config requires TypeScript 5 or later.*

## Usage

`tsconfig.json`

```json
{
	"extends": "@rubiin/tsconfig",
	"compilerOptions": {
		"outDir": "dist"
	}
}
```

When you are targeting a higher version of Node.js, check the relevant ECMAScript version and add it as `target`:

```json
{
	"extends": "@rubiin/tsconfig",
	"compilerOptions": {
		"outDir": "dist",
		"target": "ES2023"
	}
}
```
npm package: @rubiklabs/nestjs-jacpol-kysely
Description: Kysely adapter for @rubiklabs/nestjs-jacpol – store ABAC policies in PostgreSQL, MySQL or SQLite
Author: Halil Safa Sağlık
Latest version: 1.0.0

# @rubiklabs/nestjs-jacpol-kysely

Kysely adapter for **[@rubiklabs/nestjs-jacpol](https://www.npmjs.com/package/@rubiklabs/nestjs-jacpol)** – store ABAC policies in PostgreSQL, MySQL or SQLite.

## Installation

```bash
npm install @rubiklabs/nestjs-jacpol-kysely
```

### Peer dependencies

| Package | Version |
|---|---|
| `@rubiklabs/nestjs-jacpol` | `^1.0.0` |
| `kysely` | `^0.27.0` |
| `@nestjs/common` | `^10.0.0` |

## Quick start

### 1. Run migrations

The package exports ready-to-use Kysely migrations:

```ts
import { Migrator } from 'kysely';
import { jacpolMigrations } from '@rubiklabs/nestjs-jacpol-kysely';

const migrator = new Migrator({
  db,
  provider: {
    getMigrations: async () =>
      Object.fromEntries(jacpolMigrations.map((m) => [m.name, m])),
  },
});

await migrator.migrateToLatest();
```

### 2. Register the module

```ts
import { Module } from '@nestjs/common';
import { JacpolModule } from '@rubiklabs/nestjs-jacpol';
import { JacpolKyselyModule } from '@rubiklabs/nestjs-jacpol-kysely';

@Module({
  imports: [
    JacpolModule.forRoot({ /* ... */ }),
    JacpolKyselyModule.forRoot({ db }), // your Kysely instance
  ],
})
export class AppModule {}
```

#### Async registration

```ts
JacpolKyselyModule.forRootAsync({
  imports: [DatabaseModule],
  inject: [KyselyService],
  useFactory: (kyselyService: KyselyService) => ({
    db: kyselyService.getDb(),
  }),
});
```

## API

### `JacpolKyselyModule`

| Method | Description |
|---|---|
| `forRoot(options)` | Synchronous registration with a Kysely instance |
| `forRootAsync(options)` | Async registration with factory pattern |

### `KyselyAdapter`

Implements `IPolicyAdapter` from `@rubiklabs/nestjs-jacpol`. Available methods:

- `getPolicySet(id)` / `getAllPolicySets()`
- `getPolicy(id)` / `getPoliciesByIds(ids)`
- `savePolicySet(policySet)` / `savePolicy(policy)`
- `upsertPolicySet(policySet)` / `upsertPolicy(policy)`
- `deletePolicySet(id)` / `deletePolicy(id)`
- `healthCheck()`

### Exports

```ts
// Schema types
export { JacpolDatabase, JacpolPolicySetTable, JacpolPolicyTable };
export { PolicySetRow, PolicyRow, PolicySetInsert, PolicyInsert };

// Adapter
export { KyselyAdapter, KyselyAdapterOptions };

// Module
export { JacpolKyselyModule, JacpolKyselyModuleOptions };

// Migrations
export { jacpolMigrations };
```

## License

MIT