Skip to content

Commit

Permalink
Merge pull request #21 from SundaeSwap-finance/calvin/taste-tests
Browse files Browse the repository at this point in the history
Introduce Taste Test Package
  • Loading branch information
cjkoepke authored Oct 12, 2023
2 parents ce71014 + 6de530b commit 33172b4
Show file tree
Hide file tree
Showing 42 changed files with 957 additions and 87 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
{
}
"editor.codeActionsOnSave": {
"source.organizeImports": "always"
}
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ Sundae-SDK is a TypeScript library for building transactions for the SundaeSwap
First, install the relevant packages:

```console
$ yarn add lucid-cardano @sundaeswap/sdk-core
$ yarn add lucid-cardano @sundaeswap/core
```
Then start using the SDK:
```typescript
import { SundaeSDK } from "@sundaeswap/sdk-core";
import { SundaeSDK } from "@sundaeswap/core";
import {
TxBuilderLucid,
ProviderSundaeSwap
} from "@sundaeswap/sdk-core/extensions";
} from "@sundaeswap/core/extensions";

const txBuilder = new TxBuilderLucid(
{
Expand Down
3 changes: 2 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ packages will follow, but we plan to support popular libraries like [TypeScript]

## TypeScript

- [@sundaeswap/sdk-core](./typescript/core/modules.html)
- [@sundaeswap/core](./typescript/core/modules.html)
- [@sundaeswap/taste-test](./typescript/taste-test/modules.html)
10 changes: 5 additions & 5 deletions docs/typescript/core/classes/Extensions.TxBuilderLucid.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ TxBuilder<

#### Defined in

[classes/Extensions/TxBuilders/TxBuilder.Lucid.class.ts:96](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/classes/Extensions/TxBuilders/TxBuilder.Lucid.class.ts#L96)
[classes/Extensions/TxBuilders/TxBuilder.Lucid.class.ts:95](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/classes/Extensions/TxBuilders/TxBuilder.Lucid.class.ts#L95)

## Methods

Expand All @@ -76,7 +76,7 @@ that allows a user to add or update staking positions.

#### Defined in

[classes/Extensions/TxBuilders/TxBuilder.Lucid.class.ts:189](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/classes/Extensions/TxBuilders/TxBuilder.Lucid.class.ts#L189)
[classes/Extensions/TxBuilders/TxBuilder.Lucid.class.ts:188](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/classes/Extensions/TxBuilders/TxBuilder.Lucid.class.ts#L188)

___

Expand Down Expand Up @@ -105,7 +105,7 @@ with an updated swap datum.

#### Defined in

[classes/Extensions/TxBuilders/TxBuilder.Lucid.class.ts:355](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/classes/Extensions/TxBuilders/TxBuilder.Lucid.class.ts#L355)
[classes/Extensions/TxBuilders/TxBuilder.Lucid.class.ts:354](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/classes/Extensions/TxBuilders/TxBuilder.Lucid.class.ts#L354)

___

Expand Down Expand Up @@ -141,7 +141,7 @@ Initializes a Lucid instance with the

#### Defined in

[classes/Extensions/TxBuilders/TxBuilder.Lucid.class.ts:114](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/classes/Extensions/TxBuilders/TxBuilder.Lucid.class.ts#L114)
[classes/Extensions/TxBuilders/TxBuilder.Lucid.class.ts:113](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/classes/Extensions/TxBuilders/TxBuilder.Lucid.class.ts#L113)

___

Expand All @@ -167,4 +167,4 @@ Returns a new Tx instance from Lucid. Throws an error if not ready.

#### Defined in

[classes/Extensions/TxBuilders/TxBuilder.Lucid.class.ts:148](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/classes/Extensions/TxBuilders/TxBuilder.Lucid.class.ts#L148)
[classes/Extensions/TxBuilders/TxBuilder.Lucid.class.ts:147](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/classes/Extensions/TxBuilders/TxBuilder.Lucid.class.ts#L147)
6 changes: 3 additions & 3 deletions docs/typescript/core/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ Sundae-SDK is a TypeScript library for building transactions for the SundaeSwap
First, install the relevant packages:

```console
$ yarn add lucid-cardano @sundaeswap/sdk-core
$ yarn add lucid-cardano @sundaeswap/core
```
Then start using the SDK:
```typescript
import { SundaeSDK } from "@sundaeswap/sdk-core";
import { SundaeSDK } from "@sundaeswap/core";
import {
TxBuilderLucid,
ProviderSundaeSwap
} from "@sundaeswap/sdk-core/extensions";
} from "@sundaeswap/core/extensions";

