Skip to content

Commit

Permalink
feat: required permissions can be non-active
Browse files Browse the repository at this point in the history
  • Loading branch information
theblockstalk committed Sep 5, 2024
1 parent 74f4a2c commit 048e325
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/cli/msig/addAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ export async function addAuth(
},
};

const requested = [...options.requested, { actor: args.account, permission: args.permission }];

const proposalHash = await createProposal(
options.proposer,
options.proposalName,
[action],
options.privateKey,
options.requested
requested
);

if (options.test) await executeProposal(options.proposer, options.proposalName, proposalHash);
Expand Down
32 changes: 23 additions & 9 deletions src/cli/msig/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PrivateKey, Name, Checksum256, PublicKey, Weight } from '@wharfkit/antelope';
import { PrivateKey, Name, Checksum256, PublicKey, Weight, NameType } from '@wharfkit/antelope';
import { EosioMsigContract, setSettings } from '../../sdk';
import { ActionData, createSigner, getProducers } from '../../sdk/services/blockchain';
import settings from '../bootstrap/settings';
Expand Down Expand Up @@ -141,9 +141,9 @@ export default async function msig(args: string[]) {
} else if (proposalType === 'add-auth') {
await addAuth(
{
account: 'coinsale.tmy',
permission: 'active',
newDelegate: settings.isProduction() ? '14.found.tmy' : governanceAccounts[2],
account: 'join.hypha',
permission: 'owner',
newDelegate: 'gov.tmy',
},
{
proposer,
Expand Down Expand Up @@ -357,17 +357,31 @@ export default async function msig(args: string[]) {
}
}

type PermissionLevelType = {
actor: NameType;
permission: NameType;
};

export async function createProposal(
proposer: string,
proposalName: Name,
actions: ActionData[],
privateKey: PrivateKey,
requested: string[]
requested: (string | PermissionLevelType)[]
): Promise<Checksum256> {
const requestedPermissions = requested.map((actor) => ({
actor,
permission: 'active',
}));
const requestedPermissions = requested.map((actor) => {
if (typeof actor === 'string') {
return {
actor,
permission: 'active',
};
}

return {
actor: actor.actor.toString(),
permission: actor.permission.toString(),
};
});

console.log(
'Sending transaction',
Expand Down

0 comments on commit 048e325

Please sign in to comment.