Skip to content

Commit

Permalink
Sync updates in v4
Browse files Browse the repository at this point in the history
  • Loading branch information
DaevMithran committed Aug 28, 2024
1 parent 9b10a3d commit b495672
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 45 deletions.
3 changes: 1 addition & 2 deletions .github/linters/.markdown-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ MD022: true
MD023: true

# Multiple headings with the same content <https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md024>
MD024:
allow_different_nesting: true
MD024: false

# Multiple top level headings in the same document <https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md025>
MD025: false
Expand Down
40 changes: 20 additions & 20 deletions .github/linters/mlc_config.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"aliveStatusCodes": [0, 200, 206, 403, 501, 999],
"replacementPatterns": [
{
"pattern": "\" %}",
"replacement": ""
},
{
"pattern": "&quot; %}",
"replacement": ""
}
],
"ignorePatterns": [
{
"pattern": "^https://resolver.cheqd.net/"
},
{
"pattern": "^https://twitter.com/"
}
],
"retryOn429": true
"aliveStatusCodes": [0, 200, 206, 403, 501, 999],
"replacementPatterns": [
{
"pattern": "\" %}",
"replacement": ""
},
{
"pattern": "&quot; %}",
"replacement": ""
}
],
"ignorePatterns": [
{
"pattern": "^https://resolver.cheqd.net/"
},
{
"pattern": "^https://twitter.com/"
}
],
"retryOn429": true
}
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: amannn/action-semantic-pull-request@v5.2.0
- uses: amannn/action-semantic-pull-request@v5.5.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- name: "Obtain Github App token"
id: app-token
uses: getsentry/action-github-app-token@v2.0.0
uses: getsentry/action-github-app-token@v3.0.0
with:
app_id: ${{ secrets.BOT_APP_ID }}
private_key: ${{ secrets.BOT_APP_PRIVATE_KEY }}
Expand Down
39 changes: 39 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@
"@cosmjs/tendermint-rpc": "~0.30.0",
"@cosmjs/utils": "~0.30.0",
"@stablelib/ed25519": "^1.0.3",
"@types/secp256k1": "^4.0.3",
"cosmjs-types": "^0.7.1",
"did-jwt": "^8.0.4",
"did-resolver": "^4.1.0",
"file-type": "^16.5.4",
"long": "^4.0.0",
"multiformats": "^9.9.0",
"secp256k1": "^5.0.0",
"uuid": "^10.0.0"
},
"devDependencies": {
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,8 @@ export {
createSignInputsFromImportableEd25519Key,
validateSpecCompliantPayload,
isEqualKeyValuePair,
createCosmosPayerWallet,
getCosmosAccount,
checkBalance,
toMultibaseRaw,
} from './utils';
14 changes: 7 additions & 7 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ import { base64ToBytes } from 'did-jwt';
import { generateKeyPair, generateKeyPairFromSeed, KeyPair } from '@stablelib/ed25519';
import { DirectSecp256k1HdWallet, DirectSecp256k1Wallet } from '@cosmjs/proto-signing';
import { EnglishMnemonic as _, sha256 } from '@cosmjs/crypto';
import { rawSecp256k1PubkeyToRawAddress } from '@cosmjs/amino';
import pkg from 'secp256k1';
import { v4 } from 'uuid';
import {
VerificationMethod as ProtoVerificationMethod,
Service as ProtoService,
MsgCreateDidDocPayload,
MsgDeactivateDidDocPayload,
} from '@cheqd/ts-proto/cheqd/did/v2';
import { MsgCreateResourcePayload } from '@cheqd/ts-proto/cheqd/resource/v2';
import { DIDModule } from './modules/did';
import { MsgCreateResourcePayload } from '@cheqd/ts-proto/cheqd/resource/v2';
import { toBech32 } from '@cosmjs/encoding';
import { StargateClient } from '@cosmjs/stargate';
import { Coin } from 'cosmjs-types/cosmos/base/v1beta1/coin';
import { rawSecp256k1PubkeyToRawAddress } from '@cosmjs/amino';
import pkg from 'secp256k1';

export type TImportableEd25519Key = {
publicKeyHex: string;
Expand Down Expand Up @@ -310,6 +310,10 @@ export function createMsgDeactivateDidDocPayloadToSign(didPayload: DIDDocument,
).finish();
}

export function createMsgResourcePayloadToSign(payload: Partial<MsgCreateResourcePayload> | MsgCreateResourcePayload) {
return MsgCreateResourcePayload.encode(MsgCreateResourcePayload.fromPartial(payload)).finish();
}

export function getCosmosAccount(publicKeyHex: string): string {
const { publicKeyConvert } = pkg;

Expand All @@ -322,10 +326,6 @@ export async function checkBalance(address: string, rpcAddress: string): Promise
return await client.getAllBalances(address);
}

export function createMsgResourcePayloadToSign(payload: Partial<MsgCreateResourcePayload> | MsgCreateResourcePayload) {
return MsgCreateResourcePayload.encode(MsgCreateResourcePayload.fromPartial(payload)).finish();
}

export function isJSON(input: any): boolean {
if (typeof input !== 'string') return false;
try {
Expand Down
26 changes: 12 additions & 14 deletions tests/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
createKeyPairRaw,
getCosmosAccount,
} from '../src/utils';
import { toString } from 'uint8arrays';
import { toString } from 'uint8arrays/to-string';
import { IKeyPair, MethodSpecificIdAlgo, VerificationMethods } from '../src/types';
import { faucet_address, pubkey_hex, testnet_rpc } from './testutils.test';

Expand Down Expand Up @@ -82,21 +82,19 @@ describe('createSignInputsFromImportableEd25519Key', () => {
});
});

it('should get the cosmos account from publicKeyHex', () => {
// We know, that such point could be transformed to a cheqd account cheqd1ehcg0jarxkyxtkzrwcxayedxrskwyftxj4exm9
const expectedAddress = "cheqd1ehcg0jarxkyxtkzrwcxayedxrskwyftxj4exm9"
it('should get the cosmos account from publicKeyHex', () => {
// We know, that such point could be transformed to a cheqd account cheqd1ehcg0jarxkyxtkzrwcxayedxrskwyftxj4exm9
const expectedAddress = 'cheqd1ehcg0jarxkyxtkzrwcxayedxrskwyftxj4exm9';

expect(expectedAddress).toEqual(getCosmosAccount(pubkey_hex))

})
expect(expectedAddress).toEqual(getCosmosAccount(pubkey_hex));
});

it('should return not empty account balance', async () => {
const balances = await checkBalance(faucet_address, testnet_rpc)
expect(balances.length).toBeGreaterThan(0)
expect(balances[0].denom).toEqual("ncheq")
expect(+balances[0].amount).toBeGreaterThan(0)
})
})
it('should return not empty account balance', async () => {
const balances = await checkBalance(faucet_address, testnet_rpc);
expect(balances.length).toBeGreaterThan(0);
expect(balances[0].denom).toEqual('ncheq');
expect(+balances[0].amount).toBeGreaterThan(0);
});

it('should return valid json', async () => {
// define invalid cases
Expand Down

0 comments on commit b495672

Please sign in to comment.