Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deep copy datum templates on use #55

Merged
merged 3 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ jobs:
- name: Test using Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '17'
- run: npm ci
- run: npm run test
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

All notable changes to Dexter will be documented in this file.

## [UNRELEASED]
- Update DEX template definitions to use a copy of the template, rather than altering the original.

## [v3.0.1]

- Fix for WingRiders price impact calculation when using a non ADA swap in token.
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/definition-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class DefinitionBuilder {
* Load a DEX definition file as a template for this builder.
*/
public async loadDefinition(definition: DefinitionConstr): Promise<DefinitionBuilder> {
this._definition = definition;
this._definition = structuredClone(definition);

return this;
}
Expand Down
1 change: 1 addition & 0 deletions tests/minswap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe('Minswap', () => {

return minswap.buildSwapOrder(liquidityPool, defaultSwapParameters)
.then((payments: PayToAddress[]) => {
expect(() => { minswap.buildSwapOrder(liquidityPool, defaultSwapParameters); }).not.toThrowError();
expect(payments[0].addressType).toBe(AddressType.Contract);
expect(payments[0].assetBalances[0].quantity).toEqual(10000004000000n);
expect(payments[0].datum).toBe('d8799fd8799fd8799f42ed56ffd8799fd8799fd8799f42bac6ffffffffd8799fd8799f42ed56ffd8799fd8799fd8799f42bac6ffffffffd87a80d8799fd8799f581cf66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b698804469555344ff1b00004d616c553b2dff1a001e84801a001e8480ff');
Expand Down
1 change: 1 addition & 0 deletions tests/muesliswap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe('MuesliSwap', () => {

return muesliswap.buildSwapOrder(liquidityPool, defaultSwapParameters)
.then((payments: PayToAddress[]) => {
expect(() => { muesliswap.buildSwapOrder(liquidityPool, defaultSwapParameters); }).not.toThrowError();
expect(payments[0].addressType).toBe(AddressType.Contract);
expect(payments[0].assetBalances[0].quantity).toEqual(100002650000n);
expect(payments[0].datum).toBe('d8799fd8799fd8799fd8799f42ed56ffd8799fd8799fd8799f42bac6ffffffff581cf66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988044695553444040197b98d87a801a00286f90ffff');
Expand Down
1 change: 1 addition & 0 deletions tests/sundaeswap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ describe('SundaeSwap', () => {

return sundaeswap.buildSwapOrder(liquidityPool, defaultSwapParameters)
.then((payments: PayToAddress[]) => {
expect(() => { sundaeswap.buildSwapOrder(liquidityPool, defaultSwapParameters); }).not.toThrowError();
expect(payments[0].addressType).toBe(AddressType.Contract);
expect(payments[0].assetBalances[0].quantity).toEqual(10004500000n);
expect(payments[0].datum).toBe('d8799f421234d8799fd8799fd8799fd8799f42ed56ffd8799fd8799fd8799f42bac6ffffffffd87a80ffd87a80ff1a002625a0d8799fd879801b00000002540be400d8799f1b000000309173774fffffff');
Expand Down
1 change: 1 addition & 0 deletions tests/vyfinance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ describe('VyFinance', () => {

return vyfi.buildSwapOrder(liquidityPool, defaultSwapParameters)
.then((payments: PayToAddress[]) => {
expect(() => { vyfi.buildSwapOrder(liquidityPool, defaultSwapParameters); }).not.toThrowError();
expect(payments[0].addressType).toBe(AddressType.Contract);
expect(payments[0].assetBalances[0].quantity).toBe(100_003_900000n);
expect(payments[0].datum).toBe('d8799f44ed56bac6d87c9f1b000000017a830584ffff');
Expand Down
1 change: 1 addition & 0 deletions tests/wingriders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe('WingRiders', () => {

return wingriders.buildSwapOrder(liquidityPool, defaultSwapParameters)
.then((payments: PayToAddress[]) => {
expect(() => { wingriders.buildSwapOrder(liquidityPool, defaultSwapParameters); }).not.toThrowError();
expect(payments[0].addressType).toBe(AddressType.Contract);
expect(payments[0].assetBalances[0].quantity).toEqual(10004000000n);
});
Expand Down