-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Initial migration of fees code from internal codebase to public sdk (#…
…365) * Migrate Fees code to public SDK Includes all fee-related code and supporting oracle code. Supporting types defined for bridging and swaps have been included, but chaincode methods and other code for these features will be migrated later. * chore: lint * fix: move GalaChainFeeContract to break circular dependency * test: initial fees migration from internal to public sdk * fix: chaincode-template unit test snapshot * fix: remove older bridge ids/dtos in process of rework * code review feedback, bridge out fee multiplier, bridge out nfts * pull request feedback * add GalaChainFeeContract to chaincode-template e2e * fix snapshot, postpone fee contract migration * fix: fees exports * fix decimal precision for bridge surge pricing, start typedoc defs
1 parent
4eabcdc
commit 911a49d
Showing
69 changed files
with
9,995 additions
and
1,082 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright (c) Gala Games Inc. All rights reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
export enum ChainId { | ||
Ethereum = 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (c) Gala Games Inc. All rights reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { BigNumber } from "bignumber.js"; | ||
import { IsNotEmpty } from "class-validator"; | ||
|
||
import { ChainKey } from "../utils"; | ||
import { BigNumberIsNotNegative, BigNumberProperty, IsUserAlias } from "../validators"; | ||
import { ChainObject } from "./ChainObject"; | ||
|
||
export class FeeAuthorization extends ChainObject { | ||
public static INDEX_KEY = "GCFA"; | ||
|
||
@ChainKey({ position: 0 }) | ||
@IsUserAlias() | ||
public authority: string; | ||
|
||
@ChainKey({ position: 1 }) | ||
@IsNotEmpty() | ||
public year: string; | ||
|
||
@ChainKey({ position: 2 }) | ||
@IsNotEmpty() | ||
public month: string; | ||
|
||
@ChainKey({ position: 3 }) | ||
@IsNotEmpty() | ||
public day: string; | ||
|
||
@ChainKey({ position: 4 }) | ||
@IsNotEmpty() | ||
public txId: string; | ||
|
||
@IsNotEmpty() | ||
@BigNumberIsNotNegative() | ||
@BigNumberProperty() | ||
public quantity: BigNumber; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (c) Gala Games Inc. All rights reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { BigNumber } from "bignumber.js"; | ||
import { IsNotEmpty, IsString } from "class-validator"; | ||
|
||
import { ChainKey } from "../utils"; | ||
import { BigNumberIsNotNegative, BigNumberProperty, EnumProperty, IsUserAlias } from "../validators"; | ||
import { ChainObject } from "./ChainObject"; | ||
import { FeeReceiptStatus } from "./FeeReceiptStatus"; | ||
|
||
export class FeeBalanceCreditReceipt extends ChainObject { | ||
public static INDEX_KEY = "GCCR"; // CR = Credit Receipt | ||
|
||
@ChainKey({ position: 0 }) | ||
@IsNotEmpty() | ||
public year: string; | ||
|
||
@ChainKey({ position: 1 }) | ||
@IsNotEmpty() | ||
public month: string; | ||
|
||
@ChainKey({ position: 2 }) | ||
@IsNotEmpty() | ||
public day: string; | ||
|
||
@ChainKey({ position: 3 }) | ||
@IsString() | ||
@IsNotEmpty() | ||
public hours: string; | ||
|
||
@ChainKey({ position: 4 }) | ||
@IsString() | ||
@IsNotEmpty() | ||
public minutes: string; | ||
|
||
@ChainKey({ position: 5 }) | ||
@IsString() | ||
@IsNotEmpty() | ||
public seconds: string; | ||
|
||
@ChainKey({ position: 6 }) | ||
@IsUserAlias() | ||
public creditToUser: string; | ||
|
||
@ChainKey({ position: 7 }) | ||
@IsNotEmpty() | ||
public txId: string; | ||
|
||
@IsNotEmpty() | ||
@BigNumberIsNotNegative() | ||
@BigNumberProperty() | ||
public quantity: BigNumber; | ||
|
||
@EnumProperty(FeeReceiptStatus) | ||
public status: FeeReceiptStatus; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) Gala Games Inc. All rights reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { BigNumber } from "bignumber.js"; | ||
import { IsNotEmpty, IsString } from "class-validator"; | ||
|
||
import { ChainKey } from "../utils"; | ||
import { BigNumberIsNotNegative, BigNumberProperty, EnumProperty, IsUserAlias } from "../validators"; | ||
import { ChainObject } from "./ChainObject"; | ||
import { FeeReceiptStatus } from "./FeeReceiptStatus"; | ||
|
||
// Channel receipt. Indexed time-first, lookup by distribution period. | ||
export class FeeChannelPaymentReceipt extends ChainObject { | ||
public static INDEX_KEY = "GCFR"; // FR = Fee Receipt | ||
|
||
@ChainKey({ position: 0 }) | ||
@IsNotEmpty() | ||
public year: string; | ||
|
||
@ChainKey({ position: 1 }) | ||
@IsNotEmpty() | ||
public month: string; | ||
|
||
@ChainKey({ position: 2 }) | ||
@IsNotEmpty() | ||
public day: string; | ||
|
||
@ChainKey({ position: 3 }) | ||
@IsString() | ||
@IsNotEmpty() | ||
public feeCode: string; | ||
|
||
@ChainKey({ position: 4 }) | ||
@IsUserAlias() | ||
public paidByUser: string; | ||
|
||
// todo: consider adding hours and minutes | ||
// to the index as additional chain keys | ||
|
||
@ChainKey({ position: 5 }) | ||
@IsNotEmpty() | ||
public txId: string; | ||
|
||
@IsNotEmpty() | ||
@BigNumberIsNotNegative() | ||
@BigNumberProperty() | ||
public quantity: BigNumber; | ||
|
||
@EnumProperty(FeeReceiptStatus) | ||
public status: FeeReceiptStatus; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (c) Gala Games Inc. All rights reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { BigNumber } from "bignumber.js"; | ||
import { IsBoolean, IsNotEmpty, IsNumber, IsOptional, IsString } from "class-validator"; | ||
|
||
import { ChainKey } from "../utils"; | ||
import { BigNumberIsInteger, BigNumberIsNotNegative, BigNumberProperty, EnumProperty } from "../validators"; | ||
import { ChainObject } from "./ChainObject"; | ||
|
||
export enum FeeAccelerationRateType { | ||
CuratorDefined = 0, | ||
// optional? todo: define mathematically increasing fee schedules | ||
Additive = 1, | ||
Multiplicative = 2, | ||
Exponential = 3, | ||
Logarithmic = 4, | ||
Custom = 5 | ||
} | ||
|
||
export class FeeCodeDefinition extends ChainObject { | ||
public static INDEX_KEY = "GCFD"; | ||
public static DECIMAL_PRECISION = 8; | ||
|
||
@ChainKey({ position: 0 }) | ||
@IsString() | ||
@IsNotEmpty() | ||
public feeCode: string; | ||
|
||
@ChainKey({ position: 1 }) | ||
@BigNumberIsNotNegative() | ||
@BigNumberIsInteger() | ||
@BigNumberProperty() | ||
public feeThresholdUses: BigNumber; | ||
|
||
@IsNumber() | ||
public feeThresholdTimePeriod: number; | ||
|
||
@BigNumberIsNotNegative() | ||
@BigNumberProperty() | ||
public baseQuantity: BigNumber; | ||
|
||
@BigNumberIsNotNegative() | ||
@BigNumberProperty() | ||
public maxQuantity: BigNumber; | ||
|
||
@IsOptional() | ||
@BigNumberIsNotNegative() | ||
@BigNumberProperty() | ||
public maxUses?: BigNumber; | ||
|
||
@EnumProperty(FeeAccelerationRateType) | ||
public feeAccelerationRateType: FeeAccelerationRateType; | ||
|
||
@BigNumberProperty() | ||
public feeAccelerationRate: BigNumber; | ||
|
||
@IsOptional() | ||
@IsBoolean() | ||
public isCrossChannel?: boolean; | ||
} |
Oops, something went wrong.