Skip to content

Commit

Permalink
feat: Update signature conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
DaevMithran committed Dec 9, 2022
1 parent 242e82f commit 2824bcb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { SignMode } from 'cosmjs-types/cosmos/tx/signing/v1beta1/signing'
import { Any } from 'cosmjs-types/google/protobuf/any'
import { Coin } from 'cosmjs-types/cosmos/base/v1beta1/coin'
import Long from 'long'
import { fromString } from 'uint8arrays'

export function calculateDidFee(gasLimit: number, gasPrice: string | GasPrice): DidStdFee {
return calculateFee(gasLimit, gasPrice)
Expand Down Expand Up @@ -204,7 +205,7 @@ export class CheqdSigningStargateClient extends SigningStargateClient {
return {
verificationMethodId: signInput.verificationMethodId,
// TODO: We can't rely on `payload.verificationMethod` here because `CreateResourceTx` doesn't have it
signature: base64ToBytes((await (await this.getDidSigner(signInput.verificationMethodId, payload.verificationMethod))(hexToBytes(signInput.privateKeyHex))(signBytes)) as string)
signature: fromString((await (await this.getDidSigner(signInput.verificationMethodId, payload.verificationMethod))(hexToBytes(signInput.privateKeyHex))(signBytes)) as string)
}
}))

Expand All @@ -219,7 +220,7 @@ export class CheqdSigningStargateClient extends SigningStargateClient {
return {
verificationMethodId: signInput.verificationMethodId,
// TODO: We can't rely on `payload.verificationMethod` here because `CreateResourceTx` doesn't have it
signature: base64ToBytes((await (await this.getDidSigner(signInput.verificationMethodId, payload.verificationMethod))(hexToBytes(signInput.privateKeyHex))(signBytes)) as string)
signature: fromString((await (await this.getDidSigner(signInput.verificationMethodId, payload.verificationMethod))(hexToBytes(signInput.privateKeyHex))(signBytes)) as string)
}
}))

Expand All @@ -234,7 +235,7 @@ export class CheqdSigningStargateClient extends SigningStargateClient {
return {
verificationMethodId: signInput.verificationMethodId,
// TODO: We can't rely on `payload.verificationMethod` here because `CreateResourceTx` doesn't have it
signature: base64ToBytes((await (await this.getDidSigner(signInput.verificationMethodId, verificationMethod))(hexToBytes(signInput.privateKeyHex))(signBytes)) as string)
signature: fromString((await (await this.getDidSigner(signInput.verificationMethodId, verificationMethod))(hexToBytes(signInput.privateKeyHex))(signBytes)) as string)
}
}))

Expand Down Expand Up @@ -267,7 +268,7 @@ export class CheqdSigningStargateClient extends SigningStargateClient {

signInfos.push({
verificationMethodId: signInput.verificationMethodId,
signature: base64ToBytes(signature)
signature: fromString(signature)
});
}

Expand Down
6 changes: 3 additions & 3 deletions tests/modules/did.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('DIDModule', () => {
amount: [
{
denom: 'ncheq',
amount: '5000000'
amount: '5000000000'
}
],
gas: '100000',
Expand Down Expand Up @@ -79,7 +79,7 @@ describe('DIDModule', () => {
amount: [
{
denom: 'ncheq',
amount: '5000000'
amount: '5000000000'
}
],
gas: '100000',
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('DIDModule', () => {
amount: [
{
denom: 'ncheq',
amount: '5000000'
amount: '5000000000'
}
],
gas: '100000',
Expand Down
2 changes: 1 addition & 1 deletion tests/modules/resource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('ResourceModule', () => {
amount: [
{
denom: 'ncheq',
amount: '50000000'
amount: '2500000000'
}
],
gas: '1000000',
Expand Down

0 comments on commit 2824bcb

Please sign in to comment.