const txBuilder = new TxBuilderLucid(
{
Expand Down
8 changes: 4 additions & 4 deletions docs/typescript/core/interfaces/Core.ITxBuilderBaseOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Whether to allow debugging console logs.

#### Defined in

[@types/txbuilder.ts:61](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/@types/txbuilder.ts#L61)
[@types/txbuilder.ts:62](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/@types/txbuilder.ts#L62)

___

Expand All @@ -33,7 +33,7 @@ The minimum amount of ADA required for a locking position.

#### Defined in

[@types/txbuilder.ts:59](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/@types/txbuilder.ts#L59)
[@types/txbuilder.ts:60](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/@types/txbuilder.ts#L60)

___

Expand All @@ -45,7 +45,7 @@ A supported Cardano network.

#### Defined in

[@types/txbuilder.ts:57](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/@types/txbuilder.ts#L57)
[@types/txbuilder.ts:58](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/@types/txbuilder.ts#L58)

___

Expand All @@ -57,4 +57,4 @@ A CIP-30 compatible wallet.

#### Defined in

[@types/txbuilder.ts:55](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/@types/txbuilder.ts#L55)
[@types/txbuilder.ts:56](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/@types/txbuilder.ts#L56)
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Whether to allow debugging console logs.

#### Defined in

[@types/txbuilder.ts:61](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/@types/txbuilder.ts#L61)
[@types/txbuilder.ts:62](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/@types/txbuilder.ts#L62)

___

Expand All @@ -59,7 +59,7 @@ The minimum amount of ADA required for a locking position.

#### Defined in

[@types/txbuilder.ts:59](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/@types/txbuilder.ts#L59)
[@types/txbuilder.ts:60](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/@types/txbuilder.ts#L60)

___

Expand All @@ -75,7 +75,7 @@ A supported Cardano network.

#### Defined in

[@types/txbuilder.ts:57](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/@types/txbuilder.ts#L57)
[@types/txbuilder.ts:58](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/@types/txbuilder.ts#L58)

___

Expand Down Expand Up @@ -103,4 +103,4 @@ A CIP-30 compatible wallet.

#### Defined in

[@types/txbuilder.ts:55](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/@types/txbuilder.ts#L55)
[@types/txbuilder.ts:56](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/@types/txbuilder.ts#L56)
2 changes: 1 addition & 1 deletion docs/typescript/core/modules.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @sundaeswap/sdk-core
# @sundaeswap/core

## Modules

Expand Down
8 changes: 4 additions & 4 deletions docs/typescript/core/modules/Core.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Module: Core

# Introduction
The `@sundaeswap/sdk-core` package serves as the foundation for interacting with the SundaeSwap protocol in a predictable and declarative manner,
The `@sundaeswap/core` package serves as the foundation for interacting with the SundaeSwap protocol in a predictable and declarative manner,
and includes all typings and class interfaces needed to both [Get Started](#get-started) and extending the API.

## Get Started
To start with [Lucid](https://www.npmjs.com/package/lucid-cardano), install dependencies:

```sh
yarn add lucid-cardano @sundaeswap/sdk-core
yarn add lucid-cardano @sundaeswap/core
```

If you plan to use this package in the browser along with Webpack 5, you'll need to add
Expand All @@ -25,11 +25,11 @@ plugins: {
Next, configure the instance in your app:

```ts
import { SundaeSDK } from "@sundaeswap/sdk-core";
import { SundaeSDK } from "@sundaeswap/core";
import {
TxBuilderLucid,
ProviderSundaeSwap
} from "@sundaeswap/sdk-core/extensions";
} from "@sundaeswap/core/extensions";

const txBuilder = new TxBuilderLucid(
{
Expand Down
50 changes: 50 additions & 0 deletions docs/typescript/taste-test/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Sundae-SDK

[![Licence](https://img.shields.io/github/license/SundaeSwap-finance/sundae-sdk)](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/LICENSE)

Sundae-SDK is a TypeScript library for building transactions for the SundaeSwap DEX on Cardano.

> :warning: **This is a pre-release package**: until we release v1.0.0, the interface may change as we identify the optimal usage patterns.
## QuickStart

### Getting started

First, install the relevant packages:

```console
$ yarn add lucid-cardano @sundaeswap/core
```
Then start using the SDK:
```typescript
import { SundaeSDK } from "@sundaeswap/core";
import {
TxBuilderLucid,
ProviderSundaeSwap
} from "@sundaeswap/core/extensions";

const txBuilder = new TxBuilderLucid(
{
wallet: "eternl",
network: "preview",
provider: "blockfrost",
blockfrost: {
url: "https://cardano-preview.blockfrost.io/api/v0",
apiKey: "YOUR_API_KEY"
}
},
new ProviderSundaeSwap("preview")
);

const sdk: SundaeSDK = new SundaeSDK(txBuilder);

const txHash = await sdk.swap( /** ... */ ).then(({ submit }) => submit());
```

### How to Use

Documentation is available at [https://sundaeswap-finance.github.io/sundae-sdk/](https://sundaeswap-finance.github.io/sundae-sdk/), but it is very much a work-in-progress. Feel free to open a discussion with feedback, or submit a pull request!

# Contributing

Want to contribute? See [CONTRIBUTING.md](CONTRIBUTING.md) to know how.
56 changes: 56 additions & 0 deletions docs/typescript/taste-test/modules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# @sundaeswap/taste-test

# Introduction
The `@sundaeswap/taste-test` package serves as an additional API by which clients can interact with existing SundaeSwap Taste Tests.

## Get Started
To start with [Lucid](https://www.npmjs.com/package/lucid-cardano), install dependencies:

```sh
yarn add lucid-cardano @sundaeswap/core @sundaeswap/taste-test
```

If you plan to use this package in the browser along with Webpack 5, you'll need to add
polyfill support for Buffer. You can do this like so:

```ts
plugins: {
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"]
})
}
```

Next, configure the instance in your app:

```ts
import {
TxBuilderLucid,
ProviderSundaeSwap
} from "@sundaeswap/core/extensions";
import { SundaeSDK } from "@sundaeswap/core";
import { TasteTest } from "@sundaeswap/taste-test"
import type { Lucid } from "lucid-cardano";

const txBuilder = new TxBuilderLucid(
{
wallet: "eternl",
network: "preview",
provider: "blockfrost",
blockfrost: {
url: "https://cardano-preview.blockfrost.io/api/v0",
apiKey: "YOUR_API_KEY"
}
},
new ProviderSundaeSwap("preview")
);

const sdk: SundaeSDK = new SundaeSDK(txBuilder);
const walletInstance = txBuilder.build<unknown, Lucid>().wallet;
let tt: TasteTest | undefined;
if (walletInstance) {
tt = new TasteTest(txBuilder.build<unknown, Lucid>().wallet)
}

tt?.deposit({ ...args });
```
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { JestConfigWithTsJest } from "ts-jest";
const config: JestConfigWithTsJest = {
projects: [
{
displayName: "@sundaeswap/sdk-core",
displayName: "@sundaeswap/core",
testEnvironment: "node",
testMatch: ["<rootDir>/packages/core/**/__tests__/**/*.test.*?(x)"],
testPathIgnorePatterns: ["/dist/", "/node_modules/", "__tests__/data"],
Expand Down
5 changes: 4 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useNx": true,
"useWorkspaces": true,
"version": "1.1.0-alpha.5",
"version": "independent",
"npmClient": "yarn",
"ignoreChanges": [
"**/__tests__/**",
Expand All @@ -19,6 +19,9 @@
},
"build": {
"ignore": "demo"
},
"test": {
"ignore": "demo"
}
}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"build": "lerna run build",
"version:ci": "lerna version -y --ignore-scripts",
"publish:ci": "lerna publish from-package -y",
"docs": "lerna run docs:ci"
"docs": "lerna run docs:ci",
"dev": "concurrently \"cd packages/core && yarn watch\" \"cd packages/taste-tests && yarn watch\" \"cd packages/demo && yarn start\""
},
"engines": {
"node": ">=18"
Expand All @@ -24,6 +25,7 @@
"@sundaeswap/asset": "^0.6.9",
"@sundaeswap/docgen": "^0.1.1",
"@types/node": "^18.11.18",
"concurrently": "^8.2.1",
"eslint": "^8.31.0",
"glob": "^8.0.3",
"husky": "^8.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@sundaeswap/sdk-core",
"version": "1.1.0-alpha.5",
"name": "@sundaeswap/core",
"version": "1.0.0-beta",
"description": "The official SundaeSwap protocol SDK for clients.",
"repository": "git@github.com:SundaeSwap-finance/sundae-sdk.git",
"author": {
"name": "SundaeSwap Labs, Inc.",
"url": "https://www.sundaeswap.finance/"
"url": "https://sundae.fi/"
},
"bugs": {
"url": "https://github.com/SundaeSwap-finance/sundae-sdk/issues"
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/@types/txbuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ export interface ITxBuilderReferralFee {
export interface ITxBuilderFees {
cardanoTxFee?: AssetAmount<IAssetAmountMetadata>;
deposit: AssetAmount<IAssetAmountMetadata>;
scooperFee: AssetAmount<IAssetAmountMetadata>;
foldFee?: AssetAmount<IAssetAmountMetadata>;
liquidity?: AssetAmount<IAssetAmountMetadata>;
referral?: AssetAmount<IAssetAmountMetadata>;
scooperFee: AssetAmount<IAssetAmountMetadata>;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ interface ITxBuilderLucidCompleteTxArgs {
deposit?: bigint;
scooperFee?: bigint;
coinSelection?: boolean;
complete?: boolean;
}

/**
Expand Down Expand Up @@ -683,7 +682,6 @@ export class TxBuilderLucid extends TxBuilder<
deposit,
scooperFee,
coinSelection,
complete = true,
}: ITxBuilderLucidCompleteTxArgs): Promise<
ITxBuilder<Tx, Datum | undefined>
> {
Expand Down
Loading

0 comments on commit 33172b4

Please sign in to comment.