@gala-chain/launchpad 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/package.json +1 -1
- package/lib/src/api/types/LaunchpadDtos.d.ts +4 -0
- package/lib/src/api/types/LaunchpadDtos.d.ts.map +1 -1
- package/lib/src/api/types/LaunchpadDtos.js +12 -1
- package/lib/src/api/types/LaunchpadDtos.js.map +1 -1
- package/lib/src/chaincode/LaunchpadContract.d.ts +4 -3
- package/lib/src/chaincode/LaunchpadContract.d.ts.map +1 -1
- package/lib/src/chaincode/LaunchpadContract.js +23 -4
- package/lib/src/chaincode/LaunchpadContract.js.map +1 -1
- package/lib/src/chaincode/launchpad/buyExactToken.d.ts.map +1 -1
- package/lib/src/chaincode/launchpad/buyExactToken.js +8 -1
- package/lib/src/chaincode/launchpad/buyExactToken.js.map +1 -1
- package/lib/src/chaincode/launchpad/buyWithNative.d.ts.map +1 -1
- package/lib/src/chaincode/launchpad/buyWithNative.js +9 -2
- package/lib/src/chaincode/launchpad/buyWithNative.js.map +1 -1
- package/lib/src/chaincode/launchpad/callMemeTokenOut.d.ts.map +1 -1
- package/lib/src/chaincode/launchpad/callMemeTokenOut.js.map +1 -1
- package/lib/src/chaincode/launchpad/callNativeTokenIn.d.ts.map +1 -1
- package/lib/src/chaincode/launchpad/callNativeTokenIn.js.map +1 -1
- package/lib/src/chaincode/launchpad/callNativeTokenOut.d.ts.map +1 -1
- package/lib/src/chaincode/launchpad/callNativeTokenOut.js.map +1 -1
- package/lib/src/chaincode/launchpad/fetchLaunchpadAdressConfig.d.ts +2 -1
- package/lib/src/chaincode/launchpad/fetchLaunchpadAdressConfig.d.ts.map +1 -1
- package/lib/src/chaincode/launchpad/fetchLaunchpadAdressConfig.js +1 -1
- package/lib/src/chaincode/launchpad/fetchLaunchpadAdressConfig.js.map +1 -1
- package/lib/src/chaincode/launchpad/fetchLaunchpadFeeAmount.d.ts +12 -0
- package/lib/src/chaincode/launchpad/fetchLaunchpadFeeAmount.d.ts.map +1 -0
- package/lib/src/chaincode/launchpad/fetchLaunchpadFeeAmount.js +37 -0
- package/lib/src/chaincode/launchpad/fetchLaunchpadFeeAmount.js.map +1 -0
- package/lib/src/chaincode/launchpad/sellExactToken.d.ts.map +1 -1
- package/lib/src/chaincode/launchpad/sellExactToken.js +2 -1
- package/lib/src/chaincode/launchpad/sellExactToken.js.map +1 -1
- package/lib/src/chaincode/launchpad/sellWithNative.d.ts.map +1 -1
- package/lib/src/chaincode/launchpad/sellWithNative.js +2 -1
- package/lib/src/chaincode/launchpad/sellWithNative.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/api/types/LaunchpadDtos.ts +8 -0
- package/src/chaincode/LaunchpadContract.ts +25 -5
- package/src/chaincode/launchpad/buyExactToken.spec.ts +222 -0
- package/src/chaincode/launchpad/buyExactToken.ts +18 -2
- package/src/chaincode/launchpad/buyWithNative.spec.ts +221 -0
- package/src/chaincode/launchpad/buyWithNative.ts +20 -3
- package/src/chaincode/launchpad/callMemeTokenOut.spec.ts +1 -1
- package/src/chaincode/launchpad/callMemeTokenOut.ts +1 -0
- package/src/chaincode/launchpad/callNativeTokenIn.ts +1 -0
- package/src/chaincode/launchpad/callNativeTokenOut.ts +1 -0
- package/src/chaincode/launchpad/fetchLaunchpadAdressConfig.ts +5 -2
- package/src/chaincode/launchpad/fetchLaunchpadFeeAmount.spec.ts +67 -0
- package/src/chaincode/launchpad/fetchLaunchpadFeeAmount.ts +40 -0
- package/src/chaincode/launchpad/sellExactToken.ts +2 -1
- package/src/chaincode/launchpad/sellWithNative.ts +2 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Gala Games Inc. All rights reserved.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
import { ChainCallDTO, GalaChainErrorResponse, NotFoundError } from "@gala-chain/api";
|
|
16
|
+
import { fixture, users } from "@gala-chain/test";
|
|
17
|
+
import { plainToInstance } from "class-transformer";
|
|
18
|
+
|
|
19
|
+
import { LaunchpadFeeConfig, TransactionFeeResDto } from "../../api/types";
|
|
20
|
+
import { LaunchpadContract } from "../LaunchpadContract";
|
|
21
|
+
|
|
22
|
+
describe("fetchLaunchpadFeeAmount", () => {
|
|
23
|
+
it("Should return the feeAmount when LaunchpadFeeConfig exists", async () => {
|
|
24
|
+
//Given
|
|
25
|
+
const launchpadConfig = new LaunchpadFeeConfig(users.testUser2.identityKey, Number("0.32"), [
|
|
26
|
+
users.testUser2.identityKey
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
const { ctx, contract } = fixture(LaunchpadContract)
|
|
30
|
+
.registeredUsers(users.testUser3)
|
|
31
|
+
.savedState(launchpadConfig);
|
|
32
|
+
|
|
33
|
+
const dto = new ChainCallDTO();
|
|
34
|
+
|
|
35
|
+
dto.sign(users.testUser3.privateKey);
|
|
36
|
+
|
|
37
|
+
//When
|
|
38
|
+
const res = await contract.FetchLaunchpadFeeAmount(ctx, dto);
|
|
39
|
+
|
|
40
|
+
const expectedRes = plainToInstance(TransactionFeeResDto, {
|
|
41
|
+
feeAmount: 0.32
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
//Then
|
|
45
|
+
expect(res.Data).toEqual(expectedRes);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("Should revert when LaunchpadFeeConfig does not exists", async () => {
|
|
49
|
+
//Given
|
|
50
|
+
|
|
51
|
+
const { ctx, contract } = fixture(LaunchpadContract).registeredUsers(users.testUser3);
|
|
52
|
+
|
|
53
|
+
const dto = new ChainCallDTO();
|
|
54
|
+
|
|
55
|
+
dto.sign(users.testUser3.privateKey);
|
|
56
|
+
|
|
57
|
+
//When
|
|
58
|
+
const res = await contract.FetchLaunchpadFeeAmount(ctx, dto);
|
|
59
|
+
|
|
60
|
+
//Then
|
|
61
|
+
expect(res).toEqual(
|
|
62
|
+
new GalaChainErrorResponse(
|
|
63
|
+
new NotFoundError("Platform fee configuration has yet to be defined. Fee amount is not available.")
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Gala Games Inc. All rights reserved.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
import { ChainCallDTO, NotFoundError } from "@gala-chain/api";
|
|
16
|
+
import { GalaChainContext } from "@gala-chain/chaincode";
|
|
17
|
+
|
|
18
|
+
import { TransactionFeeResDto } from "../../api/types";
|
|
19
|
+
import { fetchLaunchpadFeeAddress } from "../utils";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @dev The fetchLaunchpadFeeAmount function retrieves the configured fee amount
|
|
23
|
+
* for Launchpad transactions. If no fee configuration is found, it throws a NotFoundError.
|
|
24
|
+
* @param ctx GalaChainContext – The execution context providing access to the GalaChain environment.
|
|
25
|
+
* @returns TransactionFeeResDto – An object containing:
|
|
26
|
+
* - feeAmount – The configured transaction fee amount for Launchpad transactions.
|
|
27
|
+
*/
|
|
28
|
+
export async function fetchLaunchpadFeeAmount(
|
|
29
|
+
ctx: GalaChainContext,
|
|
30
|
+
dto: ChainCallDTO
|
|
31
|
+
): Promise<TransactionFeeResDto> {
|
|
32
|
+
const feeConfig = await fetchLaunchpadFeeAddress(ctx);
|
|
33
|
+
|
|
34
|
+
if (!feeConfig) {
|
|
35
|
+
throw new NotFoundError("Platform fee configuration has yet to be defined. Fee amount is not available.");
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
feeAmount: feeConfig.feeAmount
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -132,6 +132,7 @@ export async function sellExactToken(
|
|
|
132
132
|
vaultAddress: sellTokenDTO.vaultAddress,
|
|
133
133
|
userAddress: ctx.callingUser,
|
|
134
134
|
isFinalized: false,
|
|
135
|
-
functionName: "SellExactToken"
|
|
135
|
+
functionName: "SellExactToken",
|
|
136
|
+
uniqueKey: sellTokenDTO.uniqueKey
|
|
136
137
|
};
|
|
137
138
|
}
|
|
@@ -131,6 +131,7 @@ export async function sellWithNative(
|
|
|
131
131
|
vaultAddress: sellTokenDTO.vaultAddress,
|
|
132
132
|
userAddress: ctx.callingUser,
|
|
133
133
|
isFinalized: false,
|
|
134
|
-
functionName: "SellWithNative"
|
|
134
|
+
functionName: "SellWithNative",
|
|
135
|
+
uniqueKey: sellTokenDTO.uniqueKey
|
|
135
136
|
};
|
|
136
137
|
}
|