Skip to content

Commit

Permalink
Merge pull request #1178 from kadena-community/fix/client-pred
Browse files Browse the repository at this point in the history
Fix client predicate type
  • Loading branch information
javadkh2 authored Nov 6, 2023
2 parents 60dad5e + 445fb2c commit 418b351
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 15 deletions.
6 changes: 6 additions & 0 deletions .changeset/pretty-balloons-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@kadena/client': patch
'@kadena/client-utils': patch
---

Fix pred type for keysets
2 changes: 1 addition & 1 deletion packages/libs/client-utils/src/coin/create-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface ICreateAccountCommandInput {
account: string;
keyset: {
keys: string[];
pred: 'keys-all' | 'keys-two' | 'keys-one';
pred: 'keys-all' | 'keys-2' | 'keys-any';
};
gasPayer: { account: string; publicKeys: string[] };
chainId: ChainId;
Expand Down
2 changes: 1 addition & 1 deletion packages/libs/client-utils/src/coin/rotate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface IRotateCommandInput {
account: { account: string; publicKeys: string[] };
newguard: {
keys: string[];
pred: 'keys-all' | 'keys-two' | 'keys-one';
pred: 'keys-all' | 'keys-2' | 'keys-any';
};
gasPayer: { account: string; publicKeys: string[] };
chainId: ChainId;
Expand Down
2 changes: 1 addition & 1 deletion packages/libs/client-utils/src/coin/transfer-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface ICreateTransferInput {
account: string;
keyset: {
keys: string[];
pred: 'keys-all' | 'keys-two' | 'keys-one';
pred: 'keys-all' | 'keys-2' | 'keys-any';
};
};
amount: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/libs/client-utils/src/coin/transfer-crosschain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface ICrossChainInput {
account: string;
keyset: {
keys: string[];
pred: 'keys-all' | 'keys-two' | 'keys-one';
pred: 'keys-all' | 'keys-2' | 'keys-any';
};
};
amount: string;
Expand Down
14 changes: 7 additions & 7 deletions packages/libs/client/src/composePactCommand/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ const command = {

add keyset to the data part

| parameter | type | description |
| ------------- | ------------------------------------------------ | -------------------------------------------- |
| name | string | name of the keyset |
| pred | "keys-all" \| "keys-one" \| "keys-two" \| string | type of pred |
| ...publicKeys | string[] | list of the public keys to add to the keyset |
| parameter | type | description |
| ------------- | ---------------------------------------------- | -------------------------------------------- |
| name | string | name of the keyset |
| pred | "keys-all" \| "keys-any" \| "keys-2" \| string | type of pred |
| ...publicKeys | string[] | list of the public keys to add to the keyset |

<details>
<summary>examples</summary>
Expand All @@ -180,7 +180,7 @@ const command = composePactCommand(
execution(
coin.transfer(readKeyset("senderKey"), "bob", { decimal: "1.1" })
),
addKeyset("senderKey","keys-one", "the_public_key")
addKeyset("senderKey","keys-any", "the_public_key")
)()

//
Expand All @@ -190,7 +190,7 @@ const command = {
data: {
senderKey: {
publicKeys: ['the_public_key'],
pred: "keys-one"
pred: "keys-any"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const addData: (
};

export interface IAddKeyset {
<TKey extends string, PRED extends 'keys-all' | 'keys-one' | 'keys-two'>(
<TKey extends string, PRED extends 'keys-all' | 'keys-any' | 'keys-2'>(
key: TKey,
pred: PRED,
...publicKeys: string[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { addKeyset } from '../addKeyset';

describe('addKeyset', () => {
it('returns keyset data format', () => {
expect(addKeyset('test', 'keys-one', 'p1', 'p2')({})).toEqual({
expect(addKeyset('test', 'keys-any', 'p1', 'p2')({})).toEqual({
payload: {
exec: {
data: {
test: {
keys: ['p1', 'p2'],
pred: 'keys-one',
pred: 'keys-any',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ interface ISetNonce<TCommand> {
}

interface IAddKeyset<TCommand> {
<TKey extends string, PRED extends 'keys-all' | 'keys-one' | 'keys-two'>(
<TKey extends string, PRED extends 'keys-all' | 'keys-any' | 'keys-2'>(
key: TKey,
pred: PRED,
...publicKeys: string[]
Expand Down

0 comments on commit 418b351

Please sign in to comment.