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

Sprint 55 #1231

Merged
merged 17 commits into from
Nov 13, 2024
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/actions/create-env-file/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@ runs:
DFNS_WALLET_PUBLIC_KEY=$CLIENT_PUBLIC_KEY_ECDSA_2

HEDERA_TOKEN_MANAGER_ADDRESS=0.0.2167020
FACTORY_ADDRESS=0.0.2167166
FACTORY_ADDRESS=0.0.5088833
EOF
working-directory: sdk
4 changes: 2 additions & 2 deletions .github/workflows/test-contracts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- "contracts/test/**"
- "contracts/scripts/**"
- "contracts/package*.json"
- "contracts/hardhat.config.js"
- "contracts/hardhat.config.ts"
- "contracts/tsconfig.json"
push:
branches:
Expand All @@ -17,7 +17,7 @@ on:
- "contracts/test/**"
- "contracts/scripts/**"
- "contracts/package*.json"
- "contracts/hardhat.config.js"
- "contracts/hardhat.config.ts"
- "contracts/tsconfig.json"
# env:
# NODE_VERSION: "20.17.0" # Fixed version for better stability
Expand Down
1 change: 1 addition & 0 deletions FACTORY_VERSION.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
| Version | Contract name | Address | Network |
|---------| -------------- | ----------- | ------- |
| 1.27.0 | FactoryAddress | 0.0.5088833 | Testnet |
| 1.26.1 | FactoryAddress | 0.0.2167166 | Testnet |
| 1.26.0 | FactoryAddress | 0.0.2167166 | Testnet |
| 1.25.0 | FactoryAddress | 0.0.2167166 | Testnet |
Expand Down
4 changes: 2 additions & 2 deletions backend/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 backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hashgraph/stablecoin-npm-backend",
"version": "1.26.1",
"version": "1.27.0",
"description": "",
"author": "",
"license": "Apache-2.0",
Expand Down
33 changes: 19 additions & 14 deletions cli/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 cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hashgraph/stablecoin-npm-cli",
"version": "1.26.1",
"version": "1.27.0",
"description": "CLI for Hedera Stablecoin",
"main": "./build/src/index.js",
"bin": {
Expand Down
18 changes: 14 additions & 4 deletions cli/src/app/service/stablecoin/CreateStableCoinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,7 @@ export default class CreateStableCoinService extends Service {
const feeScheduleKey = await this.checkAnswer(
await utilsService.defaultMultipleAsk(
language.getText('stablecoin.features.feeSchedule'),
language.getArrayFromObject(
'wizard.nonSmartContractAndNoneFeatureOptions',
),
language.getArrayFromObject('wizard.nonNoneFeatureOptions'),
),
);
tokenToCreate.feeScheduleKey = feeScheduleKey;
Expand All @@ -297,6 +295,8 @@ export default class CreateStableCoinService extends Service {
tokenToCreate.freezeRoleAccount = currentAccount.accountId;
if (tokenToCreate.kycKey == Account.NullPublicKey)
tokenToCreate.kycRoleAccount = currentAccount.accountId;
if (tokenToCreate.feeScheduleKey == Account.NullPublicKey)
tokenToCreate.feeRoleAccount = currentAccount.accountId;
}

// Proof of Reserve
Expand Down Expand Up @@ -410,6 +410,7 @@ export default class CreateStableCoinService extends Service {
freezeRole: tokenToCreate.freezeRoleAccount,
deleteRole: tokenToCreate.deleteRoleAccount,
kycRole: tokenToCreate.kycRoleAccount,
feeRole: tokenToCreate.feeRoleAccount,
cashinRole: tokenToCreate.cashInRoleAccount,
cashinAllowance: tokenToCreate.cashInRoleAllowance,
metadata: tokenToCreate.metadata,
Expand Down Expand Up @@ -622,6 +623,14 @@ export default class CreateStableCoinService extends Service {
'kycRoleAccount',
);

if (tokenToCreate.feeScheduleKey == Account.NullPublicKey)
await this.askForAccount(
language.getText('stablecoin.initialRoles.feeSchedule'),
currentAccountId,
tokenToCreate,
'feeRoleAccount',
);

const result: string = await this.askForAccount(
language.getText('stablecoin.initialRoles.cashin'),
currentAccountId,
Expand Down Expand Up @@ -656,7 +665,8 @@ export default class CreateStableCoinService extends Service {
| 'freezeRoleAccount'
| 'deleteRoleAccount'
| 'kycRoleAccount'
| 'cashInRoleAccount',
| 'cashInRoleAccount'
| 'feeRoleAccount',
): Promise<string> {
const options = [
language.getText('stablecoin.initialRoles.options.currentAccount'),
Expand Down
82 changes: 72 additions & 10 deletions cli/src/app/service/stablecoin/OperationStableCoinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export default class OperationStableCoinService extends Service {
private stableCoinDeleted;
private hasKycKey;
private hasFreezeKey;
private hasFeeScheduleKey;
private isFrozen;

// private tokenUpdate: IManagedFeatures = undefined;
Expand Down Expand Up @@ -213,6 +214,8 @@ export default class OperationStableCoinService extends Service {
this.stableCoinDeleted = capabilitiesStableCoin.coin.deleted;
this.stableCoinPaused = capabilitiesStableCoin.coin.paused;
this.hasKycKey = capabilitiesStableCoin.coin.kycKey !== undefined;
this.hasFeeScheduleKey =
capabilitiesStableCoin.coin.feeScheduleKey !== undefined;
this.hasFreezeKey = capabilitiesStableCoin.coin.freezeKey !== undefined;

const freezeAccountRequest = new FreezeAccountRequest({
Expand Down Expand Up @@ -639,6 +642,30 @@ export default class OperationStableCoinService extends Service {
);
}

public hasHTSAccess = (
operation: Operation,
stableCoinCapabilities: StableCoinCapabilities,
) =>
stableCoinCapabilities?.capabilities.find(
(cap) => cap.operation === operation,
)?.access === Access.HTS;

public hasSCAccess = (
operation: Operation,
role: StableCoinRole,
stableCoinCapabilities: StableCoinCapabilities,
roles: string[],
) => {
if (
stableCoinCapabilities?.capabilities.find(
(cap) => cap.operation === operation,
)?.access === Access.CONTRACT
) {
if (roles?.includes(role)) return true;
}
return false;
};

private async sendTokens(sender: string): Promise<void> {
const getAccountBalanceRequest = new GetAccountBalanceRequest({
tokenId: this.stableCoinId,
Expand Down Expand Up @@ -1092,9 +1119,9 @@ export default class OperationStableCoinService extends Service {
this.stableCoinPaused,
this.stableCoinDeleted,
);
const capabilities: Operation[] = stableCoinCapabilities.capabilities.map(
(a) => a.operation,
);

const roles: string[] = await this.getRolesAccount();

const detailsStableCoin =
await new DetailsStableCoinService().getDetailsStableCoins(
this.stableCoinId,
Expand All @@ -1106,13 +1133,35 @@ export default class OperationStableCoinService extends Service {
.filter((option) => {
switch (option) {
case language.getText('feeManagement.options.Create'):
return (
this.hasHTSAccess(
Operation.CREATE_CUSTOM_FEE,
stableCoinCapabilities,
) ||
this.hasSCAccess(
Operation.CREATE_CUSTOM_FEE,
StableCoinRole.CUSTOM_FEES_ROLE,
stableCoinCapabilities,
roles,
)
);
break;
case language.getText('feeManagement.options.Remove'):
return (
this.hasHTSAccess(
Operation.REMOVE_CUSTOM_FEE,
stableCoinCapabilities,
) ||
this.hasSCAccess(
Operation.REMOVE_CUSTOM_FEE,
StableCoinRole.CUSTOM_FEES_ROLE,
stableCoinCapabilities,
roles,
)
);
break;
case language.getText('feeManagement.options.List'):
const showCustomFee: boolean =
option == language.getText('feeManagement.options.Create')
? capabilities.includes(Operation.CREATE_CUSTOM_FEE)
: capabilities.includes(Operation.REMOVE_CUSTOM_FEE);
return showCustomFee;
return this.hasFeeScheduleKey;
break;
}
// TODO DELETE STABLECOIN
Expand Down Expand Up @@ -1598,6 +1647,10 @@ export default class OperationStableCoinService extends Service {
await this.getAccountsWithRole(StableCoinRole.KYC_ROLE);
break;

case language.getText('wizard.CheckAccountsWithRoleOptions.Fees'):
await this.getAccountsWithRole(StableCoinRole.CUSTOM_FEES_ROLE);
break;

default:
break;
}
Expand Down Expand Up @@ -2331,8 +2384,7 @@ export default class OperationStableCoinService extends Service {
capabilities.includes(Operation.DELETE))) ||
option === language.getText('wizard.stableCoinOptions.RoleMgmt') ||
(option === language.getText('wizard.stableCoinOptions.FeesMgmt') &&
(capabilities.includes(Operation.CREATE_CUSTOM_FEE) ||
capabilities.includes(Operation.REMOVE_CUSTOM_FEE))) ||
this.hasFeeScheduleKey) ||
(option === language.getText('wizard.stableCoinOptions.Details') &&
!this.stableCoinDeleted) ||
(option === language.getText('wizard.stableCoinOptions.Balance') &&
Expand Down Expand Up @@ -2727,6 +2779,16 @@ export default class OperationStableCoinService extends Service {
id: tokenKeys.kyc,
},
},
{
role: {
availability:
capabilities.includes(Operation.CREATE_CUSTOM_FEE) ||
capabilities.includes(Operation.REMOVE_CUSTOM_FEE),
name: 'Fees Role',
value: StableCoinRole.CUSTOM_FEES_ROLE,
id: tokenKeys.feeSchedule,
},
},
{
role: {
// TODO Eliminar el DELETE HTS cuando se pueda eliminar desde contrato (SOLO para ver la opción)
Expand Down
2 changes: 2 additions & 0 deletions cli/src/resources/config/language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ export const english = {
delete: 'Choose the DELETE admin account',
kyc: 'Choose the KYC admin account',
cashin: 'Choose the CASHIN admin account',
feeSchedule: 'Choose the FEE SCHEDULE admin account',
options: {
currentAccount: 'Current User Account',
otherAccount: 'Other Account',
Expand Down Expand Up @@ -464,6 +465,7 @@ export const english = {
Freeze: 'Freeze',
Delete: 'Delete',
KYC: 'KYC',
Fees: 'Fees',
...goBack,
},

Expand Down
Loading
Loading